blob: ed4392948d8a3482eaaa285901c4baa947c43f8b [file] [log] [blame]
Skyler Greya3261d12022-05-24 21:05:22 +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 Turnerdb486c92022-03-06 10:48:24 +000043 wayland.windowManager.sway = {
44 enable = true;
45 wrapperFeatures.gtk = true;
Skyler Turnerf2a88392022-03-06 21:08:15 +000046
Skyler Turnerbb530ed2022-03-15 14:04:39 +000047 config = rec {
Skyler Turnerf2a88392022-03-06 21:08:15 +000048 assigns = {};
49 bars = [];
50 colors = {};
Skyler Turnerfe471d32022-03-07 13:16:17 +000051 defaultWorkspace = null;
52 down = "j";
53 floating = {};
54 focus = {};
55 fonts = {};
56 gaps = {
Skyler Turner801a9a82022-03-07 13:40:41 +000057 inner = 10;
Skyler Turner89be0062022-03-07 21:37:09 +000058 top = -10;
Skyler Turner1bd708a2022-03-07 13:44:27 +000059 outer = 0;
Skyler Turnera076a832022-03-09 09:42:54 +000060 smartGaps = false;
Skyler Turnerfe471d32022-03-07 13:16:17 +000061 };
Skyler Turnerb1fef9e2022-03-07 13:39:14 +000062 input = {
Skyler Turnera9227fd2022-03-07 13:48:39 +000063 "type:touchpad" = {
Skyler Turnerf277cf62022-03-07 13:49:14 +000064 dwt = "enabled";
65 tap = "enabled";
66 natural_scroll = "enabled";
Skyler Turner42bc3662022-03-09 13:33:14 +000067 middle_emulation = "enabled";
Skyler Turnera9227fd2022-03-07 13:48:39 +000068 events = "disabled_on_external_mouse";
69 };
70 "type:keyboard" = {
71 xkb_layout = "gb";
72 };
Skyler Turner6dceae22022-03-16 08:59:08 +000073 "type:tablet_tool" = {
Skyler Turner85299c42022-03-16 08:55:33 +000074 map_to_output = "eDP-1";
75 };
Skyler Turnerb1fef9e2022-03-07 13:39:14 +000076 };
Skyler Turnerb8a61992022-03-15 10:32:51 +000077 keybindings = lib.mkOptionDefault {
Skyler Greyc711df62022-05-21 01:06:15 +010078 "${modifier}+l" = "exec /usr/bin/env wlogout -c 5 -r 5 -p layer-shell -l ${wlogoutConfigFile}"; # "exec /usr/bin/env swaylock -c 000000";
Skyler Greyb087aa02022-05-25 23:07:48 +010079 "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";
Skyler Grey704c5f02022-05-26 00:13:06 +010083 "XF86MonBrightnessUp" = "exec light -A 3 && light -G | cut -d'.' -f1 > $WOBSOCK";
84 "XF86MonBrightnessDown" = "exec light -U 3 && light -G | cut -d'.' -f1 > $WOBSOCK";
Skyler Grey4f0697d2022-05-26 00:16:54 +010085 "${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";
Skyler Grey2826c142022-05-20 14:18:06 +010090 "${modifier}+Shift+s" = "exec grim -g \"$(slurp)\" - | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | wl-copy";
Skyler Grey0509cd82022-05-21 20:27:56 +010091 "${modifier}+g" = "sticky toggle";
Skyler Greye12caca2022-05-28 21:21:11 +010092 "${modifier}+k" = "exec wl-copy -c";
Skyler Grey0f2c8382022-05-24 13:15:50 +010093 "${modifier}+minus" = "exec ${./sway/show-menu.sh}";
Skyler Grey5b960582022-05-24 16:36:47 +010094 "Print" = "exec grim - | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | wl-copy";
95 "${modifier}+Print" = "exec ${./sway/toggle-backlight.sh}";
Skyler Turnerb8a61992022-03-15 10:32:51 +000096 };
Skyler Turnerb1fef9e2022-03-07 13:39:14 +000097 keycodebindings = {};
98 left = "h";
99 menu = "/usr/bin/env rofi -show combi";
100 modes = {
101 resize = {
102 Down = "resize grow height 10 px";
103 Escape = "mode default";
104 Left = "resize shrink width 10 px";
105 Return = "mode default";
106 Right = "resize grow width 10 px";
107 Up = "resize shrink height 10 px";
108 h = "resize shrink width 10 px";
109 j = "resize grow height 10 px";
110 k = "resize shrink height 10 px";
111 l = "resize grow width 10 px";
112 };
113 };
114 modifier = "Mod4";
115 output = {
116 HDMI-A-2 = {
117 resolution = "3840x2160";
Skyler Turnerc3ab3c22022-04-20 09:15:08 +0100118 #position = "1920,0";
119 position = "0,0";
Skyler Grey7ad4d422022-05-25 19:53:03 +0100120 bg = "${./sway/background.png} fill";
Skyler Turnerb1fef9e2022-03-07 13:39:14 +0000121 };
122 eDP-1 = {
123 resolution = "1920x1080";
Skyler Turnerc3ab3c22022-04-20 09:15:08 +0100124 #position = "0,1522";
125 position = "0,2160";
Skyler Turnerb1fef9e2022-03-07 13:39:14 +0000126 };
Skyler Turnerc6af35b2022-03-09 00:16:45 +0000127 "*" = {
Skyler Turnerc6af35b2022-03-09 00:16:45 +0000128 };
Skyler Turnerb1fef9e2022-03-07 13:39:14 +0000129 };
130 right = "l";
131 seat = {
132 "*" = {
133 hide_cursor = "when-typing enable";
134 };
135 };
Skyler Turnerb254c9d2022-05-14 00:24:37 +0100136 startup = [
137 { command = "dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK"; }
Skyler Grey8db57a12022-05-26 08:15:42 +0100138 { command = "\"pkill swaync; pkill waybar; ${pkgs-unstable.swaynotificationcenter}/bin/swaync & waybar\""; always = true; }
Skyler Grey300ec992022-06-04 07:40:16 +0100139 { command = "\"pkill glpaper; ${pkgs-unstable.glpaper}/bin/glpaper eDP-1 ${./sway/shader.glsl} -F -W 1920 -H 1080\""; always = true; }
Skyler Grey704c5f02022-05-26 00:13:06 +0100140 { command = "light -N 1"; always = false; }
Skyler Grey8db57a12022-05-26 08:15:42 +0100141 { command = "\"pkill wob; rm -f $WOBSOCK && mkfifo $WOBSOCK && tail -f $WOBSOCK | wob --output='*'\""; always = true; }
Skyler Turnerb254c9d2022-05-14 00:24:37 +0100142 ];
Skyler Grey63786912022-05-20 11:31:40 +0100143 terminal = "kitty";
Skyler Turnerb1fef9e2022-03-07 13:39:14 +0000144 up = "k";
145 window = {};
146 workspaceAutoBackAndForth = true;
147 workspaceLayout = "default";
148 workspaceOutputAssign = [];
149 };
150
Skyler Grey6d486f12022-05-24 18:48:33 +0100151 extraConfig = ''
152 set $WOBSOCK $XDG_RUNTIME_DIR/wob.sock
Skyler Grey6d486f12022-05-24 18:48:33 +0100153 '';
154
Skyler Turnerb1fef9e2022-03-07 13:39:14 +0000155 extraSessionCommands = ''
156 export SDL_VIDEODRIVER=wayland
157 # needs qt5.qtwayland in systemPackages
158 export QT_QPA_PLATFORM=wayland
159 export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
160 # Fix for some Java AWT applications (e.g. Android Studio),
161 # use this if they aren't displayed properly:
162 export _JAVA_AWT_WM_NONREPARENTING=1
163 '';
164
165 swaynag = {
Skyler Turner36510212022-03-07 23:13:14 +0000166 enable = true;
167 settings = {
Skyler Turnerd0a8f5c2022-03-07 23:16:01 +0000168 "<config>" = {
169 background = "#ffffff99";
170 border-bottom = "#00000000";
171 button-background = "#ffffffcc";
Skyler Turner4ea60622022-03-07 23:24:22 +0000172 button-padding = 10;
Skyler Turnerd0a8f5c2022-03-07 23:16:01 +0000173 button-border-size = 0;
174 };
Skyler Turner7b341db2022-03-07 23:17:23 +0000175
176 warning = {
Skyler Turnere957a372022-03-07 23:18:27 +0000177 background = "#ffffff99";
Skyler Turner6222f752022-03-07 23:21:23 +0000178 border-bottom = "#00000000";
Skyler Turnerf24ef5e2022-03-07 23:26:30 +0000179 button-background = "#ffff00";
180 };
181
182 error = {
183 background = "#ffffff99";
184 border-bottom = "#00000000";
Skyler Turnere609f0a2022-03-07 23:25:17 +0000185 button-background = "#ff0000";
Skyler Turner7b341db2022-03-07 23:17:23 +0000186 };
Skyler Turnerf24ef5e2022-03-07 23:26:30 +0000187
188 green = {
189 background = "#ffffff99";
190 border-bottom = "#00000000";
Skyler Turnerc4d1c0b2022-03-07 23:28:58 +0000191 button-background = "#00b300";
Skyler Turnerf24ef5e2022-03-07 23:26:30 +0000192 };
193
194 blue = {
195 background = "#ffffff99";
196 border-bottom = "#00000000";
Skyler Turnerc4d1c0b2022-03-07 23:28:58 +0000197 button-background = "#0000ff";
Skyler Turnerf24ef5e2022-03-07 23:26:30 +0000198 };
Skyler Turner36510212022-03-07 23:13:14 +0000199 };
Skyler Turner07eb3d12022-03-06 21:08:29 +0000200 };
Skyler Turnereda726a2022-03-07 00:23:17 +0000201
202 systemdIntegration = true;
Skyler Turnerdb486c92022-03-06 10:48:24 +0000203 };
204
205 home.packages = with pkgs; [
206 swaylock
207 swayidle
208 wl-clipboard
Skyler Grey0509cd82022-05-21 20:27:56 +0100209 bc
Skyler Greya0d78742022-05-24 12:07:30 +0100210 jq
Skyler Grey35c05c82022-05-24 16:54:30 +0100211 pulseaudio
212 pamixer
Skyler Grey300ec992022-06-04 07:40:16 +0100213 pkgs-unstable.glpaper
Skyler Turner9dfac612022-03-06 10:48:57 +0000214 ];
Skyler Turnerdb486c92022-03-06 10:48:24 +0000215
Skyler Turnerd3b70682022-03-06 23:19:45 +0000216 programs.zsh.profileExtra = ''
217 if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
Skyler Grey8721b652022-05-31 20:59:22 +0100218 exec systemd-cat -t sway sway --unsupported-gpu
Skyler Turnerd3b70682022-03-06 23:19:45 +0000219 fi
220 '';
Skyler Turnerc6af35b2022-03-09 00:16:45 +0000221}