From 89a177caa13d8b0dc6216ebf2eb23dabf1b7a000 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Fri, 19 Apr 2024 22:00:41 -0400 Subject: [PATCH] home/sway: brought to parity with hyprland --- homeManagerModules/apps/waybar/default.nix | 9 ++ homeManagerModules/apps/waybar/waybar.css | 2 +- homeManagerModules/desktop/hypr/default.nix | 12 +- homeManagerModules/desktop/sway/default.nix | 150 +++++++++++++++----- hosts/petalburg/home.nix | 6 + 5 files changed, 137 insertions(+), 42 deletions(-) diff --git a/homeManagerModules/apps/waybar/default.nix b/homeManagerModules/apps/waybar/default.nix index f179140c..01a8c418 100644 --- a/homeManagerModules/apps/waybar/default.nix +++ b/homeManagerModules/apps/waybar/default.nix @@ -53,6 +53,15 @@ }; "sway/workspaces" = { "all-outputs" = true; + "format" = "{icon} {name}"; + "format-icons" = { + "default" = "󰝥"; + "focused" = "󰪥"; + }; + "sort-by" = "id"; + }; + "sway/mode" = { + "on-click" = "${pkgs.sway}/bin/swaymsg mode default"; }; "sway/window" = { "max-length" = 100; diff --git a/homeManagerModules/apps/waybar/waybar.css b/homeManagerModules/apps/waybar/waybar.css index 17f2c921..efe1b7f3 100644 --- a/homeManagerModules/apps/waybar/waybar.css +++ b/homeManagerModules/apps/waybar/waybar.css @@ -17,7 +17,7 @@ window#waybar { color: #FAFAFA; } -#workspaces button.active { +#workspaces button.active, #workspaces button.focused { color: #ca9ee6; } diff --git a/homeManagerModules/desktop/hypr/default.nix b/homeManagerModules/desktop/hypr/default.nix index 5561f0db..b617600a 100644 --- a/homeManagerModules/desktop/hypr/default.nix +++ b/homeManagerModules/desktop/hypr/default.nix @@ -112,7 +112,7 @@ media = "${pkgs.playerctl}/bin/playerctl"; media_play = "${media} play-pause"; media_next = "${media} next"; - media_previous = "${media} previous"; + media_prev = "${media} previous"; screenshot = "${pkgs.hyprshot}/bin/hyprshot"; screenshot_folder = "~/pics/screenshots"; @@ -274,16 +274,16 @@ windowrulev2 = suppressevent maximize, class:.* # Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more - bind = ${modifier}, T, exec, ${terminal} - bind = ${modifier}, F, exec, ${fileManager} bind = ${modifier}, B, exec, ${browser} bind = ${modifier}, E, exec, ${editor} + bind = ${modifier}, F, exec, ${fileManager} bind = ${modifier}, R, exec, ${launcher} + bind = ${modifier}, T, exec, ${terminal} # Manage session. bind = ${modifier}, C, killactive, - bind = ${modifier}, M, exec, ${logout} bind = ${modifier}, L, exec, ${lock} + bind = ${modifier}, M, exec, ${logout} # Basic window management. bind = ${modifier} SHIFT, W, fullscreen @@ -333,7 +333,7 @@ bind = ${modifier} SHIFT, 9, movetoworkspace, 9 bind = ${modifier} SHIFT, 0, movetoworkspace, 10 - # Example special workspace (scratchpad) + # Scratchpad show and move bind = ${modifier}, S, togglespecialworkspace, magic bind = ${modifier} SHIFT, S, movetoworkspace, special:magic @@ -353,7 +353,7 @@ bindl = , xf86audiomute, exec, ${volume_mute} bindl = , xf86audiomicmute, exec, ${mic_mute} bindl = , xf86audioplay, exec, ${media_play} - bindl = , xf86audioprev, exec, ${media_previous} + bindl = , xf86audioprev, exec, ${media_prev} bindl = , xf86audionext, exec, ${media_next} # Extra bindings for petalburg. diff --git a/homeManagerModules/desktop/sway/default.nix b/homeManagerModules/desktop/sway/default.nix index 11ead6e2..227185b9 100644 --- a/homeManagerModules/desktop/sway/default.nix +++ b/homeManagerModules/desktop/sway/default.nix @@ -54,6 +54,7 @@ }; wayland.windowManager.sway.enable = true; + wayland.windowManager.sway.package = pkgs.swayfx; wayland.windowManager.sway.config = let modifier = "Mod4"; @@ -63,11 +64,11 @@ editor = pkgs.vscodium + "/bin/codium"; terminal = pkgs.alacritty + "/bin/alacritty"; - # River desktop utilities + # Sway desktop utilities bar = pkgs.waybar + "/bin/waybar"; launcher = pkgs.fuzzel + "/bin/fuzzel"; notifyd = pkgs.mako + "/bin/mako"; - wallpaperd = pkgs.swaybg + "/bin/swaybg"; + wallpaperd = pkgs.swaybg + "/bin/swaybg -i ~/.local/share/backgrounds/jr-korpa-9XngoIpxcEo-unsplash.jpg"; idle = pkgs.swayidle + "/bin/swayidle"; logout = pkgs.wlogout + "/bin/wlogout"; lock = pkgs.swaylock + "/bin/swaylock -f -c 000000"; @@ -83,11 +84,11 @@ media = "${pkgs.playerctl}/bin/playerctl"; media_play = "${media} play-pause"; media_next = "${media} next"; - media_previous = "${media} previous"; + media_prev = "${media} previous"; - # screenshot = "${pkgs.hyprshot}/bin/hyprshot"; - # screenshot_folder = "~/pics/screenshots"; - # screenshot_screen = "${screenshot} -m output -o ${screenshot_folder}"; + screenshot = "${pkgs.grim}/bin/grim"; + screenshot_folder = "~/pics/screenshots"; + screenshot_screen = "${screenshot} ${screenshot_folder}/$(date +'%s_grim.png')"; # screenshot_region = "${screenshot} -m region -o ${screenshot_folder}"; # Color, themes, scaling @@ -100,7 +101,6 @@ gdk_scale = "1.5"; in { bars = [{command = "${bar}";}]; - # bars.waybar.command = "${pkgs.waybar}/bin/waybar"; terminal = "${terminal}"; menu = "${launcher}"; modifier = "${modifier}"; @@ -135,10 +135,16 @@ size = 12.0; }; startup = [ - # { command = "${pkgs.kanshi}"; } - {command = "nm-applet";} - {command = "swayosd-server";} - {command = "thunar --daemon";} + {command = "${wallpaperd}";} + {command = "${pkgs.kanshi}";} + {command = "${notifyd}";} + {command = "${pkgs.wl-clipboard}/bin/wl-paste --type text --watch cliphist store";} + {command = "${pkgs.wl-clipboard}/bin/wl-paste --type image --watch cliphist store";} + {command = "${pkgs.mate.mate-polkit}/libexec/polkit-mate-authentication-agent-1";} + {command = "${fileManager} --daemon";} + {command = "${pkgs.swayosd}/bin/swayosd-server";} + {command = "${pkgs.networkmanagerapplet}/bin/nm-applet";} + {command = "${pkgs.trayscale}/bin/trayscale --hide-window";} {command = "${pkgs.swayidle}/bin/swayidle -w timeout 300 '${pkgs.swaylock}/bin/swaylock' before-sleep '${pkgs.swaylock}/bin/swaylock'";} ]; output = { @@ -156,27 +162,42 @@ tap_button_map = "lrm"; }; }; - keybindings = lib.mkOptionDefault { - "${modifier}+r" = "exec ${launcher}"; - "${modifier}+t" = "exec ${terminal}"; - "${modifier}+b" = "exec ${browser}"; - "${modifier}+e" = "exec ${editor}"; - "${modifier}+f" = "exec ${fileManager}"; + keybindings = { + # Apps + "${modifier}+B" = "exec ${browser}"; + "${modifier}+E" = "exec ${editor}"; + "${modifier}+F" = "exec ${fileManager}"; + "${modifier}+R" = "exec ${launcher}"; + "${modifier}+T" = "exec ${terminal}"; - "${modifier}+c" = "kill"; + # Manage session. + "${modifier}+C" = "kill"; + "${modifier}+L" = "exec ${lock}"; + "${modifier}+M" = "exec ${logout}"; - "${modifier}+l" = "exec ${lock}"; - "${modifier}+m" = "exec ${logout}"; + # Basic window management. + "${modifier}+Shift+W" = "fullscreen toggle"; + "${modifier}+Shift+V" = "floating toggle"; - "${modifier}+w" = "fullscreen toggle"; - "${modifier}+v" = "floating toggle"; + # Move focus with modifier + arrow keys + "${modifier}+Left" = "focus left"; + "${modifier}+Down" = "focus down"; + "${modifier}+Up" = "focus up"; + "${modifier}+Right" = "focus right"; - "${modifier}+s" = "scratchpad show"; - "${modifier}+Shift+s" = "move scratchpad"; + # Move window with modifier SHIFT + arrow keys + "${modifier}+Shift+Left" = "move left"; + "${modifier}+Shift+Down" = "move down"; + "${modifier}+Shift+Up" = "move up"; + "${modifier}+Shift+Right" = "move right"; - "${modifier}+period" = "workspace next"; - "${modifier}+comma" = "workspace prev"; + # Gnome-like workspaces. + "${modifier}+Comma" = "workspace prev"; + "${modifier}+Period" = "workspace next"; + "${modifier}+Shift+Comma" = "move container to workspace prev; workspace prev"; + "${modifier}+Shift+Period" = "move container to workspace next; workspace next"; + # Switch workspaces with modifier + [0-9] "${modifier}+1" = "workspace number 1"; "${modifier}+2" = "workspace number 2"; "${modifier}+3" = "workspace number 3"; @@ -186,10 +207,9 @@ "${modifier}+7" = "workspace number 7"; "${modifier}+8" = "workspace number 8"; "${modifier}+9" = "workspace number 9"; + "${modifier}+0" = "workspace number 10"; - "${modifier}+Shift+period" = "move container to workspace next; workspace next"; - "${modifier}+Shift+comma" = "move container to workspace prev; workspace prev"; - + # Move active window to a workspace with modifier + SHIFT + [0-9] "${modifier}+Shift+1" = "move container to workspace number 1"; "${modifier}+Shift+2" = "move container to workspace number 2"; "${modifier}+Shift+3" = "move container to workspace number 3"; @@ -199,24 +219,84 @@ "${modifier}+Shift+7" = "move container to workspace number 7"; "${modifier}+Shift+8" = "move container to workspace number 8"; "${modifier}+Shift+9" = "move container to workspace number 9"; + "${modifier}+Shift+0" = "move container to workspace number 10"; - # audio control + # Scratchpad show and move + "${modifier}+S" = "scratchpad show"; + "${modifier}+Shift+S" = "move scratchpad"; + + # TODO: scroll with mouse up/down through workspaces + + # Display, volume, microphone, and media keys. + "XF86MonBrightnessUp" = "exec ${brightness_up}"; + "XF86MonBrightnessDown" = "exec ${brightness_down}"; "XF86AudioRaiseVolume" = "exec ${volume_up}"; "XF86AudioLowerVolume" = "exec ${volume_down}"; "XF86AudioMute" = "exec ${volume_mute}"; - - # mic control "XF86AudioMicMute" = "exec ${mic_mute}"; + "XF86AudioPlay" = "exec ${media_play}"; + "XF86AudioPrev" = "exec ${media_prev}"; + "XF86AudioNext" = "exec ${media_next}"; - # brightness - "XF86MonBrightnessUp" = "exec ${brightness_up}"; - "XF86MonBrightnessDown" = "exec ${brightness_down}"; + # For petalburg + "XF86Launch4" = "exec pp-adjuster"; + # TODO: night color shift + # "XF86Launch1" = + "XF86Launch2" = "exec ${media_play}"; + + # Screenshots + "PRINT" = "exec ${screenshot_screen}"; + # "${modifier}+PRINT" = "${screenshot_region}"; + + # Show/hide waybar + "${modifier}+F11" = "exec pkill -SIGUSR1 waybar"; + + "Mod1+R" = "mode resize"; + "Mod1+M" = "mode move"; + }; + modes = { + resize = { + Escape = "mode default"; + Left = "resize shrink width 10 px"; + Down = "resize grow height 10 px"; + Up = "resize shrink height 10 px"; + Right = "resize grow width 10 px"; + }; + move = { + Escape = "mode default"; + Left = "move left"; + Down = "move down"; + Up = "move up"; + Right = "move right"; + Comma = "move container to workspace prev; workspace prev"; + Period = "move container to workspace next; workspace next"; + "1" = "move container to workspace number 1"; + "2" = "move container to workspace number 2"; + "3" = "move container to workspace number 3"; + "4" = "move container to workspace number 4"; + "5" = "move container to workspace number 5"; + "6" = "move container to workspace number 6"; + "7" = "move container to workspace number 7"; + "8" = "move container to workspace number 8"; + "9" = "move container to workspace number 9"; + "0" = "move container to workspace number 10"; + S = "move scratchpad"; + }; }; }; wayland.windowManager.sway.extraConfig = '' bindgesture swipe:right workspace prev bindgesture swipe:left workspace next + + blur enable + blur_passes 1 + corner_radius 10 + shadows enable + + layer_effects waybar blur enable + layer_effects launcher blur enable + layer_effects logout_dialog blur enable ''; xdg.configFile."xfce4/helpers.rc".text = '' diff --git a/hosts/petalburg/home.nix b/hosts/petalburg/home.nix index 7016e5bf..93317b32 100644 --- a/hosts/petalburg/home.nix +++ b/hosts/petalburg/home.nix @@ -8,5 +8,11 @@ home-manager.users.aly = { imports = [../../homeManagerModules ../../aly.nix]; home.stateVersion = "23.11"; + alyraffauf = { + services.syncthing.enable = true; + desktop.sway = { + enable = true; + }; + }; }; }