From fa9aaa6d27b90d7ee7c45c33723414b9d9a7e575 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Sun, 1 Jun 2025 11:19:04 +0800 Subject: [PATCH] feat(home/linux/gui/hyprland): hypridle & windowrules & keybindings --- README.md | 1 + .../linux/gui/hyprland/conf/configs/exec.conf | 3 - .../hyprland/conf/configs/keybindings.conf | 217 ++++++++++++------ .../gui/hyprland/conf/configs/settings.conf | 152 ++++++++---- .../hyprland/conf/configs/windowrules.conf | 82 +++++-- home/linux/gui/hyprland/conf/hypridle.conf | 26 ++- home/linux/gui/hyprland/values/packages.nix | 1 + 7 files changed, 333 insertions(+), 149 deletions(-) diff --git a/README.md b/README.md index 63683625..e771d638 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,7 @@ Other dotfiles that inspired me: journey. - [HeinzDev/Hyprland-dotfiles](https://github.com/HeinzDev/Hyprland-dotfiles): Refer to the waybar configuration here. + - [Zeioth/zeioth-hyprland-config](https://github.com/Zeioth/zeioth-hyprland-config) - [linuxmobile/kaku](https://github.com/linuxmobile/kaku) - Neovim/AstroNvim - [maxbrunet/dotfiles](https://github.com/maxbrunet/dotfiles): astronvim with nix flakes. diff --git a/home/linux/gui/hyprland/conf/configs/exec.conf b/home/linux/gui/hyprland/conf/configs/exec.conf index 360406a7..e08fa716 100644 --- a/home/linux/gui/hyprland/conf/configs/exec.conf +++ b/home/linux/gui/hyprland/conf/configs/exec.conf @@ -1,9 +1,6 @@ #-- Startup ---------------------------------------------------- exec-once = waybar --bar main-bar --log-level error -#-- Idle Daemon -- -exec-once = hypridle - ## Fix anyrun ## https://github.com/anyrun-org/anyrun/issues/153 exec-once = ln -s "$XDG_RUNTIME_DIR/hypr" /tmp/hypr diff --git a/home/linux/gui/hyprland/conf/configs/keybindings.conf b/home/linux/gui/hyprland/conf/configs/keybindings.conf index 097408b8..0ab7c272 100644 --- a/home/linux/gui/hyprland/conf/configs/keybindings.conf +++ b/home/linux/gui/hyprland/conf/configs/keybindings.conf @@ -1,89 +1,154 @@ +# https://wiki.hyprland.org/Configuring/Binds/ +# +# Format: +# bind = MODS, key, dispatcher, params + #-- Keybindings ---------------------------------------------------- -$term = foot -$app_launcher = anyrun +$mod = ALT # use ALT instead of SUPER, to match the mod key with aerospace on darwin. $files = thunar $browser = firefox -# -- Terminal -- -bind=SUPER,Return,exec,$term -# -- App Launcher -- -bind=SUPER,D,exec,$app_launcher +# SYSTEM +# ============================================================================ -# -- Hyprland -- -bind=SUPER,Q,killactive, -bind=CTRLALT,Delete,exit, -bind=SUPER,F,fullscreen, -bind=SUPER,Space,togglefloating, -bind=SUPER,S,pseudo, +# - Drag modifier +# BIND MOD KEY DISPATCHER +bindm = $mod, mouse:272, movewindow +bindm = $mod, mouse:273, resizewindow -# -- Misc -- -bind=SUPER,N,exec,nm-connection-editor # need install network-manager-applet -bind=CTRLALT,L,exec,hyprlock -bind=SUPERSHIFT,X,exec,wlogout +# - System +# BIND MOD KEY DISPATCHER VALUE +bind = $mod, q, killactive # kill window -# -- Some nice mouse binds -- -bindm=SUPER,mouse:272,movewindow -bindm=SUPER,mouse:273,resizewindow +# - Terminal +# BIND MOD KEY DISPATCHER VALUE +bind = $mod, Return, exec, foot +bind = $mod SHIFT, Return, exec, alacritty +bind = $mod, d, exec, anyrun -# -- Function keys -- -# bind=,XF86MonBrightnessUp,exec,brightnessctl set 5%+ -# bind=,XF86MonBrightnessDown,exec, brightnessctl set 5%- -# +# - Hardware control +# BIND MOD KEY DISPATCHER VALUE # https://wiki.archlinux.org/title/WirePlumber -bind=,XF86AudioRaiseVolume,exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 10%+ -bind=,XF86AudioLowerVolume,exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 10%- -bind=,XF86AudioMute,exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle -bind=,XF86AudioMicMute,exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle +bindel = , XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ +bindel = , XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- +bindl = , XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle +bindl = , XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle +bind = , XF86MonBrightnessUp, exec, brightnessctl set 5%+ +bind = , XF86MonBrightnessDown, exec, brightnessctl set 5%- +bind = , XF86AudioPlay, exec, playerctl play-pause +bind = , XF86AudioNext, exec, playerctl next +bind = , XF86AudioPrev, exec, playerctl previous +bind = , XF86Search, exec, anyrun +bind = , XF86PowerOff, exec, shutdown -h now + +# WORKSPACES +# ============================================================================ + +# - Switch to workspace +# BIND MOD KEY DISPATCHER VALUE +bind = $mod, 1, workspace, 1 +bind = $mod, 2, workspace, 2 +bind = $mod, 3, workspace, 3 +bind = $mod, 4, workspace, 4 +bind = $mod, 5, workspace, 5 +bind = $mod, 6, workspace, 6 +bind = $mod, 7, workspace, 7 +bind = $mod, 8, workspace, 8 +bind = $mod, 9, workspace, 9 +bind = $mod, 0, workspace, 10 + +# - Move focussed window to workspace +# BIND MOD KEY DISPATCHER VALUE +bind = $mod SHIFT, 1, movetoworkspace, 1 +bind = $mod SHIFT, 2, movetoworkspace, 2 +bind = $mod SHIFT, 3, movetoworkspace, 3 +bind = $mod SHIFT, 4, movetoworkspace, 4 +bind = $mod SHIFT, 5, movetoworkspace, 5 +bind = $mod SHIFT, 6, movetoworkspace, 6 +bind = $mod SHIFT, 7, movetoworkspace, 7 +bind = $mod SHIFT, 8, movetoworkspace, 8 +bind = $mod SHIFT, 9, movetoworkspace, 9 +bind = $mod SHIFT, 0, movetoworkspace, 10 + +bind = $mod, mouse_down, workspace, e+1 +bind = $mod, mouse_up, workspace, e-1 + + +# Window +# ============================================================================ + +# Move Window +bind = $mod SHIFT, left, movewindow, l +bind = $mod SHIFT, right, movewindow, r +bind = $mod SHIFT, up, movewindow, u +bind = $mod SHIFT, down, movewindow, d + +# Focus Window +bind = $mod, left, movefocus, l +bind = $mod, right, movefocus, r +bind = $mod, up, movefocus, u +bind = $mod, down, movefocus, d + +# Resize Window +bind = $mod CTRL, left, resizeactive, -20 0 +bind = $mod CTRL, right, resizeactive, 20 0 +bind = $mod CTRL, up, resizeactive, 0 -20 +bind = $mod CTRL, down, resizeactive, 0 20 + +# MODES +# ============================================================================ + +# BIND MOD KEY DISPATCHER VALUE +bind = $mod SHIFT, d, submap, mode_displays +bind = $mod SHIFT, a, submap, mode_move +bind = $mod , r, submap, mode_resize +bind = $mod SHIFT, s, submap, mode_screenshot +bind = $mod SHIFT, e, submap, mode_shutdown + +# LAYOUT +# ============================================================================ + +# ## Action // Toggle floating ## +bind = $mod, space, togglefloating + +# ## Action // Toggle fullscreen ## +bind = $mod, f, fullscreen + +# ## Action // Toggle fullscreen across all monitors## +# WIP: https://github.com/hyprwm/Hyprland/issues/1660 +# bind = $mod SHIFT, f, fullscreen global + +# ## Setting // Split windows horizontally ## +# bind = $mod, b, splith + +# ## Setting // Split windows vertically ## +# bind = $mod, v, splitv + +# ## Action // Switch to window stacking ## +# bind = $mod, s, layout stacking + +# ## Action // Switch to window tabbing ## +# bind = $mod, w, layout tabbed + +# ## Action // Toggle window splitting ## +# bind = $mod, e, layout toggle split + +# ## Navigation // Toggle focus between tiling and floating ## +# bind = $mod, space, focus mode_toggle + +# ## Navigation // Swap focus to the parent window ## +# bind = $mod, a, focus parent + + +# Misc +# ============================================================================ # -- Screenshots -- -bind=,Print,exec,hyprshot -m output -o ~/Pictures/Screenshots -- imv -bind=SUPER,Print,exec,hyprshot -m window -o ~/Pictures/Screenshots -- imv -bind=CTRL,Print,exec,flameshot gui --raw -p ~/Pictures/Screenshots | wl-copy - -# Focus -bind=SUPER,left,movefocus,l -bind=SUPER,right,movefocus,r -bind=SUPER,up,movefocus,u -bind=SUPER,down,movefocus,d - -# Move -bind=SUPERSHIFT,left,movewindow,l -bind=SUPERSHIFT,right,movewindow,r -bind=SUPERSHIFT,up,movewindow,u -bind=SUPERSHIFT,down,movewindow,d - -# Resize -bind=SUPERCTRL,left,resizeactive,-20 0 -bind=SUPERCTRL,right,resizeactive,20 0 -bind=SUPERCTRL,up,resizeactive,0 -20 -bind=SUPERCTRL,down,resizeactive,0 20 - -# Workspaces -bind=SUPER,1,workspace,1 -bind=SUPER,2,workspace,2 -bind=SUPER,3,workspace,3 -bind=SUPER,4,workspace,4 -bind=SUPER,5,workspace,5 -bind=SUPER,6,workspace,6 -bind=SUPER,7,workspace,7 -bind=SUPER,8,workspace,8 -bind=SUPER,9,workspace,9 -bind=SUPER,0,workspace,10 - -# Send to Workspaces -bind=SUPERSHIFT,1,movetoworkspace,1 -bind=SUPERSHIFT,2,movetoworkspace,2 -bind=SUPERSHIFT,3,movetoworkspace,3 -bind=SUPERSHIFT,4,movetoworkspace,4 -bind=SUPERSHIFT,5,movetoworkspace,5 -bind=SUPERSHIFT,6,movetoworkspace,6 -bind=SUPERSHIFT,7,movetoworkspace,7 -bind=SUPERSHIFT,8,movetoworkspace,8 -bind=SUPERSHIFT,9,movetoworkspace,9 -bind=SUPERSHIFT,0,movetoworkspace,10 - -bind=SUPER,mouse_down,workspace,e+1 -bind=SUPER,mouse_up,workspace,e-1 - +bind = , Print, exec, hyprshot -m output -o ~/Pictures/Screenshots -- imv +bind = $mod, Print, exec, hyprshot -m window -o ~/Pictures/Screenshots -- imv +bind = CTRL, Print, exec, flameshot gui --raw -p ~/Pictures/Screenshots | wl-copy +bind = CTRL ALT, l, exec, hyprlock +bind = $mod SHIFT, x, exec, wlogout +bind = $mod, n, exec, nm-connection-editor # need install network-manager-applet diff --git a/home/linux/gui/hyprland/conf/configs/settings.conf b/home/linux/gui/hyprland/conf/configs/settings.conf index 806ddbc9..9eac8239 100644 --- a/home/linux/gui/hyprland/conf/configs/settings.conf +++ b/home/linux/gui/hyprland/conf/configs/settings.conf @@ -1,12 +1,110 @@ -#-- General ---------------------------------------------------- -# General settings like MOD key, Gaps, Colors, etc. +# WINDOWS AND BORDERS +# ================================================ general { - gaps_in=5 - gaps_out=10 + layout = dwindle - border_size=4 - col.active_border=0xFFB4A1DB - col.inactive_border=0xFF343A40 + # Cursor + no_focus_fallback = true + + # Gaps + gaps_in = 5 + gaps_out = 5 + + # Borders + border_size = 2 + col.active_border = 0xff4477ff + col.inactive_border = 0xff2f343f + + # Resize + resize_on_border = false + hover_icon_on_border = false + + # Allow tearing (you must add a window rule to the window to allow tearing) + allow_tearing = false +} + +cursor { + inactive_timeout = 900 # Hide the cursor after n ms (also works on screenlock) + no_warps = false # Never move the cursor automatically +} + +ecosystem { + no_donation_nag = true +} + +misc { + # Allow windows to steal focus - (only xorg apps currently) + focus_on_activate = false + + # Enable if you use personalized wallpapers + disable_hyprland_logo = true +} + +# VISUAL EFFECTS +# ================================================ + +# See: https://wiki.hyprland.org/Configuring/Variables +decoration { + + # Round borders + rounding = 8 + + # Shadow + shadow { + enabled = true + range = 4 + render_power = 3 + color = rgba(1a1a1aee) + } + + active_opacity=1.0 + inactive_opacity=0.9 + fullscreen_opacity=1.0 + + blur { + enabled=true + new_optimizations = true + size=3 # minimum 1 + passes=1 # minimum 1, more passes = more resource intensive. + ignore_opacity=false + } +} + +# See: https://wiki.hyprland.org/Configuring/Animations +animations { + enabled = yes + + # BEZIERS NAME X0 Y0 X1 Y1 + bezier = myBezier, 0.05, 0.9, 0.1, 1.05 + + # ANIMATION NAME ON SPEED CURVE STYLE + animation = windows, 1, 2, myBezier + animation = windowsOut, 1, 2, default, popin 80% + animation = border, 1, 5, default + animation = fadeIn, 1, 2, default + animation = fadeOut, 1, 2, default + animation = workspaces, 1, 6, default, fade + animation = specialWorkspace, 1, 3, myBezier, slide +} + + +# LAYOUT DETAILS +# ================================================ + +# See: https://wiki.hyprland.org/Configuring/Dwindle-Layout/ +dwindle { + pseudotile = yes + preserve_split = yes +} + +# See: https://wiki.hyprland.org/Configuring/Master-Layout +master { + new_on_top = true +} + +# See: https://wiki.hyprland.org/Configuring/Variables +gestures { + workspace_swipe = off } #-- Input ---------------------------------------------------- @@ -32,42 +130,8 @@ input { numlock_by_default=1 } -#-- Decoration ---------------------------------------------------- -# Decoration settings like Rounded Corners, Opacity, Blur, etc. -decoration { - rounding=8 # Original: rounding=-1 - - active_opacity=1.0 - inactive_opacity=0.9 - fullscreen_opacity=1.0 - - blur { - enabled=true - size=3 # minimum 1 - passes=1 # minimum 1, more passes = more resource intensive. - ignore_opacity=false - } - - # Your blur "amount" is blur_size * blur_passes, but high blur_size (over around 5-ish) will produce artifacts. - # if you want heavy blur, you need to up the blur_passes. - # the more passes, the more you can up the blur_size without noticing artifacts. -} - -#-- Animations ---------------------------------------------------- -animations { - enabled=1 - # animation=NAME,ONOFF,SPEED,CURVE,STYLE - animation=windows,1,8,default,popin 80% - animation=fadeOut,1,8,default - animation=fadeIn,1,8,default - animation=workspaces,1,8,default - #animation=workspaces,1,6,overshot -} - -#-- Dwindle ---------------------------------------------------- -dwindle { - pseudotile=0 # enable pseudotiling on dwindle -} - +# Monitors +# =================================================== +monitor = , preferred, auto, 1 diff --git a/home/linux/gui/hyprland/conf/configs/windowrules.conf b/home/linux/gui/hyprland/conf/configs/windowrules.conf index 3cc1d18d..9e7c779a 100644 --- a/home/linux/gui/hyprland/conf/configs/windowrules.conf +++ b/home/linux/gui/hyprland/conf/configs/windowrules.conf @@ -1,28 +1,66 @@ -#-- Window Rules ---------------------------------------------------- -windowrule=float, class:^(yad|nm-connection-editor|pavucontrolk)$ -windowrule=float, class:^(xfce-polkit|kvantummanager|qt5ct)$ -windowrule=float, class:^(feh|imv|Gpicview|Gimp|nomacs)$ -windowrule=float, class:^(VirtualBox Manager|qemu|Qemu-system-x86_64)$ -windowrule=float, class:^(xfce4-appfinder)$ +# You can discover a class with 'hyprctl clients' +# Check the syntax on: https://wiki.hyprland.org/Configuring/Window-Rules/ -# foot -windowrule=float, class:^(foot-float)$ -windowrule=float, class:^(foot-full)$ -windowrule=move 0 0, class:^(foot-full)$ -windowrule=size 100% 100%,class:^(foot-full)$ + +# WINDOW RULES +# ============================================================================ + +# Workspace RULE WINDOW +# Terminals +windowrulev2 = workspace 1, class:^(foot)$ +windowrulev2 = workspace 2, class:^(Alacritty)$ +# Work Chat / Meeting +windowrulev2 = workspace 3, class:^(zoom)$ +# Browsers +windowrulev2 = workspace 4, class:^(firefox)$ +windowrulev2 = workspace 5, class:^(google-chrome)$ +# Chat +windowrulev2 = workspace 6, class:^(QQ)$ +windowrulev2 = workspace 6, class:^(org.telegram.desktop)$ +# Music +# windowrulev2 = workspace 7, class:^(music)$ +# Mail / Calendahunar)$ +# Other +windowrulev2 = workspace 9, class:^(code)$ # VS Code +windowrulev2 = workspace 9, class:^(org.wireshark.Wireshark)$ + + +# Float RULE WINDOW +windowrulev2 = float, class:^(pulsemixer)$ +windowrulev2 = float, class:^(org.pulseaudio.pavucontrol)$ +windowrulev2 = float, class:^(nm-connection-editor)$ +windowrulev2 = float, class:^(feh|imv|Gpicview)$ +windowrulev2 = float, title:^(File Transfer*)$ +windowrulev2 = float, title:^(Firefox — Sharing Indicator)$ +windowrulev2 = float, class:^(firefox)$,title:^(library) +windowrulev2 = float, title:^(Save File)$ +windowrulev2 = float, class:^(blueman-manager)$ +windowrulev2 = float, class:^(thunderbird)$,title:^(.*Reminder) + +# HOT FIXES +# ============================================================================ + +# Steam +# Fix: Steam menus dissapearing on mouseover +windowrulev2 = stayfocused, title:^()$, class:^(steam)$ +windowrulev2 = minsize 1 1, title:^()$, class:^(steam)$ +# Fix: Steam starts in a broken position as float window +windowrulev2 = tile, class:^(steam)$ +windowrulev2 = fullscreen, class:^(steam)$ +# Games +# windowrulev2 = immediate, class:^(steam_app_xxx)$ # game 1 # flameshot -windowrule = move 0 0,class:(flameshot) -windowrule = pin,class:(flameshot) -windowrule = noborder,class:(flameshot) -windowrule = stayfocused,class:(flameshot) -windowrule = float,class:(flameshot) - +windowrulev2 = move 0 0, class:(flameshot) +windowrulev2 = pin, class:(flameshot) +windowrulev2 = noborder, class:(flameshot) +windowrulev2 = stayfocused, class:(flameshot) +windowrulev2 = float, class:(flameshot) # avoid transparency -windowrule = opaque,class:(flameshot) +windowrulev2 = opaque, class:(flameshot) # wlogout -windowrule=float,class:^(wlogout)$ -windowrule=move 0 0,class:^(wlogout)$ -windowrule=size 100% 100%,class:^(wlogout)$ -windowrule=animation slide,class:^(wlogout)$ +windowrulev2 = float, class:^(wlogout)$ +windowrulev2 = move 0 0, class:^(wlogout)$ +windowrulev2 = size 100% 100%, class:^(wlogout)$ +windowrulev2 = animation slide, class:^(wlogout)$ diff --git a/home/linux/gui/hyprland/conf/hypridle.conf b/home/linux/gui/hyprland/conf/hypridle.conf index 6229527d..9acbd57e 100644 --- a/home/linux/gui/hyprland/conf/hypridle.conf +++ b/home/linux/gui/hyprland/conf/hypridle.conf @@ -6,14 +6,32 @@ general { ignore_dbus_inhibit = false # whether to ignore dbus-sent idle-inhibit requests } +# turn off keyboard backlight, comment out this section if you dont have a keyboard backlight. +# listener { +# timeout = 180 # 3 minutes +# on-timeout = brightnessctl -sd rgb:kbd_backlight set 0 # turn off keyboard backlight. +# on-resume = brightnessctl -rd rgb:kbd_backlight # turn on keyboard backlight. +# } + listener { - timeout = 290 # 4 minutes and 50 seconds + timeout = 180 # 3min. + on-timeout = brightnessctl -s set 10 # set monitor backlight to minimum, avoid 0 on OLED monitor. + on-resume = brightnessctl -r # monitor backlight restore. +} + +listener { + timeout = 300 # 5 minutes on-timeout = pidof hyprlock || hyprlock # lock screen on-resume = hyprctl dispatch dpms on # monitor wake up } listener { - timeout = 300 # 5 minutes - on-timeout = hyprctl dispatch dpms off # screen off - on-resume = hyprctl dispatch dpms on # monitor wake up + timeout = 360 # 6 minutes + on-timeout = hyprctl dispatch dpms off # screen off + on-resume = hyprctl dispatch dpms on && brightnessctl -r # monitor wake up & screen on +} + +listener { + timeout = 600 # 10min + on-timeout = systemctl suspend # suspend pc } diff --git a/home/linux/gui/hyprland/values/packages.nix b/home/linux/gui/hyprland/values/packages.nix index 59ecf1eb..0fc5b368 100644 --- a/home/linux/gui/hyprland/values/packages.nix +++ b/home/linux/gui/hyprland/values/packages.nix @@ -8,6 +8,7 @@ swaybg # the wallpaper wl-clipboard # copying and pasting hyprpicker # color picker + brightnessctl hyprshot # screen shot wf-recorder # screen recording