From d08de8bc8c422b2b78365f017a97f9e2fc7197ef Mon Sep 17 00:00:00 2001 From: Caroline Larimore Date: Sat, 18 Jan 2025 14:32:18 -0800 Subject: home: desktop: port i3 config to sway --- roles/home/desktop/default.nix | 8 +- roles/home/desktop/i3.nix | 241 ----------------------------------------- roles/home/desktop/sway.nix | 240 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 244 insertions(+), 245 deletions(-) delete mode 100644 roles/home/desktop/i3.nix create mode 100644 roles/home/desktop/sway.nix (limited to 'roles/home/desktop') diff --git a/roles/home/desktop/default.nix b/roles/home/desktop/default.nix index 38b361c..6fdbb9a 100644 --- a/roles/home/desktop/default.nix +++ b/roles/home/desktop/default.nix @@ -5,7 +5,7 @@ let cfg = config.home.roles.desktop; in { imports = [ ./theme.nix - ./i3.nix + ./sway.nix ./picom.nix ./polybar.nix ./rofi.nix @@ -57,7 +57,7 @@ let cfg = config.home.roles.desktop; in { }; config = mkIf cfg.enable { - xsession.windowManager.i3.enable = true; + wayland.windowManager.sway.enable = true; gtk.enable = true; @@ -70,8 +70,8 @@ let cfg = config.home.roles.desktop; in { }; services = { - picom.enable = true; - polybar.enable = true; + #picom.enable = true; + #polybar.enable = true; flameshot.enable = cfg.screenshot; }; diff --git a/roles/home/desktop/i3.nix b/roles/home/desktop/i3.nix deleted file mode 100644 index bea43fc..0000000 --- a/roles/home/desktop/i3.nix +++ /dev/null @@ -1,241 +0,0 @@ -{ config, pkgs, ... }: - -{ - xsession.windowManager.i3 = { - config = let - #NOTE: Alt (Mod1) and meta (Mod4) have been swapped by keyd. - mod = "Mod4"; - - ws0 = "0:Main"; - ws1 = "1:Terminal"; - ws2 = "2:Browser"; - ws3 = "3:Chat"; - ws4 = "4:Gaming"; - ws5 = "5"; - ws6 = "6"; - ws7 = "7"; - ws8 = "8:Meow"; - ws9 = "9:Music"; - ws10 = "10:Misc"; - ws11 = "11:Empty"; - - output = { - primary = "primary"; - left = "DVI-D-0"; - right = "DisplayPort-1 HDMI-A-0"; - }; - in { - modifier = "${mod}"; - - fonts = { - names = [ "monospace" ]; - size = 8.0; - }; - - colors = let c = config.theme.colors; in { - focused = { - border = "#${c.fg2}"; - background = "#${c.fg2}"; - text = "#${c.bg}"; - indicator = "#${c.fg2}"; - childBorder = "#${c.fg2}"; - }; - - focusedInactive = { - border = "#${c.bg1}"; - background = "#${c.bg1}"; - text = "#${c.fg}"; - indicator = "#${c.bg1}"; - childBorder = "#${c.bg1}"; - }; - - unfocused = { - border = "#${c.bg}"; - background = "#${c.bg}"; - text = "#${c.fg}"; - indicator = "#${c.bg}"; - childBorder = "#${c.bg}"; - }; - }; - - gaps.inner = 8; - - workspaceOutputAssign = [ - { workspace = "${ws0}"; output = output.primary; } - { workspace = "${ws1}"; output = output.primary; } - - { workspace = "${ws2}"; output = output.left; } - { workspace = "${ws3}"; output = output.left; } - - { workspace = "${ws4}"; output = output.primary; } - - { workspace = "${ws5}"; output = output.primary; } - { workspace = "${ws6}"; output = output.primary; } - { workspace = "${ws7}"; output = output.primary; } - - { workspace = "${ws8}"; output = output.primary; } - { workspace = "${ws9}"; output = output.right; } - { workspace = "${ws10}"; output = output.primary; } - - { workspace = "${ws11}"; output = output.primary; } - ]; - - assigns = { - "${ws2}" = [ { class = "firefox"; } ]; - "${ws3}" = [ { class = "discord"; } ]; - "${ws4}" = [ - { class = "steam"; } - { class = "prismlauncher"; } - ]; - - "${ws8}" = [ { class = "qbittorrent"; } ]; - "${ws9}" = [ { title = "cmus"; } ]; - }; - - startup = [ - #{ command = "polybar-msg cmd quit"; always = true; notification = false; } - #{ command = "polybar"; always = true; notification = false; } - { command = "waybar"; always = true; notification = false; } - - #{ command = "systemctl --user restart picom"; always = true; notification = false; } - #{ command = "${pkgs.feh}/bin/feh --bg-fill ${../../../assets/bg/${config.theme.background}}"; always = true; notification = false; } - { command = "${pkgs.swww}/bin/swww-daemon"; always = true; notification = false; } - { command = "${pkgs.swww}/bin/swww img ${../../../assets/bg/${config.theme.background}}"; always = true; notification = false; } - { command = "${pkgs.fcitx5}/bin/fcitx5 -r -d"; always = true; notification = false; } - ]; - - keybindings = { - "${mod}+Shift+c" = "reload"; - "${mod}+Shift+r" = "restart"; - "${mod}+Shift+e" = "exec \"i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'\""; - - "${mod}+q" = "kill"; - "${mod}+d" = "exec \"rofi -modi drun,run -show drun\""; - "${mod}+Return" = "exec kitty"; - - "${mod}+Num_Lock" = "exec --no-startup-id polybar-msg cmd toggle"; - - # Screenshots - #TODO: screen and full should be swapped, but currently screen is fucky :'( - "Shift+Print" = "exec --no-startup-id ${pkgs.flameshot}/bin/flameshot screen -c"; - "Print" = "exec --no-startup-id ${pkgs.flameshot}/bin/flameshot full -c"; - "${mod}+Shift+s" = "exec --no-startup-id ${pkgs.flameshot}/bin/flameshot gui -c"; - "Mod1+Shift+s" = "exec --no-startup-id ${pkgs.flameshot}/bin/flameshot gui -c"; - "${mod}+Ctrl+Shift+s" = "exec --no-startup-id ${pkgs.flameshot}/bin/flameshot launcher -c"; - - # Media keys - "XF86AudioRaiseVolume" = "exec --no-startup-id ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +2%"; - "XF86AudioLowerVolume" = "exec --no-startup-id ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -2%"; - "XF86AudioMute" = "exec --no-startup-id ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle"; - "XF86AudioMicMute" = "exec --no-startup-id ${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle"; - - "XF86AudioPlay" = "exec --no-startup-id \"playerctl --player=cmus,firefox,%any play-pause\""; - "XF86AudioPause" = "exec --no-startup-id \"playerctl --player=cmus,firefox,%any play-pause\""; - "XF86AudioStop" = "exec --no-startup-id \"playerctl --player=cmus,firefox,%any stop\""; - "XF86AudioNext" = "exec --no-startup-id \"playerctl --player=cmus,firefox,%any next\""; - "XF86AudioPrev" = "exec --no-startup-id \"playerctl --player=cmus,firefox,%any previous\""; - - # Media controller widget - "${mod}+m" = "exec --no-startup-id eww-toggle music --arg pos=center --arg gaps=false"; - "${mod}+Ctrl+m" = "exec --no-startup-id eww-toggle music --arg pos=right --arg gaps=true"; - "${mod}+Shift+m" = "exec --no-startup-id eww-toggle music --arg pos=center --arg gaps=true"; - "${mod}+Shift+Ctrl+m" = "exec --no-startup-id eww-toggle music --arg pos=right --arg gaps=false"; - - # Workspaces - "${mod}+grave" = "workspace number ${ws0}"; - "${mod}+1" = "workspace number ${ws1}"; - "${mod}+2" = "workspace number ${ws2}"; - "${mod}+3" = "workspace number ${ws3}"; - "${mod}+4" = "workspace number ${ws4}"; - "${mod}+5" = "workspace number ${ws5}"; - "${mod}+6" = "workspace number ${ws6}"; - "${mod}+7" = "workspace number ${ws7}"; - "${mod}+8" = "workspace number ${ws8}"; - "${mod}+9" = "workspace number ${ws9}"; - "${mod}+0" = "workspace number ${ws10}"; - "${mod}+equal" = "workspace number ${ws11}"; - - # Move active workspace - "${mod}+comma" = "move workspace to output ${output.left}"; - "${mod}+period" = "move workspace to output ${output.primary}"; - "${mod}+slash" = "move workspace to output ${output.right}"; - - # Layout - "${mod}+z" = "layout stacking"; - "${mod}+x" = "layout tabbed"; - "${mod}+c" = "layout toggle split"; - - # Focus - "${mod}+h" = "focus left"; - "${mod}+j" = "focus down"; - "${mod}+k" = "focus up"; - "${mod}+l" = "focus right"; - - "${mod}+Left" = "focus left"; - "${mod}+Down" = "focus down"; - "${mod}+Up" = "focus up"; - "${mod}+Right" = "focus right"; - - "${mod}+space" = "focus mode_toggle"; - "${mod}+a" = "focus parent"; - - # Move focused container - "${mod}+Shift+h" = "move left"; - "${mod}+Shift+j" = "move down"; - "${mod}+Shift+k" = "move up"; - "${mod}+Shift+l" = "move right"; - - "${mod}+Shift+Left" = "move left"; - "${mod}+Shift+Down" = "move down"; - "${mod}+Shift+Up" = "move up"; - "${mod}+Shift+Right" = "move right"; - - # Misc container binds - "${mod}+Shift+space" = "floating toggle"; - "${mod}+f" = "fullscreen toggle"; - - "${mod}+w" = "split h"; - "${mod}+e" = "split v"; - - "${mod}+r" = "mode resize"; - - # Move focused container to workspace - "${mod}+Shift+grave" = "move container to workspace number ${ws0}"; - "${mod}+Shift+1" = "move container to workspace number ${ws1}"; - "${mod}+Shift+2" = "move container to workspace number ${ws2}"; - "${mod}+Shift+3" = "move container to workspace number ${ws3}"; - "${mod}+Shift+4" = "move container to workspace number ${ws4}"; - "${mod}+Shift+5" = "move container to workspace number ${ws5}"; - "${mod}+Shift+6" = "move container to workspace number ${ws6}"; - "${mod}+Shift+7" = "move container to workspace number ${ws7}"; - "${mod}+Shift+8" = "move container to workspace number ${ws8}"; - "${mod}+Shift+9" = "move container to workspace number ${ws9}"; - "${mod}+Shift+0" = "move container to workspace number ${ws10}"; - }; - - modes = { - resize = { - "h" = "resize shrink width 10 px or 10 ppt"; - "j" = "resize grow height 10 px or 10 ppt"; - "k" = "resize shrink height 10 px or 10 ppt"; - "l" = "resize grow width 10 px or 10 ppt"; - - "Left" = "resize shrink width 10 px or 10 ppt"; - "Down" = "resize grow height 10 px or 10 ppt"; - "Up" = "resize shrink height 10 px or 10 ppt"; - "Right" = "resize grow width 10 px or 10 ppt"; - - "Return" = "mode default"; - "Escape" = "mode default"; - "${mod}+r" = "mode default"; - }; - }; - - bars = []; - }; - - extraConfig = '' - default_border normal 0 - ''; - }; -} diff --git a/roles/home/desktop/sway.nix b/roles/home/desktop/sway.nix new file mode 100644 index 0000000..7be1439 --- /dev/null +++ b/roles/home/desktop/sway.nix @@ -0,0 +1,240 @@ +{ config, pkgs, ... }: + +{ + wayland.windowManager.sway = { + config = let + #NOTE: Alt (Mod1) and meta (Mod4) have been swapped by keyd. + mod = "Mod4"; + + ws0 = "0:Main"; + ws1 = "1:Terminal"; + ws2 = "2:Browser"; + ws3 = "3:Chat"; + ws4 = "4:Gaming"; + ws5 = "5"; + ws6 = "6"; + ws7 = "7"; + ws8 = "8:Meow"; + ws9 = "9:Music"; + ws10 = "10:Misc"; + ws11 = "11:Empty"; + + output = { + primary = "DP-3"; + left = "DVI-D-1"; + right = "DP-2 HDMI-A-0"; + }; + in { + modifier = "${mod}"; + + fonts = { + names = [ "monospace" ]; + size = 8.0; + }; + + colors = let c = config.theme.colors; in { + focused = { + border = "#${c.fg2}"; + background = "#${c.fg2}"; + text = "#${c.bg}"; + indicator = "#${c.fg2}"; + childBorder = "#${c.fg2}"; + }; + + focusedInactive = { + border = "#${c.bg1}"; + background = "#${c.bg1}"; + text = "#${c.fg}"; + indicator = "#${c.bg1}"; + childBorder = "#${c.bg1}"; + }; + + unfocused = { + border = "#${c.bg}"; + background = "#${c.bg}"; + text = "#${c.fg}"; + indicator = "#${c.bg}"; + childBorder = "#${c.bg}"; + }; + }; + + gaps.inner = 8; + + workspaceOutputAssign = [ + { workspace = "${ws0}"; output = output.primary; } + { workspace = "${ws1}"; output = output.primary; } + + { workspace = "${ws2}"; output = output.left; } + { workspace = "${ws3}"; output = output.left; } + + { workspace = "${ws4}"; output = output.primary; } + + { workspace = "${ws5}"; output = output.primary; } + { workspace = "${ws6}"; output = output.primary; } + { workspace = "${ws7}"; output = output.primary; } + + { workspace = "${ws8}"; output = output.primary; } + { workspace = "${ws9}"; output = output.right; } + { workspace = "${ws10}"; output = output.primary; } + + { workspace = "${ws11}"; output = output.primary; } + ]; + + assigns = { + "${ws2}" = [ { class = "firefox"; } ]; + "${ws3}" = [ { class = "discord"; } ]; + "${ws4}" = [ + { class = "steam"; } + { class = "prismlauncher"; } + ]; + + "${ws8}" = [ { class = "qbittorrent"; } ]; + "${ws9}" = [ { title = "cmus"; } ]; + }; + + startup = [ + { command = "waybar"; always = true; } + + #TODO: make sure swww-daemon is *re*starting + { command = "${pkgs.swww}/bin/swww-daemon"; always = true; } + { command = "${pkgs.swww}/bin/swww img ${../../../assets/bg/${config.theme.background}}"; always = true; } + + { command = "${pkgs.fcitx5}/bin/fcitx5 -r -d"; always = true; } + ]; + + keybindings = { + "${mod}+Shift+c" = "reload"; + "${mod}+Shift+r" = "restart"; + #TODO: remove i3-nagbar + "${mod}+Shift+e" = "exec \"i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'\""; + + "${mod}+q" = "kill"; + "${mod}+d" = "exec \"rofi -modi drun,run -show drun\""; + "${mod}+Return" = "exec kitty"; + + "${mod}+Num_Lock" = "exec --no-startup-id polybar-msg cmd toggle"; + + # Screenshots + #TODO: screen and full should be swapped, but currently screen is fucky :'( + "Shift+Print" = "exec --no-startup-id ${pkgs.flameshot}/bin/flameshot screen -c"; + "Print" = "exec --no-startup-id ${pkgs.flameshot}/bin/flameshot full -c"; + "${mod}+Shift+s" = "exec --no-startup-id ${pkgs.flameshot}/bin/flameshot gui -c"; + "Mod1+Shift+s" = "exec --no-startup-id ${pkgs.flameshot}/bin/flameshot gui -c"; + "${mod}+Ctrl+Shift+s" = "exec --no-startup-id ${pkgs.flameshot}/bin/flameshot launcher -c"; + + # Media keys + "XF86AudioRaiseVolume" = "exec --no-startup-id ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +2%"; + "XF86AudioLowerVolume" = "exec --no-startup-id ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -2%"; + "XF86AudioMute" = "exec --no-startup-id ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle"; + "XF86AudioMicMute" = "exec --no-startup-id ${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle"; + + "XF86AudioPlay" = "exec --no-startup-id \"playerctl --player=cmus,firefox,%any play-pause\""; + "XF86AudioPause" = "exec --no-startup-id \"playerctl --player=cmus,firefox,%any play-pause\""; + "XF86AudioStop" = "exec --no-startup-id \"playerctl --player=cmus,firefox,%any stop\""; + "XF86AudioNext" = "exec --no-startup-id \"playerctl --player=cmus,firefox,%any next\""; + "XF86AudioPrev" = "exec --no-startup-id \"playerctl --player=cmus,firefox,%any previous\""; + + # Media controller widget + "${mod}+m" = "exec --no-startup-id eww-toggle music --arg pos=center --arg gaps=false"; + "${mod}+Ctrl+m" = "exec --no-startup-id eww-toggle music --arg pos=right --arg gaps=true"; + "${mod}+Shift+m" = "exec --no-startup-id eww-toggle music --arg pos=center --arg gaps=true"; + "${mod}+Shift+Ctrl+m" = "exec --no-startup-id eww-toggle music --arg pos=right --arg gaps=false"; + + # Workspaces + "${mod}+grave" = "workspace number ${ws0}"; + "${mod}+1" = "workspace number ${ws1}"; + "${mod}+2" = "workspace number ${ws2}"; + "${mod}+3" = "workspace number ${ws3}"; + "${mod}+4" = "workspace number ${ws4}"; + "${mod}+5" = "workspace number ${ws5}"; + "${mod}+6" = "workspace number ${ws6}"; + "${mod}+7" = "workspace number ${ws7}"; + "${mod}+8" = "workspace number ${ws8}"; + "${mod}+9" = "workspace number ${ws9}"; + "${mod}+0" = "workspace number ${ws10}"; + "${mod}+equal" = "workspace number ${ws11}"; + + # Move active workspace + "${mod}+comma" = "move workspace to output ${output.left}"; + "${mod}+period" = "move workspace to output ${output.primary}"; + "${mod}+slash" = "move workspace to output ${output.right}"; + + # Layout + "${mod}+z" = "layout stacking"; + "${mod}+x" = "layout tabbed"; + "${mod}+c" = "layout toggle split"; + + # Focus + "${mod}+h" = "focus left"; + "${mod}+j" = "focus down"; + "${mod}+k" = "focus up"; + "${mod}+l" = "focus right"; + + "${mod}+Left" = "focus left"; + "${mod}+Down" = "focus down"; + "${mod}+Up" = "focus up"; + "${mod}+Right" = "focus right"; + + "${mod}+space" = "focus mode_toggle"; + "${mod}+a" = "focus parent"; + + # Move focused container + "${mod}+Shift+h" = "move left"; + "${mod}+Shift+j" = "move down"; + "${mod}+Shift+k" = "move up"; + "${mod}+Shift+l" = "move right"; + + "${mod}+Shift+Left" = "move left"; + "${mod}+Shift+Down" = "move down"; + "${mod}+Shift+Up" = "move up"; + "${mod}+Shift+Right" = "move right"; + + # Misc container binds + "${mod}+Shift+space" = "floating toggle"; + "${mod}+f" = "fullscreen toggle"; + + "${mod}+w" = "split h"; + "${mod}+e" = "split v"; + + "${mod}+r" = "mode resize"; + + # Move focused container to workspace + "${mod}+Shift+grave" = "move container to workspace number ${ws0}"; + "${mod}+Shift+1" = "move container to workspace number ${ws1}"; + "${mod}+Shift+2" = "move container to workspace number ${ws2}"; + "${mod}+Shift+3" = "move container to workspace number ${ws3}"; + "${mod}+Shift+4" = "move container to workspace number ${ws4}"; + "${mod}+Shift+5" = "move container to workspace number ${ws5}"; + "${mod}+Shift+6" = "move container to workspace number ${ws6}"; + "${mod}+Shift+7" = "move container to workspace number ${ws7}"; + "${mod}+Shift+8" = "move container to workspace number ${ws8}"; + "${mod}+Shift+9" = "move container to workspace number ${ws9}"; + "${mod}+Shift+0" = "move container to workspace number ${ws10}"; + }; + + modes = { + resize = { + "h" = "resize shrink width 10 px or 10 ppt"; + "j" = "resize grow height 10 px or 10 ppt"; + "k" = "resize shrink height 10 px or 10 ppt"; + "l" = "resize grow width 10 px or 10 ppt"; + + "Left" = "resize shrink width 10 px or 10 ppt"; + "Down" = "resize grow height 10 px or 10 ppt"; + "Up" = "resize shrink height 10 px or 10 ppt"; + "Right" = "resize grow width 10 px or 10 ppt"; + + "Return" = "mode default"; + "Escape" = "mode default"; + "${mod}+r" = "mode default"; + }; + }; + + bars = []; + }; + + extraConfig = '' + default_border normal 0 + ''; + }; +} -- cgit v1.2.3