blob: 4c776a85eeceef52ae47345cf1c3cea76346f981 [file] [log] [blame]
Skyler Greyc711df62022-05-21 01:06:15 +01001{ pkgs, lib, ... }: let
2 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);
41 wlogoutConfigFile = pkgs.writeText "wlogout-layout.layout" (builtins.substring 1 ((builtins.stringLength wlogoutJson) - 1) 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 Turnerbb530ed2022-03-15 14:04:39 +000079 "XF86AudioRaiseVolume" = "exec volumectl -u up";
80 "XF86AudioLowerVolume" = "exec volumectl -u down";
81 "XF86AudioMute" = "exec volumectl toggle-mute";
82 "XF86AudioMicMute" = "exec volumectl -m toggle-mute";
83 "XF86MonBrightnessUp" = "exec lightctl up";
84 "XF86MonBrightnessDown" = "exec lightctl down";
Skyler Grey2826c142022-05-20 14:18:06 +010085 "${modifier}+Shift+s" = "exec grim -g \"$(slurp)\" - | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | wl-copy";
Skyler Turnerb8a61992022-03-15 10:32:51 +000086 };
Skyler Turnerb1fef9e2022-03-07 13:39:14 +000087 keycodebindings = {};
88 left = "h";
89 menu = "/usr/bin/env rofi -show combi";
90 modes = {
91 resize = {
92 Down = "resize grow height 10 px";
93 Escape = "mode default";
94 Left = "resize shrink width 10 px";
95 Return = "mode default";
96 Right = "resize grow width 10 px";
97 Up = "resize shrink height 10 px";
98 h = "resize shrink width 10 px";
99 j = "resize grow height 10 px";
100 k = "resize shrink height 10 px";
101 l = "resize grow width 10 px";
102 };
103 };
104 modifier = "Mod4";
105 output = {
106 HDMI-A-2 = {
107 resolution = "3840x2160";
Skyler Turnerc3ab3c22022-04-20 09:15:08 +0100108 #position = "1920,0";
109 position = "0,0";
Skyler Turnerb1fef9e2022-03-07 13:39:14 +0000110 };
111 eDP-1 = {
112 resolution = "1920x1080";
Skyler Turnerc3ab3c22022-04-20 09:15:08 +0100113 #position = "0,1522";
114 position = "0,2160";
Skyler Turnerb1fef9e2022-03-07 13:39:14 +0000115 };
Skyler Turnerc6af35b2022-03-09 00:16:45 +0000116 "*" = {
Skyler Turner202e73d2022-03-09 00:23:39 +0000117 bg = "${./sway/background.png} fill";
Skyler Turnerc6af35b2022-03-09 00:16:45 +0000118 };
Skyler Turnerb1fef9e2022-03-07 13:39:14 +0000119 };
120 right = "l";
121 seat = {
122 "*" = {
123 hide_cursor = "when-typing enable";
124 };
125 };
Skyler Turnerb254c9d2022-05-14 00:24:37 +0100126 startup = [
127 { command = "dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK"; }
128 ];
Skyler Grey63786912022-05-20 11:31:40 +0100129 terminal = "kitty";
Skyler Turnerb1fef9e2022-03-07 13:39:14 +0000130 up = "k";
131 window = {};
132 workspaceAutoBackAndForth = true;
133 workspaceLayout = "default";
134 workspaceOutputAssign = [];
135 };
136
137 extraSessionCommands = ''
138 export SDL_VIDEODRIVER=wayland
139 # needs qt5.qtwayland in systemPackages
140 export QT_QPA_PLATFORM=wayland
141 export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
142 # Fix for some Java AWT applications (e.g. Android Studio),
143 # use this if they aren't displayed properly:
144 export _JAVA_AWT_WM_NONREPARENTING=1
145 '';
146
147 swaynag = {
Skyler Turner36510212022-03-07 23:13:14 +0000148 enable = true;
149 settings = {
Skyler Turnerd0a8f5c2022-03-07 23:16:01 +0000150 "<config>" = {
151 background = "#ffffff99";
152 border-bottom = "#00000000";
153 button-background = "#ffffffcc";
Skyler Turner4ea60622022-03-07 23:24:22 +0000154 button-padding = 10;
Skyler Turnerd0a8f5c2022-03-07 23:16:01 +0000155 button-border-size = 0;
156 };
Skyler Turner7b341db2022-03-07 23:17:23 +0000157
158 warning = {
Skyler Turnere957a372022-03-07 23:18:27 +0000159 background = "#ffffff99";
Skyler Turner6222f752022-03-07 23:21:23 +0000160 border-bottom = "#00000000";
Skyler Turnerf24ef5e2022-03-07 23:26:30 +0000161 button-background = "#ffff00";
162 };
163
164 error = {
165 background = "#ffffff99";
166 border-bottom = "#00000000";
Skyler Turnere609f0a2022-03-07 23:25:17 +0000167 button-background = "#ff0000";
Skyler Turner7b341db2022-03-07 23:17:23 +0000168 };
Skyler Turnerf24ef5e2022-03-07 23:26:30 +0000169
170 green = {
171 background = "#ffffff99";
172 border-bottom = "#00000000";
Skyler Turnerc4d1c0b2022-03-07 23:28:58 +0000173 button-background = "#00b300";
Skyler Turnerf24ef5e2022-03-07 23:26:30 +0000174 };
175
176 blue = {
177 background = "#ffffff99";
178 border-bottom = "#00000000";
Skyler Turnerc4d1c0b2022-03-07 23:28:58 +0000179 button-background = "#0000ff";
Skyler Turnerf24ef5e2022-03-07 23:26:30 +0000180 };
Skyler Turner36510212022-03-07 23:13:14 +0000181 };
Skyler Turner07eb3d12022-03-06 21:08:29 +0000182 };
Skyler Turnereda726a2022-03-07 00:23:17 +0000183
184 systemdIntegration = true;
Skyler Turnerdb486c92022-03-06 10:48:24 +0000185 };
186
187 home.packages = with pkgs; [
188 swaylock
189 swayidle
190 wl-clipboard
Skyler Turnerbb530ed2022-03-15 14:04:39 +0000191 avizo
192 pamixer
193 brightnessctl
Skyler Turner9dfac612022-03-06 10:48:57 +0000194 ];
Skyler Turnerdb486c92022-03-06 10:48:24 +0000195
Skyler Turnerd3b70682022-03-06 23:19:45 +0000196 programs.zsh.profileExtra = ''
197 if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
198 exec systemd-cat -t sway sway
199 fi
200 '';
Skyler Turnerbb530ed2022-03-15 14:04:39 +0000201
202 systemd.user.services.avizo = {
Skyler Turner7b7b73d2022-03-15 14:05:20 +0000203 Install.WantedBy = [ "graphical-session.target" ];
Skyler Turnerbb530ed2022-03-15 14:04:39 +0000204 Service = {
205 ExecReload = "kill -SIGUSR2 \$MAINPID";
206 ExecStart = "${pkgs.avizo}/bin/avizo-service";
207 KillMode = "mixed";
208 Restart = "on-failure";
209 };
210 Unit = {
211 After = "graphical-session.target";
212 Description = "Notification daemon to show volume & brightness changes";
213 Documentation = "N/A (src/apps/personal/sway.nix)";
214 PartOf= "graphical-session.target";
215 };
216 };
Skyler Turnerc6af35b2022-03-09 00:16:45 +0000217}
Skyler Turnerbb530ed2022-03-15 14:04:39 +0000218