diff options
| author | Miran Bastaja <miran.bastaja04@gmail.com> | 2023-12-29 13:47:11 +0100 |
|---|---|---|
| committer | Miran Bastaja <miran.bastaja04@gmail.com> | 2023-12-29 13:47:11 +0100 |
| commit | 37d064197f2d24a310e31b96214cf6bc599cebca (patch) | |
| tree | a23ee3981507936012e1bf82a902173c24cae663 /share/home | |
| parent | 1cc418b55e7318fa43e88e25f18ba57c74802bc4 (diff) | |
hyprdesktop: abstract away commands
Abstract away commands used in hyprdesktop config in order to make
swapping tools and utilites easier, and to make the code fit in 80
columns.
Diffstat (limited to 'share/home')
| -rw-r--r-- | share/home/hyprdesktop.nix | 142 |
1 files changed, 80 insertions, 62 deletions
diff --git a/share/home/hyprdesktop.nix b/share/home/hyprdesktop.nix index 0cd8083..13701d6 100644 --- a/share/home/hyprdesktop.nix +++ b/share/home/hyprdesktop.nix @@ -19,82 +19,100 @@ ./emacs ]; - wayland.windowManager.hyprland = { - enable = true; - extraConfig = '' - $mod = SUPER + wayland.windowManager.hyprland = + let + commands = { + audio = { + increase = "wpctl set-volume @DEFAULT_AUDIO_SINK@ --limit 1.0 5%+"; + decrease = "wpctl set-volume @DEFAULT_AUDIO_SINK@ --limit 1.0 5%-"; + toggle-mute = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; + }; + screenshot = ''grim -g "$(slurp)" -t png - | wl-copy --type image/png''; + cmd = { + run = "rofi -show run"; + drun = "rofi -show drun"; + }; + brightness = { + increase = "brightnessctl set +5%"; + decrease = "brightnessctl set 5%-"; + }; + terminal = "kitty"; + }; + in + { + enable = true; + extraConfig = '' + $mod = SUPER - bind = $mod SHIFT, Return, exec, kitty + bind = $mod SHIFT, Return, exec, ${commands.terminal} - general { - layout = master - } + general { + layout = master + } - misc { - force_hypr_chan = true - } + misc { + force_hypr_chan = true + } - master { - mfact = 0.5 - new_is_master = false - } + master { + mfact = 0.5 + new_is_master = false + } - # workspaces - # binds $mod + [shift +] {1..10} to [move to] workspace {1..10} - ${builtins.concatStringsSep "\n" (builtins.genList (x: - let ws = let c = (x + 1) / 10; in builtins.toString (x + 1 - (c * 10)); - in '' - bind = $mod, ${ws}, workspace, ${toString (x + 1)} - bind = $mod SHIFT, ${ws}, movetoworkspacesilent, ${toString (x + 1)} - '') 10)} + # workspaces + # binds $mod + [shift +] {1..10} to [move to] workspace {1..10} + ${builtins.concatStringsSep "\n" (builtins.genList (x: + let ws = let c = (x + 1) / 10; in builtins.toString (x + 1 - (c * 10)); + in '' + bind = $mod, ${ws}, workspace, ${toString (x + 1)} + bind = $mod SHIFT, ${ws}, movetoworkspacesilent, ${toString (x + 1)} + '') 10)} - bind = $mod SHIFT, C, killactive - bind = $mod SHIFT, F, togglefloating - bind = $mod SHIFT, Q, exit - bind = $mod, P, exec, rofi -show drun - bind = $mod SHIFT, P, exec, rofi -show run + bind = $mod SHIFT, C, killactive + bind = $mod SHIFT, F, togglefloating + bind = $mod SHIFT, Q, exit + bind = $mod, P, exec, ${commands.cmd.run} + bind = $mod SHIFT, P, exec, ${commands.cmd.drun} - bind = $mod, H, cyclenext, prev - bind = $mod, L, cyclenext - bind = $mod SHIFT, H, swapnext, prev - bind = $mod SHIFT, L, swapnext + bind = $mod, H, cyclenext, prev + bind = $mod, L, cyclenext + bind = $mod SHIFT, H, swapnext, prev + bind = $mod SHIFT, L, swapnext - # audio control - binde =, XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ --limit 1.0 5%+ - binde =, XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ --limit 1.0 5%- - bind =, XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle + # audio control + binde =, XF86AudioRaiseVolume, exec, ${commands.audio.increase} + binde =, XF86AudioLowerVolume, exec, ${commands.audio.decrease} + bind =, XF86AudioMute, exec, ${commands.audio.toggle-mute} - # monitor brightness control - binde =, XF86MonBrightnessUp, exec, brightnessctl set +5% - binde =, XF86MonBrightnessDown, exec, brightnessctl set 5%- + # monitor brightness control + binde =, XF86MonBrightnessUp, exec, ${commands.brightness.increase} + binde =, XF86MonBrightnessDown, exec, ${commands.brightness.decrease} - # Screenshotting - # My stupid laptop outputs these three key codes when the PrtSc key is - # pressed instead of using just one code like any sane device would - bind = SUPER SHIFT, S, exec, grim -g "$(slurp)" -t png - | wl-copy --type image/png + # Screenshotting + # My stupid laptop outputs these three key codes when the PrtSc key is + # pressed instead of using just one code like any sane device would + bind = SUPER SHIFT, S, exec, ${commands.screenshot} - input { - # focus change on cursor move - follow_mouse = 1 - accel_profile = flat - } - monitor=,preferred,auto,1 + input { + # focus change on cursor move + follow_mouse = 1 + accel_profile = flat + } + monitor=,preferred,auto,1 - # set opacity to 0.9 active and 0.5 inactive for kitty - windowrule = opacity 0.9 override 0.5 override,^(kitty)$ + # set opacity to 0.9 active and 0.5 inactive for kitty + windowrule = opacity 0.9 override 0.5 override,^(kitty)$ - # Move windows to their designated workspaces - # TODO: make popup windows stay on the workspace where they were created - # windowrulev2 = workspace 6,class:(org.qbittorrent.qBittorrent),floating:0 - windowrulev2 = workspace 3,class:(firefox) - windowrulev2 = workspace 4,class:(fluffychat) - windowrulev2 = workspace 4,class:(org.telegram.desktop) - windowrulev2 = workspace 4,class:(Signal) - windowrulev2 = workspace 5,class:(Bitwarden) + # Move windows to their designated workspaces + windowrulev2 = workspace 3,class:(firefox) + windowrulev2 = workspace 4,class:(fluffychat) + windowrulev2 = workspace 4,class:(org.telegram.desktop) + windowrulev2 = workspace 4,class:(Signal) + windowrulev2 = workspace 5,class:(Bitwarden) - exec-once = eww --config ${config.programs.eww.configDir} open bar - ''; - }; + exec-once = eww --config ${config.programs.eww.configDir} open bar + ''; + }; home.packages = with pkgs; [ xh # Nice to use HTTP client |
