sway.scm (8115B)
1 (define-module (home lukejw sway) 2 #:use-module (home lukejw scripts) 3 #:use-module (gnu home services sway) 4 #:use-module (gnu packages gnome-xyz) 5 #:use-module (gnu packages image) 6 #:use-module (gnu packages linux) 7 #:use-module (gnu packages lxqt) 8 #:use-module (gnu packages polkit) 9 #:use-module (gnu packages pulseaudio) 10 #:use-module (gnu packages qt) 11 #:use-module (gnu packages terminals) 12 #:use-module (gnu packages wm) 13 #:use-module (gnu packages xdisorg) 14 #:use-module (gnu system keyboard) 15 #:use-module (guix build-system copy) 16 #:use-module (guix gexp) 17 #:use-module (guix git-download) 18 #:use-module (guix packages) 19 #:use-module (mt packages desktop) 20 #:export (%sway-configuration)) 21 22 (define %sway-packages 23 (list sway-with-options 24 qtwayland 25 bibata-cursor-theme 26 foot 27 tofi 28 pulseaudio 29 brightnessctl 30 i3blocks 31 lxqt-policykit 32 wlsunset 33 grim 34 slurp 35 wl-clipboard)) 36 37 (define %sway-inputs 38 (list 39 (sway-input 40 (identifier "1:1:AT_Translated_Set_2_keyboard") 41 (layout (keyboard-layout "us,us" ",dvp" 42 #:options '("grp:alt_shift_toggle")))))) 43 44 (define %sway-variables 45 `((mod . "Mod4") 46 (left . "Left") 47 (down . "Down") 48 (up . "Up") 49 (right . "Right") 50 ;; Launcher 51 (menu . "tofi-drun --terminal footclient | xargs swaymsg exec --") 52 ;; Common programs 53 (web . "librewolf") 54 (mail . "footclient -T \"Mail\" aerc") 55 (file . "footclient -T \"File Manager\" lf") 56 (term . "footclient") 57 ;; Misc. controls 58 (pactl . "pactl") 59 (bctl . "brightnessctl -q") 60 ;; Color palette (Flexoki light) 61 (bg . "#FFFCF0") 62 (bg-2 . "#F2F0E5") 63 (ui . "#E6E4D9") 64 (ui-2 . "#DAD8CE") 65 (ui-3 . "#CECDC3") 66 (tx-3 . "#B7B5AC") 67 (tx-2 . "#6F6E69") 68 (tx . "#100F0F") 69 (re . "#AF3029") 70 (re-2 . "#D14D41"))) 71 72 (define %sway-theme 73 (list "font monospace 14" 74 "client.focused $ui-3 $bg $tx $tx $ui-3" 75 "client.focused_inactive $ui-2 $bg-2 $tx-2 $tx-2 $ui-2" 76 "client.unfocused $ui $bg-2 $tx-3 $tx-3 $ui" 77 "client.urgent $ui-3 $re $tx $tx $ui-3"' 78 "default_border normal 2" 79 "titlebar_border_thickness 2" 80 "gaps inner 4" 81 "gaps outer 4")) 82 83 (define %sway-modes 84 (list (sway-mode 85 (mode-name "resize") 86 (keybindings 87 '(($left . "resize shrink width 10px") 88 ($down . "resize grow height 10px") 89 ($up . "resize shrink height 10px") 90 ($right . "resize grow width 10px") 91 (Return . "mode \"default\"") 92 (Escape . "mode \"default\"")))))) 93 94 (define %sway-bar 95 (sway-bar 96 (position 'top) 97 (colors 98 (sway-color 99 (background "$bg-2") 100 (statusline "$tx\n separator $tx-3") 101 (focused-workspace 102 (sway-border-color 103 (border "$ui-3") 104 (background "$bg") 105 (text "$tx"))) 106 (active-workspace 107 (sway-border-color 108 (border "$ui-2") 109 (background "$bg-2") 110 (text "$tx-2"))) 111 (inactive-workspace 112 (sway-border-color 113 (border "$ui") 114 (background "$bg-2") 115 (text "$tx-3"))) 116 (urgent-workspace 117 (sway-border-color 118 (border "$ui") 119 (background "$re") 120 (text "$tx"))))) 121 ;; TODO: Make this suck less 122 (status-command "i3blocks\n separator_symbol \" \"\n gaps 8\n status_padding 0\n status_edge_padding 0"))) 123 124 (define %sway-keybindings 125 `(;; Meta controls 126 ($mod+Shift+c . "reload") 127 ;; Launcher controls 128 ($mod+d . "exec $menu") 129 ;; Common programs 130 ($mod+w . "exec $web") 131 ($mod+m . "exec $mail") 132 ($mod+f . "exec $file") 133 ($mod+Return . "exec $term") 134 ;; Exit / poweroff 135 ;; TODO: Migrate to gexp->script (it makes my life easier) 136 ($mod+l . ,#~(string-append "exec " #$scripts "/bin/tofi-loginctl-prompt.sh")) 137 ($mod+Shift+l . ,#~(string-append "exec " #$scripts "/bin/tofi-exit-sway-prompt.sh")) 138 ;; Password management 139 ($mod+p . "exec sta.sh quick") 140 ($mod+Shift+p . "exec sta.sh") 141 ($mod+Alt+p . "exec sta.sh modify") 142 ;; Window controls 143 ($mod+Shift+q . "kill") 144 ($mod+$left . "focus left") 145 ($mod+$down . "focus down") 146 ($mod+$up . "focus up") 147 ($mod+$right . "focus right") 148 ($mod+Shift+$left . "move left") 149 ($mod+Shift+$down . "move down") 150 ($mod+Shift+$up . "move up") 151 ($mod+Shift+$right . "move right") 152 ($mod+1 . "workspace number 1") 153 ($mod+2 . "workspace number 2") 154 ($mod+3 . "workspace number 3") 155 ($mod+4 . "workspace number 4") 156 ($mod+5 . "workspace number 5") 157 ($mod+6 . "workspace number 6") 158 ($mod+7 . "workspace number 7") 159 ($mod+8 . "workspace number 8") 160 ($mod+9 . "workspace number 9") 161 ($mod+Shift+1 . "move container to workspace number 1") 162 ($mod+Shift+2 . "move container to workspace number 2") 163 ($mod+Shift+3 . "move container to workspace number 3") 164 ($mod+Shift+4 . "move container to workspace number 4") 165 ($mod+Shift+5 . "move container to workspace number 5") 166 ($mod+Shift+6 . "move container to workspace number 6") 167 ($mod+Shift+7 . "move container to workspace number 7") 168 ($mod+Shift+8 . "move container to workspace number 8") 169 ($mod+Shift+9 . "move container to workspace number 9") 170 ($mod+b . "splith") 171 ($mod+v . "splitv") 172 ($mod+Shift+s . "layout stacking") 173 ($mod+Shift+w . "layout tabbed") 174 ($mod+Shift+e . "layout toggle split") 175 ($mod+Shift+f . "fullscreen") 176 ($mod+Shift+space . "floating toggle") 177 ($mod+space . "focus mode_toggle") 178 ($mod+a . "focus parent") 179 ($mod+Shift+minus . "move scratchpad") 180 ($mod+minus . "scratchpad show") 181 ($mod+r . "mode \"resize\"") 182 ;; Audio controls 183 (XF86AudioMute . "exec $pactl set-sink-mute \\@DEFAULT_SINK@ toggle") 184 (XF86AudioLowerVolume . "exec $pactl set-sink-volume \\@DEFAULT_SINK@ -5%") 185 (XF86AudioRaiseVolume . "exec $pactl set-sink-volume \\@DEFAULT_SINK@ +5%") 186 ;; Brightness controls 187 (XF86MonBrightnessDown . "exec $bctl s 15-") 188 (XF86MonBrightnessUp . "exec $bctl s +15") 189 ;; Screenshot controls 190 (Print . "exec grim") 191 (XF86SelectiveScreenshot . "exec grim -g \"$(slurp)\""))) 192 193 (define %sway-outputs 194 (list ;; Set background image for external monitors 195 (sway-output 196 (identifier '*) 197 (background (local-file "bg1.png"))) 198 ;; Set background image for laptop monitor 199 (sway-output 200 (identifier 'eDP-1) 201 (background (local-file "bg0.png"))) 202 ;; Work monitor(s) 203 (sway-output 204 (identifier "Dell Inc. DELL P2314H 7R1K343NCB7S") 205 (resolution "1920x1080@60Hz") 206 (extra-content 207 (list "scale 1"))) 208 (sway-output 209 (identifier "Dell Inc. DELL P2214H KW14V53238VB") 210 (resolution "1920x1080@60Hz") 211 (extra-content 212 (list "scale 1"))))) 213 214 (define %sway-startup-programs 215 (list 216 "foot --server" 217 "wlsunset -S 07:00 -s 19:30 -d 1800 -t 1000" 218 "lxqt-policykit-agent")) 219 220 (define %sway-configuration 221 (sway-configuration 222 (variables %sway-variables) 223 (keybindings %sway-keybindings) 224 (gestures '()) 225 (packages %sway-packages) 226 (inputs %sway-inputs) 227 (outputs %sway-outputs) 228 (bar %sway-bar) 229 (modes %sway-modes) 230 (startup-programs %sway-startup-programs) 231 (extra-content (append 232 (list 233 ;; Trying to maintain a pure wayland setup 234 "xwayland enable" 235 ;; Set cursor theme 236 "seat seat0 xcursor_theme Bibata-Modern-Ice 24" 237 ;; This fixes lxqt-policykit being weird 238 "for_window [title=\"Authentication Required\"] floating enable" 239 ;; Make my camera floating by default 240 "for_window [title=\"/dev/video0\"] floating enable") 241 %sway-theme)))) 242