blob: bb829a03c4f98c2c20dc9fc173a1a2b1973fd60f [file] [log] [blame]
Skyler Grey715e0072022-08-03 17:53:26 +01001{ pkgs, pkgs-unstable, lib, ... }: let
Skyler Greyc711df62022-05-21 01:06:15 +01002 wlogoutConfig = [
3 {
4 label = "lock";
5 action = "swaylock -c 000000 -i ${./sway/lockscreen.png}";
6 text = "Lock";
7 keybind = "l";
8 }
9 {
10 label = "hibernate";
11 action = "swaylock -c 000000 -i ${./sway/lockscreen.png} -f && systemctl hibernate";
12 text = "Hibernate";
13 keybind = "h";
14 }
15 {
16 label = "logout";
17 action = "loginctl terminate-user $USER";
18 text = "Logout";
19 keybind = "e";
20 }
21 {
22 label = "shutdown";
23 action = "systemctl poweroff";
24 text = "Shutdown";
25 keybind = "s";
26 }
27 {
28 label = "suspend";
29 action = "swaylock -c 000000 -i ${./sway/lockscreen.png} -f && systemctl suspend";
30 text = "Suspend";
31 keybind = "u";
32 }
33 {
34 label = "reboot";
35 action = "systemctl reboot";
36 text = "Reboot";
37 keybind = "r";
38 }
39 ];
Skyler Greycfb1c112022-05-21 01:14:15 +010040 wlogoutJson = (builtins.toJSON wlogoutConfig);
Skyler Grey412a3c12022-05-21 01:16:46 +010041 wlogoutConfigFile = pkgs.writeText "wlogout-layout.layout" (builtins.substring 1 ((builtins.stringLength wlogoutJson) - 2) wlogoutJson);
Skyler Greyc711df62022-05-21 01:06:15 +010042in {
Skyler Grey5d6fe4d2022-06-16 20:56:02 +010043 wayland.windowManager.sway = {
44 enable = true;
45 wrapperFeatures.gtk = true;
Skyler Turnerf2a88392022-03-06 21:08:15 +000046
Skyler Grey5d6fe4d2022-06-16 20:56:02 +010047 config = rec {
48 assigns = {};
49 bars = [];
50 colors = {};
51 defaultWorkspace = null;
52 down = "j";
53 floating = {};
54 focus = {};
55 fonts = {};
56 gaps = {
57 inner = 10;
58 top = -10;
59 outer = 0;
60 smartGaps = false;
61 };
62 input = {
63 "type:touchpad" = {
Skyler Greyce692382022-08-06 10:50:31 +010064 dwt = "enabled";
65 tap = "enabled";
66 natural_scroll = "enabled";
67 middle_emulation = "enabled";
68 events = "disabled_on_external_mouse";
Skyler Grey5d6fe4d2022-06-16 20:56:02 +010069 };
70 "type:keyboard" = {
Skyler Greyce692382022-08-06 10:50:31 +010071 xkb_layout = "gb";
Skyler Grey5d6fe4d2022-06-16 20:56:02 +010072 };
73 "type:tablet_tool" = {
Skyler Greyce692382022-08-06 10:50:31 +010074 map_to_output = "eDP-1";
Skyler Grey5d6fe4d2022-06-16 20:56:02 +010075 };
Skyler Greyce692382022-08-06 10:50:31 +010076 };
77 keybindings = lib.mkOptionDefault {
Skyler Grey5d6fe4d2022-06-16 20:56:02 +010078 "${modifier}+l" = "exec /usr/bin/env wlogout -c 5 -r 5 -p layer-shell -l ${wlogoutConfigFile}"; # "exec /usr/bin/env swaylock -c 000000";
79 "XF86AudioRaiseVolume" = "exec pamixer -ui 5 && ( pamixer --get-mute && expr \"$(pamixer --get-volume)\" + 100 > $WOBSOCK ) || pamixer --get-volume > $WOBSOCK";
80 "XF86AudioLowerVolume" = "exec pamixer -ud 5 && ( pamixer --get-mute && expr \"$(pamixer --get-volume)\" + 100 > $WOBSOCK ) || pamixer --get-volume > $WOBSOCK";
81 "XF86AudioMute" = "exec pamixer --toggle-mute && ( pamixer --get-mute && expr \"$(pamixer --get-volume)\" + 100 > $WOBSOCK ) || pamixer --get-volume > $WOBSOCK";
82 "XF86AudioMicMute" = "exec pamixer --toggle-mute --default-source && ( pamixer --get-mute --default-source && expr \"$(pamixer --default-source --get-volume)\" + 100 > $WOBSOCK ) || pamixer --default-source --get-volume > $WOBSOCK";
83 "XF86MonBrightnessUp" = "exec light -A 3 && light -G | cut -d'.' -f1 > $WOBSOCK";
84 "XF86MonBrightnessDown" = "exec light -U 3 && light -G | cut -d'.' -f1 > $WOBSOCK";
85 "${modifier}+XF86AudioRaiseVolume" = "exec pamixer --default-source -ui 5 && ( pamixer --get-mute --default-source && expr \"$(pamixer --default-source --get-volume)\" + 100 > $WOBSOCK ) || pamixer --default-source --get-volume > $WOBSOCK";
86 "${modifier}+XF86AudioLowerVolume" = "exec pamixer --default-source -ud 5 && ( pamixer --get-mute --default-source && expr \"$(pamixer --default-source --get-volume)\" + 100 > $WOBSOCK ) || pamixer --get-volume --default-source > $WOBSOCK";
87 "${modifier}+XF86AudioMute" = "exec pamixer --toggle-mute --default-source && ( pamixer --get-mute --default-source && expr \"$(pamixer --default-source --get-volume)\" + 100 > $WOBSOCK ) || pamixer --default-source --get-volume > $WOBSOCK";
88 "${modifier}+XF86MonBrightnessUp" = "exec light -A 6 && light -G | cut -d'.' -f1 > $WOBSOCK";
89 "${modifier}+XF86MonBrightnessDown" = "exec light -U 6 && light -G | cut -d'.' -f1 > $WOBSOCK";
90 "${modifier}+Shift+s" = "exec grim -g \"$(slurp)\" - | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | wl-copy";
91 "${modifier}+g" = "sticky toggle";
92 "${modifier}+k" = "exec wl-copy -c";
93 "${modifier}+minus" = "exec ${./sway/show-menu.sh}";
94 "Print" = "exec grim - | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | wl-copy";
95 "${modifier}+Print" = "exec ${./sway/toggle-backlight.sh}";
Skyler Grey88a88922022-06-16 21:05:56 +010096 "${modifier}+f" = "maximize toggle";
Skyler Greyce692382022-08-06 10:50:31 +010097 };
98 keycodebindings = {};
99 left = "h";
100 menu = "/usr/bin/env rofi -show combi";
101 modes = {
102 resize = {
103 Down = "resize grow height 10 px";
104 Escape = "mode default";
105 Left = "resize shrink width 10 px";
106 Return = "mode default";
107 Right = "resize grow width 10 px";
108 Up = "resize shrink height 10 px";
109 h = "resize shrink width 10 px";
110 j = "resize grow height 10 px";
111 k = "resize shrink height 10 px";
112 l = "resize grow width 10 px";
Skyler Grey5d6fe4d2022-06-16 20:56:02 +0100113 };
Skyler Greyce692382022-08-06 10:50:31 +0100114 };
115 modifier = "Mod4";
116 output = {
117 HDMI-A-2 = {
118 resolution = "3840x2160";
119 #position = "1920,0";
120 position = "0,0";
121 bg = "${./sway/background.png} fill";
122 };
123 eDP-1 = {
124 resolution = "1920x1080";
125 #position = "0,1522";
126 position = "0,2160";
127 };
128 "*" = {
129 };
130 };
131 right = "l";
132 seat = {
133 "*" = {
134 hide_cursor = "when-typing enable";
135 };
136 };
137 startup = [
138 { command = "dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK"; }
139 { command = "\"pkill swaync; pkill waybar; ${pkgs-unstable.swaynotificationcenter}/bin/swaync & waybar\""; always = true; }
140 { command = "\"pkill glpaper; ${pkgs-unstable.glpaper}/bin/glpaper eDP-1 ${./sway/shader.glsl} -F -W 1920 -H 1080\""; always = true; }
141 { command = "light -N 1"; always = false; }
142 { command = "\"pkill wob; rm -f $WOBSOCK && mkfifo $WOBSOCK && tail -f $WOBSOCK | wob --output='*'\""; always = true; }
143 ];
144 terminal = "kitty";
145 up = "k";
146 window = {};
147 workspaceAutoBackAndForth = true;
148 workspaceLayout = "default";
149 workspaceOutputAssign = [];
150 };
Skyler Turnerb1fef9e2022-03-07 13:39:14 +0000151
Skyler Greyce692382022-08-06 10:50:31 +0100152 extraConfig = ''
153 set $WOBSOCK $XDG_RUNTIME_DIR/wob.sock
154 '';
Skyler Grey6d486f12022-05-24 18:48:33 +0100155
Skyler Greyce692382022-08-06 10:50:31 +0100156 extraSessionCommands = ''
157 export SDL_VIDEODRIVER=wayland
158 # needs qt5.qtwayland in systemPackages
159 export QT_QPA_PLATFORM=wayland
160 export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
161 # Fix for some Java AWT applications (e.g. Android Studio),
162 # use this if they aren't displayed properly:
163 export _JAVA_AWT_WM_NONREPARENTING=1
164 '';
Skyler Turnerb1fef9e2022-03-07 13:39:14 +0000165
Skyler Greyce692382022-08-06 10:50:31 +0100166 swaynag = {
167 enable = true;
168 settings = {
169 "<config>" = {
170 background = "#ffffff99";
171 border-bottom = "#00000000";
172 button-background = "#ffffffcc";
173 button-padding = 10;
174 button-border-size = 0;
175 };
Skyler Turner7b341db2022-03-07 23:17:23 +0000176
Skyler Greyce692382022-08-06 10:50:31 +0100177 warning = {
178 background = "#ffffff99";
179 border-bottom = "#00000000";
180 button-background = "#ffff00";
181 };
Skyler Turnerf24ef5e2022-03-07 23:26:30 +0000182
Skyler Greyce692382022-08-06 10:50:31 +0100183 error = {
184 background = "#ffffff99";
185 border-bottom = "#00000000";
186 button-background = "#ff0000";
187 };
Skyler Turnerf24ef5e2022-03-07 23:26:30 +0000188
Skyler Greyce692382022-08-06 10:50:31 +0100189 green = {
190 background = "#ffffff99";
191 border-bottom = "#00000000";
192 button-background = "#00b300";
193 };
Skyler Turnerf24ef5e2022-03-07 23:26:30 +0000194
Skyler Greyce692382022-08-06 10:50:31 +0100195 blue = {
196 background = "#ffffff99";
197 border-bottom = "#00000000";
198 button-background = "#0000ff";
199 };
200 };
201 };
Skyler Grey5d6fe4d2022-06-16 20:56:02 +0100202
Skyler Greyce692382022-08-06 10:50:31 +0100203 systemdIntegration = true;
204 };
Skyler Turnereda726a2022-03-07 00:23:17 +0000205
Skyler Greyce692382022-08-06 10:50:31 +0100206 home.packages = with pkgs; [
207 swaylock
208 swayidle
209 wl-clipboard
210 bc
211 jq
212 pulseaudio
213 pamixer
214 pkgs-unstable.glpaper
215 ];
Skyler Turnerdb486c92022-03-06 10:48:24 +0000216
Skyler Greyce692382022-08-06 10:50:31 +0100217 programs.zsh.profileExtra = ''
218 if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
219 exec systemd-cat -t sway sway --unsupported-gpu
220 fi
221 '';
222}