From 8c12edfdb9a34a7abf028594c69ecab815bec2de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Sun, 3 Mar 2024 15:03:04 +0100 Subject: [PATCH] feat(sway): add preliminary configuration --- configs/i3.nix | 347 +++++++++++++++++++++++++++---------------------- 1 file changed, 190 insertions(+), 157 deletions(-) diff --git a/configs/i3.nix b/configs/i3.nix index 3b03053f..e1ac1447 100644 --- a/configs/i3.nix +++ b/configs/i3.nix @@ -58,13 +58,6 @@ ''; }; }; - - new-workspace = pkgs.writers.writeDash "new-workspace" '' - i3-msg workspace $(($(i3-msg -t get_workspaces | tr , '\n' | grep '"num":' | cut -d : -f 2 | sort -rn | head -1) + 1)) - ''; - move-to-new-workspace = pkgs.writers.writeDash "new-workspace" '' - i3-msg move container to workspace $(($(i3-msg -t get_workspaces | tr , '\n' | grep '"num":' | cut -d : -f 2 | sort -rn | head -1) + 1)) - ''; in { age.secrets = { github-token-i3status-rust = { @@ -106,169 +99,209 @@ in { ''; }; - home-manager.users.me.xsession.windowManager.i3 = let + home-manager.users.me = let modifier = "Mod4"; - in { - enable = true; - extraConfig = '' - bindsym --release ${modifier}+Shift+w exec /run/wrappers/bin/slock - ''; - config = rec { - inherit modifier; - window = { - titlebar = false; - border = 2; - hideEdgeBorders = "smart"; - commands = [ - { - criteria = {class = "floating";}; - command = "floating enable"; - } - { - criteria = {class = "fzfmenu";}; - command = "floating enable"; - } - { - criteria = {class = ".*";}; - command = "border pixel 2"; - } - { - criteria = {class = "mpv";}; - command = lib.strings.concatStringsSep ", " [ - "floating enable" - "sticky enable" - "fullscreen disable" - "resize set 640 480" - "move position mouse" - ]; - } - ]; - }; - gaps.inner = 4; - floating = { - titlebar = false; - border = 1; - }; - bars = [ - (config.home-manager.users.me.lib.stylix.i3.bar - // rec { - workspaceButtons = false; - mode = "dock"; # "hide"; - position = "bottom"; - statusCommand = toString (pkgs.writers.writeDash "i3status-rust" '' - export I3RS_GITHUB_TOKEN="$(cat ${config.age.secrets.github-token-i3status-rust.path})" - export OPENWEATHERMAP_API_KEY="$(cat ${config.age.secrets.openweathermap-api-key.path})" - ${config.home-manager.users.me.programs.i3status-rust.package}/bin/i3status-rs ${config.home-manager.users.me.home.homeDirectory}/.config/i3status-rust/config-${position}.toml - ''); - fonts = { - names = ["${config.stylix.fonts.sansSerif.name}" "FontAwesome 6 Free"]; - size = config.stylix.fonts.sizes.desktop * 0.8; - }; - }) + modes.resize = { + "Escape" = ''mode "default"''; + "Return" = ''mode "default"''; + "h" = "resize shrink width 10 px or 5 ppt"; + "j" = "resize grow height 10 px or 5 ppt"; + "k" = "resize shrink height 10 px or 5 ppt"; + "l" = "resize grow width 10 px or 5 ppt"; + }; + gaps.inner = 4; + floating = { + titlebar = false; + border = 1; + }; + bars = [ + (config.home-manager.users.me.lib.stylix.i3.bar + // rec { + workspaceButtons = false; + mode = "dock"; # "hide"; + position = "bottom"; + statusCommand = toString (pkgs.writers.writeDash "i3status-rust" '' + export I3RS_GITHUB_TOKEN="$(cat ${config.age.secrets.github-token-i3status-rust.path})" + export OPENWEATHERMAP_API_KEY="$(cat ${config.age.secrets.openweathermap-api-key.path})" + ${config.home-manager.users.me.programs.i3status-rust.package}/bin/i3status-rs ${config.home-manager.users.me.home.homeDirectory}/.config/i3status-rust/config-${position}.toml + ''); + fonts = { + names = ["${config.stylix.fonts.sansSerif.name}" "FontAwesome 6 Free"]; + size = config.stylix.fonts.sizes.desktop * 0.8; + }; + }) + ]; + window = { + titlebar = false; + border = 2; + hideEdgeBorders = "smart"; + commands = [ + { + criteria = {class = "floating";}; + command = "floating enable"; + } + { + criteria = {class = "fzfmenu";}; + command = "floating enable"; + } + { + criteria = {class = ".*";}; + command = "border pixel 2"; + } + { + criteria = {class = "mpv";}; + command = lib.strings.concatStringsSep ", " [ + "floating enable" + "sticky enable" + "fullscreen disable" + "resize set 640 480" + "move position mouse" + ]; + } ]; - colors = let - background = config.lib.stylix.colors.withHashtag.base00; - in { - unfocused = { - border = lib.mkForce background; - childBorder = lib.mkForce background; - }; - }; - modes.resize = { - "Escape" = ''mode "default"''; - "Return" = ''mode "default"''; - "h" = "resize shrink width 10 px or 5 ppt"; - "j" = "resize grow height 10 px or 5 ppt"; - "k" = "resize shrink height 10 px or 5 ppt"; - "l" = "resize grow width 10 px or 5 ppt"; + }; + colors = let + background = config.lib.stylix.colors.withHashtag.base00; + in { + unfocused = { + border = lib.mkForce background; + childBorder = lib.mkForce background; }; - keybindings = { - "${modifier}+Shift+h" = "move left 25 px"; - "${modifier}+Shift+j" = "move down 25 px"; - "${modifier}+Shift+k" = "move up 25 px"; - "${modifier}+Shift+l" = "move right 25 px"; - "${modifier}+h" = "focus left"; - "${modifier}+j" = "focus down"; - "${modifier}+k" = "focus up"; - "${modifier}+l" = "focus right"; - - "${modifier}+Shift+b" = "move window to workspace prev"; - "${modifier}+Shift+n" = "move window to workspace next"; - "${modifier}+Shift+x" = "exec ${move-to-new-workspace}"; - "${modifier}+b" = "workspace prev"; - "${modifier}+n" = "workspace next"; - "${modifier}+x" = "exec ${new-workspace}"; + }; + keybindings = { + "${modifier}+Shift+h" = "move left 25 px"; + "${modifier}+Shift+j" = "move down 25 px"; + "${modifier}+Shift+k" = "move up 25 px"; + "${modifier}+Shift+l" = "move right 25 px"; + "${modifier}+h" = "focus left"; + "${modifier}+j" = "focus down"; + "${modifier}+k" = "focus up"; + "${modifier}+l" = "focus right"; - "${modifier}+Shift+c" = "reload"; - "${modifier}+Shift+q" = "kill"; - "${modifier}+Shift+r" = "restart"; + "${modifier}+Shift+b" = "move window to workspace prev"; + "${modifier}+Shift+n" = "move window to workspace next"; + "${modifier}+b" = "workspace prev"; + "${modifier}+n" = "workspace next"; - "${modifier}+z" = "sticky toggle"; - "${modifier}+Shift+z" = "floating toggle"; + "${modifier}+Shift+c" = "reload"; + "${modifier}+Shift+q" = "kill"; + "${modifier}+Shift+r" = "restart"; - "${modifier}+s" = "scratchpad show"; - "${modifier}+Shift+s" = "move scratchpad"; + "${modifier}+z" = "sticky toggle"; + "${modifier}+Shift+z" = "floating toggle"; - "${modifier}+c" = "split h"; - "${modifier}+e" = "layout toggle split"; - "${modifier}+f" = "fullscreen toggle"; - "${modifier}+r" = "mode resize"; - "${modifier}+v" = "split v"; - "${modifier}+w" = "layout tabbed"; - "${modifier}+q" = "exec ${config.services.clipmenu.package}/bin/clipmenu"; + "${modifier}+s" = "scratchpad show"; + "${modifier}+Shift+s" = "move scratchpad"; - "${modifier}+Return" = "exec ${(defaultApplications pkgs).terminal}"; - "${modifier}+t" = "exec ${(defaultApplications pkgs).fileManager}"; - "${modifier}+y" = "exec ${(defaultApplications pkgs).browser}"; - "${modifier}+0" = "exec ${niveumPackages.menu-calc}/bin/="; + "${modifier}+c" = "split h"; + "${modifier}+e" = "layout toggle split"; + "${modifier}+f" = "fullscreen toggle"; + "${modifier}+r" = "mode resize"; + "${modifier}+v" = "split v"; + "${modifier}+w" = "layout tabbed"; + "${modifier}+q" = "exec ${config.services.clipmenu.package}/bin/clipmenu"; - "${modifier}+d" = "exec ${pkgs.writers.writeDash "run" ''exec rofi -modi run,ssh,window -show run''}"; - "${modifier}+Shift+d" = "exec ${niveumPackages.notemenu}/bin/notemenu"; - "${modifier}+p" = "exec rofi-pass"; - "${modifier}+Shift+p" = "exec rofi-pass --insert"; - "${modifier}+u" = "exec ${niveumPackages.unicodmenu}/bin/unicodmenu"; + "${modifier}+Return" = "exec ${(defaultApplications pkgs).terminal}"; + "${modifier}+t" = "exec ${(defaultApplications pkgs).fileManager}"; + "${modifier}+y" = "exec ${(defaultApplications pkgs).browser}"; + "${modifier}+0" = "exec ${niveumPackages.menu-calc}/bin/="; - "${modifier}+F6" = "exec ${pkgs.xorg.xkill}/bin/xkill"; - "${modifier}+F7" = "exec ${pkgs.writers.writeDash "showkeys-toggle" '' - if ${pkgs.procps}/bin/pgrep screenkey; then - exec ${pkgs.procps}/bin/pkill screenkey - else - exec ${pkgs.screenkey}/bin/screenkey - fi - ''}"; - "${modifier}+F8" = "exec switch-theme toggle"; - "${modifier}+F9" = "exec ${pkgs.redshift}/bin/redshift -O 4000 -b 0.85"; - "${modifier}+F10" = "exec ${pkgs.redshift}/bin/redshift -x"; - "${modifier}+F11" = "exec ${pkgs.xcalib}/bin/xcalib -invert -alter"; - "${modifier}+F12" = "exec ${klem}/bin/klem"; - "Print" = "exec flameshot gui"; - "XF86AudioLowerVolume" = "exec ${pkgs.pamixer}/bin/pamixer -d 5"; - "XF86AudioMute" = "exec ${pkgs.pamixer}/bin/pamixer -t"; - "XF86AudioRaiseVolume" = "exec ${pkgs.pamixer}/bin/pamixer -i 5"; - "XF86Calculator" = "exec ${pkgs.st}/bin/st -c floating -e ${pkgs.bc}/bin/bc"; - "XF86AudioPause" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; - "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; - "XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next"; - "XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous"; - "XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop"; - "XF86ScreenSaver" = "exec ${niveumPackages.k-lock}/bin/k-lock"; + "${modifier}+d" = "exec ${pkgs.writers.writeDash "run" ''exec rofi -modi run,ssh,window -show run''}"; + "${modifier}+Shift+d" = "exec ${niveumPackages.notemenu}/bin/notemenu"; + "${modifier}+p" = "exec rofi-pass"; + "${modifier}+Shift+p" = "exec rofi-pass --insert"; + "${modifier}+u" = "exec ${niveumPackages.unicodmenu}/bin/unicodmenu"; - "XF86Display" = "exec ${niveumPackages.dmenu-randr}/bin/dmenu-randr"; + "${modifier}+F7" = "exec ${pkgs.writers.writeDash "showkeys-toggle" '' + if ${pkgs.procps}/bin/pgrep screenkey; then + exec ${pkgs.procps}/bin/pkill screenkey + else + exec ${pkgs.screenkey}/bin/screenkey + fi + ''}"; + "${modifier}+F12" = "exec ${klem}/bin/klem"; + "XF86AudioLowerVolume" = "exec ${pkgs.pamixer}/bin/pamixer -d 5"; + "XF86AudioMute" = "exec ${pkgs.pamixer}/bin/pamixer -t"; + "XF86AudioRaiseVolume" = "exec ${pkgs.pamixer}/bin/pamixer -i 5"; + "XF86Calculator" = "exec ${pkgs.st}/bin/st -c floating -e ${pkgs.bc}/bin/bc"; + "XF86AudioPause" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; + "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; + "XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next"; + "XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous"; + "XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop"; + "XF86ScreenSaver" = "exec ${niveumPackages.k-lock}/bin/k-lock"; - # key names detected with xorg.xev: - # XF86WakeUp (fn twice) - # XF86Battery (fn f3) - # XF86Sleep (fn f4) - actually suspends - # XF86WLAN - # XF86WebCam (fn f6) - # XF86TouchpadToggle (fn f8) - # XF86Suspend (fn f12) - actually suspends to disk - # Num_Lock (fn Roll) - numlocks - # XF86Audio{Prev,Next,Mute,Play,Stop} - # XF86Forward - # XF86Back - # XF86Launch1 (thinkvantage) + # key names detected with xorg.xev: + # XF86WakeUp (fn twice) + # XF86Battery (fn f3) + # XF86Sleep (fn f4) - actually suspends + # XF86WLAN + # XF86WebCam (fn f6) + # XF86TouchpadToggle (fn f8) + # XF86Suspend (fn f12) - actually suspends to disk + # Num_Lock (fn Roll) - numlocks + # XF86Audio{Prev,Next,Mute,Play,Stop} + # XF86Forward + # XF86Back + # XF86Launch1 (thinkvantage) + }; + in { + wayland.windowManager.sway = { + enable = true; + config = { + menu = "rofi -modi run,ssh,window -show run"; + inherit modifier modes gaps bars floating window colors keybindings; + input = { + "*" = { + xkb_layout = "de"; + xkb_variant = "T3"; + }; + }; + terminal = (defaultApplications pkgs).terminal; + up = "k"; + down = "j"; + left = "h"; + right = "l"; + seat = { + "*" = { + hide_cursor = "when-typing enable"; + }; + }; + startup = [ + {command = "echo hello";} + ]; }; }; + + xsession.windowManager.i3 = { + enable = true; + extraConfig = '' + bindsym --release ${modifier}+Shift+w exec /run/wrappers/bin/slock + ''; + config = lib.mkMerge [ + { + inherit modifier gaps modes bars floating window colors keybindings; + } + { + keybindings = let + new-workspace = pkgs.writers.writeDash "new-workspace" '' + i3-msg workspace $(($(i3-msg -t get_workspaces | tr , '\n' | grep '"num":' | cut -d : -f 2 | sort -rn | head -1) + 1)) + ''; + move-to-new-workspace = pkgs.writers.writeDash "new-workspace" '' + i3-msg move container to workspace $(($(i3-msg -t get_workspaces | tr , '\n' | grep '"num":' | cut -d : -f 2 | sort -rn | head -1) + 1)) + ''; + in { + "${modifier}+F6" = "exec ${pkgs.xorg.xkill}/bin/xkill"; + "${modifier}+F9" = "exec ${pkgs.redshift}/bin/redshift -O 4000 -b 0.85"; + "${modifier}+F10" = "exec ${pkgs.redshift}/bin/redshift -x"; + "${modifier}+F11" = "exec ${pkgs.xcalib}/bin/xcalib -invert -alter"; + "Print" = "exec flameshot gui"; + "${modifier}+Shift+x" = "exec ${move-to-new-workspace}"; + "${modifier}+x" = "exec ${new-workspace}"; + "XF86Display" = "exec ${niveumPackages.dmenu-randr}/bin/dmenu-randr"; + }; + } + ]; + }; }; }