{ pkgs, lib, ... }: let modifier = "Mod4"; terminal = "alacritty"; in { home.packages = with pkgs; [ swayidle wl-clipboard wlroots ]; wayland.windowManager.sway = { enable = true; wrapperFeatures.gtk = true; config = { inherit modifier terminal; menu = "wofi --show drun"; fonts = { names = [ "NotoSans Nerd Font" ]; style = "Medium"; size = 12.0; }; bars = [{ command = "waybar"; }]; window.border = 3; gaps = { inner = 8; outer = 0; }; colors = { unfocused.border = "#474f6f"; unfocused.background = "#1a1b26"; unfocused.text = "#a9b1d6"; unfocused.indicator = "#474f6f"; unfocused.childBorder = "#474f6f"; focused.border = "#7bc5e4"; focused.background = "#1a1b26"; focused.text = "#a9b1d6"; focused.indicator = "#7bc5e4"; focused.childBorder = "#7bc5e4"; focusedInactive.border = "#787c99"; focusedInactive.background = "#1a1b26"; focusedInactive.text = "#a9b1d6"; focusedInactive.indicator = "#787c99"; focusedInactive.childBorder = "#787c99"; urgent.border = "#d5556f"; urgent.background = "#444b6a"; urgent.text = "#ffffff"; urgent.indicator = "#d5556f"; urgent.childBorder = "#d5556f"; }; startup = map (x: { command = x; }) [ # Make wob channels ''mkfifo $SWAYSOCK.volume.wob && tail -f $SWAYSOCK.volume.wob | wob'' ''mkfifo $SWAYSOCK.brightness.wob && tail -f $SWAYSOCK.brightness.wob | wob \ --border-color "#FFFF00FF" --bar-color "#FFFF00FF"'' ''swayidle timeout 120 'swaylock -f --grace=180' \ timeout 600 'systemctl suspend' \ before-sleep 'swaylock -f' '' ''export XDG_SESSION_TYPE=wayland'' ''export XDG_CURRENT_DESKTOP=sway'' ]; keybindings = let # Volume using pamixer and wob audio-disp = ''pamixer --get-volume > $SWAYSOCK.volume.wob''; audio = cmd: "exec pamixer ${cmd} && ${audio-disp}"; # Brightness using brightnessctl and wob brightness-disp = ''brightnessctl -e -m | cut -d "," -f4 | tr -d "%" > $SWAYSOCK.brightness.wob''; brightness = x: "exec brightnessctl -e set ${x} && ${brightness-disp}"; # Play controls using playerctl playerctl = cmd: "exec playerctl ${cmd}"; # Grim screenshot file name filename = ''~/Pictures/$(date +%Y-%m-%d_%H-%M-%S).png''; in pkgs.lib.mkOptionDefault { "${modifier}+Shift+d" = ''exec wofi --show run''; "${modifier}+Shift+m" = ''exec swaylock''; # Screenshot "Print" = ''exec grim ${filename}''; "Shift+Print" = ''exec grim -g "$(slurp)" ${filename}''; "Ctrl+Print" = ''exec grim -g "$(swaymsg -t get_tree | jq -j '.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"')" ${filename}''; # Special XF86 key bindings "XF86AudioRaiseVolume" = audio "-ui 2"; "XF86AudioLowerVolume" = audio "-ud 2"; "Shift+XF86AudioRaiseVolume" = audio "-ui 2 --allow-boost"; "Shift+XF86AudioLowerVolume" = audio "-ud 2 --allow-boost"; "XF86AudioMute" = ''exec pamixer --toggle-mute''; "XF86AudioMicMute" = ''exec pactl set-source-mute @DEFAULT_SOURCE@ toggle''; "XF86MonBrightnessDown" = brightness "4%-"; "XF86MonBrightnessUp" = brightness "4%+"; "XF86AudioPlay" = playerctl "play-pause"; "XF86AudioNext" = playerctl "next"; "XF86AudioPrev" = playerctl "previous"; # Exit "${modifier}+Shift+e" = ''exec swaynag -t warning -m \ "You pressed the exit shortcut. Do you really want to exit sway? \ This will end your Wayland session." -b "Yes, exit sway" "swaymsg exit" ''; # Workspaces "${modifier}+1" = "workspace 1:browser"; "${modifier}+2" = "workspace 2:terminal"; "${modifier}+3" = "workspace 3:code"; "${modifier}+4" = "workspace 4:files"; "${modifier}+5" = "workspace 5:discord"; "${modifier}+6" = "workspace 6:settings"; "${modifier}+Shift+1" = "move container to workspace 1:browser"; "${modifier}+Shift+2" = "move container to workspace 2:terminal"; "${modifier}+Shift+3" = "move container to workspace 3:code"; "${modifier}+Shift+4" = "move container to workspace 4:files"; "${modifier}+Shift+5" = "move container to workspace 5:discord"; "${modifier}+Shift+6" = "move container to workspace 6:settings"; }; output."*" = { bg = "${../../../assets/background.png} fill"; }; }; }; }