1
1
Fork 0

hyprland: refactor binds and rules

Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
Myned 2024-09-11 18:16:44 -05:00
parent 29972bf2d8
commit 505e6dc583
Signed by: myned
GPG key ID: C7224454F7881A34
2 changed files with 341 additions and 413 deletions

View file

@ -5,27 +5,17 @@
pkgs, pkgs,
... ...
}: }:
with lib; let
with lib;
let
clipse = "${pkgs.clipse}/bin/clipse"; clipse = "${pkgs.clipse}/bin/clipse";
codium = "${ codium = "${config.home-manager.users.${config.custom.username}.programs.vscode.package}/bin/codium";
config.home-manager.users.${config.custom.username}.programs.vscode.package firefox-esr = "${config.home-manager.users.${config.custom.username}.programs.firefox.finalPackage}/bin/firefox-esr";
}/bin/codium";
firefox-esr = "${
config.home-manager.users.${config.custom.username}.programs.firefox.finalPackage
}/bin/firefox-esr";
gnome-text-editor = "${pkgs.gnome-text-editor}/bin/gnome-text-editor"; gnome-text-editor = "${pkgs.gnome-text-editor}/bin/gnome-text-editor";
hyprctl = "${pkgs.hyprland}/bin/hyprctl"; hyprctl = "${pkgs.hyprland}/bin/hyprctl";
hyprlock = "${ hyprlock = "${config.home-manager.users.${config.custom.username}.programs.hyprlock.package}/bin/hyprlock";
config.home-manager.users.${config.custom.username}.programs.hyprlock.package
}/bin/hyprlock";
hyprpicker = "${pkgs.hyprpicker}/bin/hyprpicker"; hyprpicker = "${pkgs.hyprpicker}/bin/hyprpicker";
jq = "${pkgs.jq}/bin/jq"; jq = "${pkgs.jq}/bin/jq";
kill = "${pkgs.procps}/bin/kill"; kill = "${pkgs.procps}/bin/kill";
kitty = "${config.home-manager.users.${config.custom.username}.programs.kitty.package}/bin/kitty"; kitty = "${config.home-manager.users.${config.custom.username}.programs.kitty.package}/bin/kitty";
libreoffice = "${config.custom.programs.libreoffice.package}/bin/libreoffice";
loginctl = "${pkgs.systemd}/bin/loginctl"; loginctl = "${pkgs.systemd}/bin/loginctl";
nautilus = "${pkgs.nautilus}/bin/nautilus"; nautilus = "${pkgs.nautilus}/bin/nautilus";
networkmanager_dmenu = "${pkgs.networkmanager_dmenu}/bin/networkmanager_dmenu"; networkmanager_dmenu = "${pkgs.networkmanager_dmenu}/bin/networkmanager_dmenu";
@ -35,6 +25,7 @@ let
playerctl = "${pkgs.playerctl}/bin/playerctl"; playerctl = "${pkgs.playerctl}/bin/playerctl";
rofi-rbw = "${pkgs.rofi-rbw}/bin/rofi-rbw"; rofi-rbw = "${pkgs.rofi-rbw}/bin/rofi-rbw";
sleep = "${pkgs.coreutils}/bin/sleep"; sleep = "${pkgs.coreutils}/bin/sleep";
steam = "${config.programs.steam.package}/bin/steam";
swayosd-client = "${pkgs.swayosd}/bin/swayosd-client"; swayosd-client = "${pkgs.swayosd}/bin/swayosd-client";
systemctl = "${pkgs.systemd}/bin/systemctl"; systemctl = "${pkgs.systemd}/bin/systemctl";
virt-manager = "${config.programs.virt-manager.package}/bin/virt-manager"; virt-manager = "${config.programs.virt-manager.package}/bin/virt-manager";
@ -42,214 +33,206 @@ let
wofi = "${config.home-manager.users.${config.custom.username}.programs.wofi.package}/bin/wofi"; wofi = "${config.home-manager.users.${config.custom.username}.programs.wofi.package}/bin/wofi";
cfg = config.custom.desktops.hyprland.binds; cfg = config.custom.desktops.hyprland.binds;
in in {
{ options.custom.desktops.hyprland.binds.enable = mkOption {default = false;};
options.custom.desktops.hyprland.binds.enable = mkOption { default = false; };
config.home-manager.users.${config.custom.username} = mkIf cfg.enable { config.home-manager.users.${config.custom.username} = mkIf cfg.enable {
wayland.windowManager.hyprland.settings = { wayland.windowManager.hyprland.settings = let
# Reverse mods and key for alphabetical sorting
#?? key <"KEY"> <"MODS"|null> <"DISPATCHER"> <"PARAMS"|null>
key = key: mods: dispatcher: params: "${
if (isNull mods)
then ""
else mods
}, ${key}, ${dispatcher}${
if (isNull params)
then ""
else ", ${params}"
}";
in {
# https://wiki.hyprland.org/Configuring/Binds # https://wiki.hyprland.org/Configuring/Binds
#?? bind = MODS, KEY, DISPATCHER, [PARAMS] #?? bind = MODS, KEY, DISPATCHER, [PARAMS]
#?? wev #?? wev
binds = {
allow_workspace_cycles = true;
disable_keybind_grabbing = true;
scroll_event_delay = 0;
};
# Lockscreen binds # Lockscreen binds
bindl = [ bindl = [
### System (key "Delete" "Ctrl" "exec" "${hyprctl} reload")
"CTRL, Delete, exec, ${hyprctl} reload" (key "Delete" "Ctrl+Alt" "exec" "${loginctl} terminate-session ''")
"CTRL+ALT, Delete, exec, ${loginctl} terminate-session ''" (key "Delete" "Super" "exec" "inhibit")
"SUPER, L, exec, ${hyprlock} --immediate & ${sleep} 1 && ${hyprctl} dispatch dpms off" (key "L" "Super" "exec" "${hyprlock} --immediate & ${sleep} 1 && ${hyprctl} dispatch dpms off")
# Laptop lid switches # Laptop lid switches
# https://wiki.hyprland.org/Configuring/Binds/#switches # https://wiki.hyprland.org/Configuring/Binds/#switches
#?? hyprctl devices #?? hyprctl devices
", switch:on:Lid Switch, dpms, off" # Close (key "switch:off:Lid Switch" null "dpms" "on") # Open
", switch:off:Lid Switch, dpms, on" # Open (key "switch:on:Lid Switch" null "dpms" "off") # Close
### Scripts
"SUPER, Delete, exec, inhibit"
]; ];
# Mouse binds # Mouse binds
bindm = [ bindm = [
"SUPER, mouse:272, movewindow" # LMB (key "mouse:272" "Super" "movewindow" null) # LMB
"SUPER, mouse:273, resizewindow" # RMB (key "mouse:273" "Super" "resizewindow" null) # RMB
]; ];
# Repeat binds # Repeat binds
binde = [ binde = [
# Media keys # Media keys
# https://github.com/xkbcommon/libxkbcommon/blob/master/include/xkbcommon/xkbcommon-keysyms.h # https://github.com/xkbcommon/libxkbcommon/blob/master/include/xkbcommon/xkbcommon-keysyms.h
", XF86AudioMute, exec, ${swayosd-client} --output-volume mute-toggle" (key "XF86AudioMute" null "exec" "${swayosd-client} --output-volume mute-toggle") # F1
", XF86AudioLowerVolume, exec, ${swayosd-client} --output-volume lower" (key "XF86AudioLowerVolume" null "exec" "${swayosd-client} --output-volume lower") # F2
", XF86AudioRaiseVolume, exec, ${swayosd-client} --output-volume raise" (key "XF86AudioRaiseVolume" null "exec" "${swayosd-client} --output-volume raise") # F3
", XF86AudioPlay, exec, ${playerctl} play-pause" (key "XF86AudioPrev" null "exec" "${playerctl} previous") # F4
", XF86AudioPrev, exec, ${playerctl} previous" (key "XF86AudioPlay" null "exec" "${playerctl} play-pause") # F5
", XF86AudioNext, exec, ${playerctl} next" (key "XF86AudioNext" null "exec" "${playerctl} next") # F6
", XF86MonBrightnessDown, exec, ${swayosd-client} --brightness lower" (key "XF86MonBrightnessDown" null "exec" "${swayosd-client} --brightness lower") # F7
", XF86MonBrightnessUp, exec, ${swayosd-client} --brightness raise" (key "XF86MonBrightnessUp" null "exec" "${swayosd-client} --brightness raise") # F8
(key "XF86AudioMedia" null "exec" "${notify-send} test") # F12
# TODO: Unused media key
#// ", XF86AudioMedia, exec, null"
]; ];
# Release binds # Release binds
bindr = [ bindr = [
### Layouts (key "Alt_L" "Super+Alt" "togglespecialworkspace" "wallpaper")
"SUPER+CTRL, Control_L, layoutmsg, swapwithmaster master" (key "Control_L" "Super+Ctrl" "layoutmsg" "swapwithmaster master")
"SUPER+SHIFT+CTRL, Control_L, layoutmsg, addmaster" (key "Control_L" "Super+Ctrl+Alt+Shift" "layoutmsg" "removemaster")
"SUPER+SHIFT+CTRL+ALT, Control_L, layoutmsg, removemaster" (key "Control_L" "Super+Ctrl+Shift" "layoutmsg" "addmaster")
(key "Shift_L" "Super+Shift" "workspace" "previous")
### Workspaces (key "Super_L" "Super" "exec" "${pkill} wofi || ${wofi} --show drun")
"SUPER+SHIFT, Shift_L, workspace, previous" (key "Super_L" "Super+Alt" "exec" "${pkill} wofi || ${rofi-rbw}")
(key "Super_L" "Super+Ctrl" "exec" "${pkill} wofi || calc")
# Special workspaces (key "Super_L" "Super+Ctrl+Shift" "exec" "${pkill} wofi || ${networkmanager_dmenu}")
"SUPER, Super_L, togglespecialworkspace, scratchpad" (key "Super_L" "Super+Shift" "exec" "${pkill} wofi || ${wofi} --show run")
"SUPER+SHIFT, Super_L, movetoworkspacesilent, special:scratchpad"
"SUPER+ALT, Alt_L, togglespecialworkspace, wallpaper"
]; ];
# Regular binds # Regular binds
bind = [ bind = [
### Scripts (key "mouse:274" "Super" "layoutmsg" "swapwithmaster master")
", Print, exec, screenshot" (key "mouse:274" "Super+Shift" "layoutmsg" "addmaster")
"SHIFT, Print, exec, screenshot -d" (key "mouse:274" "Super+Ctrl+Shift" "layoutmsg" "removemaster")
"SUPER, Print, exec, screenshot -e"
"SUPER+SHIFT, Print, exec, screenshot -ed"
"SUPER+SHIFT, Delete, exec, vrr"
"SUPER, Minus, exec, audio"
"SUPER, Equal, exec, audio Normalizer"
"SUPER+SHIFT, W, exec, vm -x ${if config.custom.hidpi then "/scale:140 +f" else ""}"
"SUPER+SHIFT+CTRL, W, exec, vm ${virt-manager} --connect qemu:///system --show-domain-console myndows"
"SUPER+SHIFT+CTRL, Q, exec, close" # Quit all windows
# BUG: Freezes window when toggled (key "Backslash" "Super" "layoutmsg" "orientationcenter")
# https://github.com/hyprwm/Hyprland/issues/7609 (key "Backslash" "Super+Shift" "splitratio" "exact 0.5") # Reset layout ratio
"CTRL, Space, exec, toggle dropdown special:dropdown ${kitty} --app-id dropdown --override font_size=12" (key "Backspace" "Super" "changegroupactive" "f")
(key "Backspace" "Super+Ctrl" "togglegroup" null)
"CTRL+SHIFT, Space, exec, toggle pip special:pip" (key "Backspace" "Super+Ctrl+Shift" "lockactivegroup" "toggle")
(key "Backspace" "Super+Shift" "changegroupactive" "b")
(key "Bracketleft" "Super" "layoutmsg" "orientationprev")
(key "Bracketleft" "Super+Shift" "splitratio" "-0.1")
(key "Bracketright" "Super" "layoutmsg" "orientationnext")
(key "Bracketright" "Super+Shift" "splitratio" "+0.1")
# TODO: Toggle trackball hand # TODO: Toggle trackball hand
#// "SUPER, Delete, exec, left" #// (key "Delete" "Super" "exec" "left")
### Applications (key "Delete" "Super+Shift" "exec" "vrr")
"SUPER, B, exec, [tag +browser] ${firefox-esr}" (key "Down" "Super" "movewindoworgroup" "d")
"SUPER, C, exec, ${codium}" (key "Equal" "Super" "exec" "audio Normalizer")
"SUPER, E, exec, ${gnome-text-editor}" (key "Escape" "Super" "togglefloating" null)
"SUPER, F, exec, ${nautilus}" (key "Escape" "Super+Alt" "exec" "lifx state --color red")
"SUPER, K, exec, ${obsidian}" (key "Escape" "Super+Shift" "centerwindow" null)
"SUPER, O, exec, ${libreoffice}" (key "Left" "Super" "movewindoworgroup" "l")
"SUPER, P, exec, ${hyprpicker} --autocopy" (key "Minus" "Super" "exec" "audio")
"SUPER+SHIFT, P, exec, ${hyprpicker} --autocopy --format rgb" (key "Print" "Shift" "exec" "screenshot -d")
"SUPER+CTRL, T, exec, ${kitty}" (key "Print" "Super" "exec" "screenshot -e")
"SUPER+SHIFT+CTRL, T, exec, ${pkill} kitty" (key "Print" "Super+Shift" "exec" "screenshot -ed")
"SUPER, V, exec, ${kitty} --app-id clipboard --override font_size=12 ${clipse}" (key "Print" null "exec" "screenshot")
"SUPER+SHIFT, V, exec, ${clipse} -clear && ${notify-send} clipse 'Clipboard cleared' --urgency low" (key "Return" "Super" "fullscreen" "1") # Maximize
"SUPER, Space, exec, ${pkill} wofi || ${wofi} --show drun" (key "Return" "Super+Shift" "fullscreen" "0") # Fullscreen
"SUPER+SHIFT, Space, exec, ${pkill} wofi || ${wofi} --show run" (key "Right" "Super" "movewindoworgroup" "r")
"SUPER+CTRL, Space, exec, ${pkill} wofi || calc" (key "Space" "Ctrl" "exec" (concatStringsSep " " [
"SUPER+ALT, Space, exec, ${pkill} wofi || ${rofi-rbw}" "toggle"
"SUPER+SHIFT+CTRL, Space, exec, ${pkill} wofi || ${networkmanager_dmenu}" "--focus"
"--type class"
"--expression '^dropdown$'"
"--workspace special:dropdown"
"--"
"${kitty} --app-id dropdown --override font_size=12"
]))
(key "Space" "Ctrl+Alt" "exec" "lifx toggle")
(key "Space" "Ctrl+Shift" "exec" (concatStringsSep " " [
"toggle"
"--type title"
"--expression '^Picture.in.[Pp]icture$'"
"--workspace special:pip"
]))
(key "Space" "Super" "togglespecialworkspace" "scratchpad")
(key "Space" "Super+Ctrl" "movetoworkspacesilent" "special:scratchpad")
(key "Tab" "Super" "cyclenext" "tiled")
(key "Tab" "Super+Shift" "alterzorder" "top")
(key "Tab" "Super+Shift" "cyclenext" "floating")
(key "Up" "Super" "movewindoworgroup" "u")
# Kill applications (key "0" "Super" "workspace" "10")
"SUPER, Q, killactive" (key "0" "Super+Ctrl" "movetoworkspacesilent" "10")
"SUPER+SHIFT, Q, exec, ${kill} -9 $(${hyprctl} -j activewindow | ${jq} .pid)" (key "1" "Ctrl+Alt" "exec" "lifx state --brightness 0.01")
"SUPER+SHIFT, A, exec, ${waydroid} session stop" (key "1" "Super" "workspace" "1")
"SUPER+SHIFT, S, exec, ${pkill} steam" (key "1" "Super+Alt" "exec" "lifx state --kelvin 1500")
"SUPER+SHIFT+CTRL, G, exec, ${pkill} gamescope" (key "1" "Super+Ctrl" "movetoworkspacesilent" "1")
(key "2" "Ctrl+Alt" "exec" "lifx state --brightness 0.25")
# LIFX (key "2" "Super" "workspace" "2")
"SUPER+ALT, Escape, exec, lifx state --color red" (key "2" "Super+Alt" "exec" "lifx state --kelvin 2500")
"SUPER+ALT, 1, exec, lifx state --kelvin 1500" (key "2" "Super+Ctrl" "movetoworkspacesilent" "2")
"SUPER+ALT, 2, exec, lifx state --kelvin 2500" (key "3" "Ctrl+Alt" "exec" "lifx state --brightness 0.50")
"SUPER+ALT, 3, exec, lifx state --kelvin 3000" (key "3" "Super" "workspace" "3")
"SUPER+ALT, 4, exec, lifx state --kelvin 4000" (key "3" "Super+Alt" "exec" "lifx state --kelvin 3000")
"SUPER+ALT, 5, exec, lifx state --kelvin 5000" (key "3" "Super+Ctrl" "movetoworkspacesilent" "3")
"CTRL+ALT, 1, exec, lifx state --brightness 0.01" (key "4" "Ctrl+Alt" "exec" "lifx state --brightness 0.75")
"CTRL+ALT, 2, exec, lifx state --brightness 0.25" (key "4" "Super" "workspace" "4")
"CTRL+ALT, 3, exec, lifx state --brightness 0.50" (key "4" "Super+Alt" "exec" "lifx state --kelvin 4000")
"CTRL+ALT, 4, exec, lifx state --brightness 0.75" (key "4" "Super+Ctrl" "movetoworkspacesilent" "4")
"CTRL+ALT, 5, exec, lifx state --brightness 1.00" (key "5" "Ctrl+Alt" "exec" "lifx state --brightness 1.00")
"CTRL+ALT, Space, exec, lifx toggle" (key "5" "Super" "workspace" "5")
(key "5" "Super+Alt" "exec" "lifx state --kelvin 5000")
### Windows (key "5" "Super+Ctrl" "movetoworkspacesilent" "5")
"SUPER, Escape, togglefloating" (key "6" "Super" "workspace" "6")
"SUPER+SHIFT, Escape, centerwindow" (key "6" "Super+Ctrl" "movetoworkspacesilent" "6")
"SUPER, Return, fullscreen, 1" # Maximize (key "7" "Super" "workspace" "7")
"SUPER+SHIFT, Return, fullscreen, 0" # Fullscreen (key "7" "Super+Ctrl" "movetoworkspacesilent" "7")
"SUPER, Tab, cyclenext, tiled" (key "8" "Super" "workspace" "8")
(key "8" "Super+Ctrl" "movetoworkspacesilent" "8")
# FIXME: Handle hover focus and zorder (key "9" "Super" "workspace" "9")
"SUPER+SHIFT, Tab, cyclenext, floating" (key "9" "Super+Ctrl" "movetoworkspacesilent" "9")
"SUPER+SHIFT, Tab, alterzorder, top" (key "A" "Ctrl+Alt" "exec" "${waydroid} session stop")
(key "A" "Super" "togglespecialworkspace" "android")
### Groups (key "A" "Super+Ctrl" "movetoworkspacesilent" "android")
"SUPER, Backspace, changegroupactive, f" (key "B" "Super" "exec" "[group new lock; tile] ${firefox-esr}")
"SUPER+SHIFT, Backspace, changegroupactive, b" (key "C" "Super" "exec" codium)
"SUPER+CTRL, Backspace, togglegroup" (key "E" "Super" "exec" gnome-text-editor)
"SUPER+SHIFT+CTRL, Backspace, lockactivegroup, toggle" (key "F" "Super" "exec" nautilus)
"SUPER, Up, movewindoworgroup, u" (key "G" "Super" "workspace" "name:game")
"SUPER, Down, movewindoworgroup, d" (key "G" "Super+Alt" "workspace" "name:gamescope")
"SUPER, Left, movewindoworgroup, l" (key "G" "Super+Ctrl" "movetoworkspacesilent" "name:game")
"SUPER, Right, movewindoworgroup, r" (key "G" "Super+Ctrl+Alt" "exec" "${pkill} gamescope")
(key "K" "Super" "exec" obsidian)
### Layouts (key "M" "Super" "togglespecialworkspace" "music")
"SUPER, mouse:274, layoutmsg, swapwithmaster master" (key "M" "Super+Ctrl" "movetoworkspacesilent" "music")
"SUPER+SHIFT, mouse:274, layoutmsg, addmaster" (key "O" "Super" "togglespecialworkspace" "office")
"SUPER+SHIFT+CTRL, mouse:274, layoutmsg, removemaster" (key "P" "Super" "exec" "${hyprpicker} --autocopy")
"SUPER, Bracketleft, layoutmsg, orientationprev" (key "P" "Super+Shift" "exec" "${hyprpicker} --autocopy --format rgb")
"SUPER, Bracketright, layoutmsg, orientationnext" (key "Q" "Ctrl+Alt" "exec" "${kill} -9 $(${hyprctl} -j activewindow | ${jq} .pid)")
"SUPER, Backslash, layoutmsg, orientationcenter" (key "Q" "Ctrl+Alt+Shift" "exec" "close") # Quit all windows
"SUPER+SHIFT, Backslash, splitratio, exact 0.5" # Reset layout ratio (key "Q" "Super" "killactive" null)
"SUPER+SHIFT, Bracketleft, splitratio, -0.1" (key "S" "Ctrl+Alt" "exec" "${pkill} steam")
"SUPER+SHIFT, Bracketright, splitratio, +0.1" (key "S" "Super" "togglespecialworkspace" "steam")
(key "S" "Super+Ctrl" "movetoworkspacesilent" "steam")
### Workspaces (key "S" "Super+Shift" "exec" steam)
"SUPER, 1, workspace, 1" (key "T" "Ctrl+Alt" "exec" "${pkill} kitty")
"SUPER+SHIFT, 1, movetoworkspacesilent, 1" (key "T" "Super" "togglespecialworkspace" "terminal")
"SUPER, 2, workspace, 2" (key "T" "Super+Ctrl" "movetoworkspacesilent" "terminal")
"SUPER+SHIFT, 2, movetoworkspacesilent, 2" (key "T" "Super+Shift" "exec" kitty)
"SUPER, 3, workspace, 3" (key "V" "Super" "exec" "${kitty} --app-id clipboard --override font_size=12 ${clipse}")
"SUPER+SHIFT, 3, movetoworkspacesilent, 3" (key "V" "Super+Shift" "exec" "${clipse} -clear && ${notify-send} clipse 'Clipboard cleared' --urgency low")
"SUPER, 4, workspace, 4" (key "W" "Super" "togglespecialworkspace" "vm")
"SUPER+SHIFT, 4, movetoworkspacesilent, 4" (key "W" "Super+Shift" "exec" "vm -x ${
"SUPER, 5, workspace, 5" if config.custom.hidpi
"SUPER+SHIFT, 5, movetoworkspacesilent, 5" then "/scale:140 +f"
"SUPER, 6, workspace, 6" else ""
"SUPER+SHIFT, 6, movetoworkspacesilent, 6" }")
"SUPER, 7, workspace, 7" (key "W" "Super+Ctrl" "movetoworkspacesilent" "vm")
"SUPER+SHIFT, 7, movetoworkspacesilent, 7" (key "W" "Super+Ctrl+Shift" "exec" "vm ${virt-manager} --show-domain-console myndows")
"SUPER, 8, workspace, 8" (key "X" "Super" "workspace" "+1")
"SUPER+SHIFT, 8, movetoworkspacesilent, 8" (key "X" "Super+Ctrl" "movetoworkspacesilent" "+1")
"SUPER, 9, workspace, 9" (key "Z" "Super" "workspace" "-1")
"SUPER+SHIFT, 9, movetoworkspacesilent, 9" (key "Z" "Super+Ctrl" "movetoworkspacesilent" "-1")
"SUPER, 0, workspace, 10"
"SUPER+SHIFT, 0, movetoworkspacesilent, 10"
"SUPER, Z, workspace, -1"
"SUPER+SHIFT, Z, movetoworkspacesilent, -1"
"SUPER, X, workspace, +1"
"SUPER+SHIFT, X, movetoworkspacesilent, +1"
# Named workspaces
"SUPER, G, workspace, name:game"
"SUPER+SHIFT, G, movetoworkspacesilent, name:game"
"SUPER+CTRL, G, workspace, name:gamescope"
# Special workspaces
"SUPER, A, togglespecialworkspace, android"
"SUPER+SHIFT, A, movetoworkspacesilent, android"
"SUPER, M, togglespecialworkspace, music"
"SUPER+SHIFT, M, movetoworkspacesilent, music"
"SUPER, S, togglespecialworkspace, steam"
"SUPER+SHIFT, S, movetoworkspacesilent, steam"
"SUPER, T, togglespecialworkspace, terminal"
"SUPER+SHIFT, T, movetoworkspacesilent, terminal"
"SUPER, W, togglespecialworkspace, vm"
"SUPER+SHIFT, W, movetoworkspacesilent, vm"
]; ];
}; };
}; };

View file

@ -4,22 +4,20 @@
pkgs, pkgs,
... ...
}: }:
with lib; let
with lib;
let
gamescope = "${config.programs.gamescope.package}/bin/gamescope"; gamescope = "${config.programs.gamescope.package}/bin/gamescope";
kitty = "${config.home-manager.users.${config.custom.username}.programs.kitty.package}/bin/kitty";
libreoffice = "${config.custom.programs.libreoffice.package}/bin/libreoffice";
loupe = "${pkgs.loupe}/bin/loupe"; loupe = "${pkgs.loupe}/bin/loupe";
pgrep = "${pkgs.procps}/bin/pgrep";
steam = "${config.programs.steam.package}/bin/steam"; steam = "${config.programs.steam.package}/bin/steam";
virt-manager = "${pkgs.virt-manager}/bin/virt-manager"; virt-manager = "${pkgs.virt-manager}/bin/virt-manager";
waydroid = "${pkgs.waydroid}/bin/waydroid"; waydroid = "${pkgs.waydroid}/bin/waydroid";
kitty = "${config.home-manager.users.${config.custom.username}.programs.kitty.package}/bin/kitty";
youtube-music = "${pkgs.youtube-music}/bin/youtube-music"; youtube-music = "${pkgs.youtube-music}/bin/youtube-music";
cfg = config.custom.desktops.hyprland.rules; cfg = config.custom.desktops.hyprland.rules;
in in {
{ options.custom.desktops.hyprland.rules.enable = mkOption {default = false;};
options.custom.desktops.hyprland.rules.enable = mkOption { default = false; };
config.home-manager.users.${config.custom.username} = mkIf cfg.enable { config.home-manager.users.${config.custom.username} = mkIf cfg.enable {
wayland.windowManager.hyprland.settings = { wayland.windowManager.hyprland.settings = {
@ -30,246 +28,193 @@ in
"special:android, on-created-empty:${waydroid} app launch com.YoStarEN.Arknights" "special:android, on-created-empty:${waydroid} app launch com.YoStarEN.Arknights"
"special:music, on-created-empty:${youtube-music}" "special:music, on-created-empty:${youtube-music}"
"special:office, on-created-empty:${libreoffice}"
"special:steam, on-created-empty:${steam}" "special:steam, on-created-empty:${steam}"
"special:terminal, on-created-empty:${kitty}" "special:terminal, on-created-empty:${kitty}"
"special:vm, on-created-empty:${pgrep} -x vm || ${virt-manager}"
"special:wallpaper, on-created-empty:[tile] ${loupe} /tmp/wallpaper.png" "special:wallpaper, on-created-empty:[tile] ${loupe} /tmp/wallpaper.png"
]; ];
# https://wiki.hyprland.org/Configuring/Window-Rules # https://wiki.hyprland.org/Configuring/Window-Rules
#?? windowrulev2 = RULE, WINDOW #?? windowrulev2 = RULE, WINDOW
windowrulev2 = windowrulev2 = with config.custom; let
with config.custom; ### Hardware-dependent rules
let # Convert truncated float to string
# Return hypr-formatted string, converting booleans into 0/1 tr = num: toString (builtins.floor num);
format =
field: expr:
"${field}:${
toString (
if expr == true then
1
else if expr == false then
0
else
expr
)
}";
# Generate hypr-formatted window rules # Bottom center
#?? merge <FIELD|{FIELDS}> <EXPRESSION> <RULES> clipboard = rec {
merge = x = tr (width / scale / 2 - (toInt w) / 2);
field: expr: rules: y = tr (height / scale - (toInt h) - gap - border - padding);
map ( w = "600";
rule: h = tr (height / scale * 0.5 * scale);
if builtins.isAttrs field then };
"${rule}, ${lib.concatStringsSep ", " (lib.mapAttrsToList (f: e: format f e) field)}"
else
"${rule}, ${format field expr}"
) rules;
class = expr: rules: merge "class" "^${expr}$" rules; # Bottom center
floating = expr: rules: merge "floating" expr rules; dropdown = rec {
fullscreen = expr: rules: merge "fullscreen" expr rules; x = tr (width / scale / 2 - (toInt w) / 2);
pinned = expr: rules: merge "pinned" expr rules; y = tr (height / scale - (toInt h) - gap - border - padding);
tag = expr: rules: merge "tag" expr rules; w = tr (width
title = expr: rules: merge "title" "^${expr}$" rules; / scale
* (
if ultrawide
then 0.5
else 1
)
- gap
- gap / 2
+ 1);
h = tr (height / scale * 0.2 * scale);
};
fields = fields: rules: merge fields null rules; # Top right
pip = rec {
x = tr (width / scale - (toInt w) - gap - border);
y = tr (gap + border);
w = tr (width / scale * 0.25 - gap - gap + 1);
h = tr ((toInt w) * 9 / 16); # 16:9 aspect ratio
};
### Hardware-dependent rules ### Rules
# Convert truncated float to string # Return hypr-formatted string, converting booleans into 0/1
tr = num: toString (builtins.floor num); format = field: expr: "${field}:${
toString (
if expr == true
then 1
else if expr == false
then 0
else expr
)
}";
# Bottom center # Generate hypr-formatted window rules
clipboard = rec { #?? merge <FIELD|{FIELDS}> <EXPRESSION> <RULES>
x = tr (width / scale / 2 - (toInt w) / 2); merge = field: expr: rules:
y = tr (height / scale - (toInt h) - gap - border - padding); map (
w = "600"; rule:
h = tr (height / scale * 0.5 * scale); if builtins.isAttrs field
}; then "${rule}, ${lib.concatStringsSep ", " (lib.mapAttrsToList (f: e: format f e) field)}"
else "${rule}, ${format field expr}"
)
rules;
# Bottom center class = expr: rules: merge "class" "^${expr}$" rules;
dropdown = rec { floating = expr: rules: merge "floating" expr rules;
x = tr (width / scale / 2 - (toInt w) / 2); fullscreen = expr: rules: merge "fullscreen" expr rules;
y = tr (height / scale - (toInt h) - gap - border - padding); pinned = expr: rules: merge "pinned" expr rules;
w = tr (width / scale * (if ultrawide then 0.5 else 1) - gap - gap / 2 + 1); title = expr: rules: merge "title" "^${expr}$" rules;
h = tr (height / scale * 0.2 * scale);
};
# Top right fields = fields: rules: merge fields null rules;
pip = rec {
x = tr (width / scale - (toInt w) - gap - border); ### Pseudo-tags
y = tr (gap + border); # Wrap generated rules in Nix categories
w = tr (width / scale * 0.25 - gap - gap + 1); tag = {
h = tr ((toInt w) * 9 / 16); # 16:9 aspect ratio android = rules: [
}; (class "waydroid.*" rules)
in ];
clipboard = rules: [
(class "clipboard" rules)
];
dropdown = rules: [
(class "dropdown" rules)
];
editor = rules: [
(class "codium-url-handler" rules) # VSCode
(class "obsidian" (rules ++ ["group barred"]))
];
files = rules: [
(class "org\\.gnome\\.Nautilus" rules)
];
game = rules: [
(class "moe\\.launcher\\.the-honkers-railway-launcher" (rules ++ ["size 1280 730"])) # Honkai: Star Rail
(class "steam_app_.+" rules) # Proton
];
music = rules: [
(class "Spotify" rules)
(class "YouTube Music" rules)
(title "Spotify Premium" rules)
];
office = rules: [
(class "libreoffice.+" rules)
];
pip = rules: [
(title "Picture.in.[Pp]icture" rules)
];
social = rules: [
(class "cinny" rules)
(class "discord" rules)
(class "Element" rules)
(class "org\\.telegram\\.desktop" rules)
];
steam = rules: [
(class "SDL Application" rules) # Steam
(class "steam" rules)
];
terminal = rules: [
(class "foot" rules)
(class "kitty" rules)
(class "org\\.wezfurlong\\.wezterm" rules)
];
vm = rules: [
(class "(sdl-|wl|x)freerdp" (rules ++ ["nomaxsize" "tile"]))
(class "virt-manager" rules)
];
wine = rules: [
(class ".*\\.(exe|x86_64)" rules) # Wine
];
};
in
flatten [ flatten [
### Defaults ### Defaults
(class ".*" [ (class ".*" ["float" "suppressevent maximize" "syncfullscreen"])
"center" (floating true ["bordercolor rgb(073642)"])
"float" (fullscreen true ["idleinhibit focus"])
"suppressevent maximize" (pinned true ["bordercolor rgb(073642) rgb(073642)"])
"syncfullscreen"
])
(floating true [
"bordercolor rgb(073642)"
"workspace special:scratchpad"
])
(fullscreen true [ "idleinhibit focus" ])
(pinned true [ "bordercolor rgb(073642) rgb(073642)" ])
# TODO: Convert to nix variables instead of tags (tag.android ["tile" "workspace special:android"])
### Tags (tag.clipboard ["move ${clipboard.x} ${clipboard.y}" "pin" "size ${clipboard.w} ${clipboard.h}" "stayfocused"])
(tag "android" [ (tag.dropdown ["move ${dropdown.x} ${dropdown.y}" "pin" "size ${dropdown.w} ${dropdown.h}"])
"tile" (tag.editor ["group invade" "tile"])
"workspace special:android" (tag.files ["size 1000 625"])
]) (tag.game ["group barred" "idleinhibit always" "noborder" "noshadow" "renderunfocused" "workspace name:game"])
(tag "browser" [ (tag.music ["tile" "workspace special:music"])
"group new lock" (tag.office ["tile" "workspace special:office"])
"tile" (tag.pip ["keepaspectratio" "move ${pip.x} ${pip.y}" "pin" "size ${pip.w} ${pip.h}"])
"workspace unset" (tag.social ["group" "tile"])
]) (tag.steam ["workspace special:steam"])
(tag "clipboard" [ (tag.terminal ["tile"])
"move ${clipboard.x} ${clipboard.y}" (tag.vm ["workspace special:vm"])
"pin" (tag.wine ["noborder" "noshadow"])
"size ${clipboard.w} ${clipboard.h}"
"stayfocused"
])
(tag "dropdown" [
"move ${dropdown.x} ${dropdown.y}"
"pin"
"size ${dropdown.w} ${dropdown.h}"
"workspace special:dropdown"
])
(tag "editor" [
"group invade"
"tile"
"workspace unset"
])
(tag "files" [
"size 1000 625"
])
(tag "game" [
"group barred"
"idleinhibit always"
"noborder"
"noshadow"
"renderunfocused"
"workspace name:game"
])
(tag "music" [
"tile"
"workspace special:music"
])
(tag "pip" [
"keepaspectratio"
"move ${pip.x} ${pip.y}"
"pin"
"size ${pip.w} ${pip.h}"
])
(tag "social" [
"group"
"tile"
"workspace unset"
])
(tag "steam" [ "workspace special:steam" ])
(tag "terminal" [
"tile"
"workspace unset"
])
(tag "vm" [ "workspace special:vm" ])
(tag "wine" [
"noborder"
"noshadow"
])
### Applications
(class ".*\\.(exe|x86_64)" [ "tag +wine" ]) # Wine
(class "(sdl-|wl|x)freerdp" [
"nomaxsize"
"tag +vm"
"tile"
])
(class "cinny" [ "tag +social" ])
(class "clipboard" [ "tag +clipboard" ])
(class "codium-url-handler" [ "tag +editor" ]) # VSCode
(class "discord" [ "tag +social" ])
(class "dropdown" [ "tag +dropdown" ])
(class "Element" [ "tag +social" ])
(class "foot" [ "tag +terminal" ])
(class "kitty" [ "tag +terminal" ])
(class "libreoffice.+" [
"tile"
"workspace unset"
])
(class "moe\\.launcher\\.the-honkers-railway-launcher" [
"size 1280 730"
"tag +game"
])
(class "obsidian" [
"group barred"
"tag +editor"
])
(class "org\\.gnome\\.Nautilus" [ "tag +files" ])
(class "org\\.telegram\\.desktop" [ "tag +social" ])
(class "org\\.wezfurlong\\.wezterm" [ "tag +terminal" ])
(class "SDL Application" [ "tag +steam" ]) # Steam
(class "Spotify" [ "tag +music" ])
(class "steam_app_1473350" [ "workspace 0" ]) # (the) Gnorp Apologue
(class "steam" [ "tag +steam" ])
(class "steam_app_.+" [ "tag +game" ]) # Proton
(class "Tap Wizard 2.x86_64" [ "workspace 0" ])
(class "virt-manager" [ "tag +vm" ])
(class "waydroid.*" [ "tag +android" ])
(class "YouTube Music" [ "tag +music" ])
(title "Picture.in.[Pp]icture" [ "tag +pip" ])
(title "Spotify Premium" [ "tag +music" ])
### Overrides ### Overrides
#!! Expressions are not wrapped in ^$ (class "steam_app_1473350" ["workspace 0"]) # (the) Gnorp Apologue
(fields (class "Tap Wizard 2.x86_64" ["workspace 0"])
{
class = "^lutris$";
title = "^Lutris$";
}
[
"center"
"size 1000 500"
]
)
(fields {
tag = "steam";
title = "^notificationtoasts$";
} [ "workspace unset" ])
(fields {
tag = "steam";
title = "^Steam$";
} [ "tile" ])
(fields #!! Expressions are not wrapped in ^$
{ (fields {
class = "^com\\.github\\.wwmm\\.easyeffects$"; class = "^com\\.github\\.wwmm\\.easyeffects$";
title = "^Easy Effects$"; title = "^Easy Effects$"; # Main window
} } ["size 50% 50%"])
[ (fields {
"size 50% 50%" class = "^discord$";
] title = "^Discord Updater$"; # Update dialog
) } ["float" "nofocus"])
(fields (fields {
{ class = "^lutris$";
class = "^discord$"; title = "^Lutris$"; # Main window
title = "^Discord Updater$"; } ["center" "size 1000 500"])
} (fields {
[ class = "^steam$";
"float" title = "^notificationtoasts$"; # Steam notifications
"nofocus" } [])
] (fields {
) class = "^steam$";
title = "^Steam$"; # Main window
} ["tile"])
(fields { (fields {
class = "^virt-manager$"; class = "^virt-manager$";
title = "^.+on QEMU/KVM$"; title = "^.+on QEMU/KVM$"; # VM window
} [ "tile" ]) } ["tile"])
]; ];
}; };
}; };