diff options
author | Minijackson <minijackson@riseup.net> | 2021-04-18 16:58:23 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2021-04-18 16:58:23 +0200 |
commit | 8ffe5ce23fa1548304a3fa25f2bd0e89837f5a0b (patch) | |
tree | cd0de6a4642b76b42002dae5291c307d30727bc6 /usecases/desktop/graphical/sway.nix | |
parent | 46ac3d5464712d6b0e0bee4ac62543abcbf2db2c (diff) | |
download | nixos-config-reborn-8ffe5ce23fa1548304a3fa25f2bd0e89837f5a0b.tar.gz nixos-config-reborn-8ffe5ce23fa1548304a3fa25f2bd0e89837f5a0b.zip |
revamp with nix flakes + desktop config
Diffstat (limited to 'usecases/desktop/graphical/sway.nix')
-rw-r--r-- | usecases/desktop/graphical/sway.nix | 263 |
1 files changed, 263 insertions, 0 deletions
diff --git a/usecases/desktop/graphical/sway.nix b/usecases/desktop/graphical/sway.nix new file mode 100644 index 0000000..6c5b2ed --- /dev/null +++ b/usecases/desktop/graphical/sway.nix | |||
@@ -0,0 +1,263 @@ | |||
1 | inputs: | ||
2 | |||
3 | { config, lib, pkgs, system, ... }: | ||
4 | let | ||
5 | globalConfig = config; | ||
6 | in | ||
7 | { | ||
8 | home-manager.users.minijackson = { config, ... }: { | ||
9 | wayland.windowManager.sway = { | ||
10 | enable = true; | ||
11 | |||
12 | extraSessionCommands = '' | ||
13 | # https://github.com/emersion/xdg-desktop-portal-wlr/issues/20 | ||
14 | export XDG_CURRENT_DESKTOP=sway | ||
15 | # https://github.com/emersion/xdg-desktop-portal-wlr/pull/11 | ||
16 | export XDG_SESSION_TYPE=wayland | ||
17 | |||
18 | export SDL_VIDEODRIVER=wayland | ||
19 | |||
20 | export QT_QPA_PLATFORM=wayland | ||
21 | export QT_WAYLAND_DISABLE_WINDOWDECORATION=1 | ||
22 | ''; | ||
23 | |||
24 | # Implemented below in startup, due to global import-environment failing | ||
25 | # when not specifying variables. | ||
26 | # | ||
27 | # TODO: make PR | ||
28 | #systemdIntegration = true; | ||
29 | wrapperFeatures.gtk = true; | ||
30 | |||
31 | config = { | ||
32 | # Using waybar | ||
33 | bars = [ ]; | ||
34 | |||
35 | bindkeysToCode = true; | ||
36 | |||
37 | colors = with globalConfig.theme.colors; { | ||
38 | focused = { | ||
39 | border = lightBackground; | ||
40 | background = lightBackground; | ||
41 | text = foreground; | ||
42 | indicator = dominant; | ||
43 | childBorder = dominant; | ||
44 | }; | ||
45 | |||
46 | focusedInactive = { | ||
47 | border = background; | ||
48 | background = background; | ||
49 | text = dimForeground; | ||
50 | indicator = dominant; | ||
51 | childBorder = background; | ||
52 | }; | ||
53 | |||
54 | unfocused = { | ||
55 | border = background; | ||
56 | background = background; | ||
57 | text = dimForeground; | ||
58 | indicator = dominant; | ||
59 | childBorder = background; | ||
60 | }; | ||
61 | |||
62 | urgent = { | ||
63 | border = brightRed; | ||
64 | background = brightRed; | ||
65 | text = foreground; | ||
66 | indicator = brightRed; | ||
67 | childBorder = brightRed; | ||
68 | }; | ||
69 | |||
70 | placeholder = { | ||
71 | border = background0; | ||
72 | background = background0; | ||
73 | text = foreground; | ||
74 | indicator = background0; | ||
75 | childBorder = background0; | ||
76 | }; | ||
77 | }; | ||
78 | |||
79 | floating.criteria = [ | ||
80 | { title = "Steam - News"; } | ||
81 | ]; | ||
82 | |||
83 | input = { | ||
84 | "1:1:AT_Translated_Set_2_keyboard" = { | ||
85 | xkb_layout = "fr"; | ||
86 | xkb_variant = "oss"; | ||
87 | xkb_options = "compose:caps"; | ||
88 | xkb_numlock = "enabled"; | ||
89 | }; | ||
90 | |||
91 | "1452:514:Alps_Electric_M2452" = { | ||
92 | xkb_layout = "fr"; | ||
93 | xkb_variant = "oss"; | ||
94 | xkb_options = "compose:caps,lv3:rwin_switch"; | ||
95 | xkb_numlock = "enabled"; | ||
96 | }; | ||
97 | |||
98 | "7764:8240:TypeMatrix.com_USB_Keyboard" = { | ||
99 | xkb_layout = "dvorak"; | ||
100 | xkb_options = "eurosign:e,compose:caps"; | ||
101 | }; | ||
102 | |||
103 | |||
104 | "1133:49948:Logitech_USB_Keyboard" = { | ||
105 | xkb_layout = "fr"; | ||
106 | xkb_variant = "oss"; | ||
107 | xkb_options = "eurosign:e,compose:caps"; | ||
108 | xkb_numlock = "enabled"; | ||
109 | }; | ||
110 | |||
111 | "1102:4639:DELL0817:00_044E:121F_Mouse" = { | ||
112 | scroll_method = "on_button_down"; | ||
113 | scroll_button = "button2"; | ||
114 | }; | ||
115 | }; | ||
116 | |||
117 | keybindings = | ||
118 | let | ||
119 | modifier = config.wayland.windowManager.sway.config.modifier; | ||
120 | in | ||
121 | lib.mkOptionDefault { | ||
122 | "${modifier}+ampersand" = "workspace 1"; | ||
123 | "${modifier}+eacute" = "workspace 2"; | ||
124 | "${modifier}+quotedbl" = "workspace 3"; | ||
125 | "${modifier}+apostrophe" = "workspace 4"; | ||
126 | "${modifier}+parenleft" = "workspace 5"; | ||
127 | "${modifier}+minus" = "workspace 6"; | ||
128 | "${modifier}+egrave" = "workspace 7"; | ||
129 | "${modifier}+underscore" = "workspace 8"; | ||
130 | "${modifier}+ccedilla" = "workspace 9"; | ||
131 | "${modifier}+agrave" = "workspace 10"; | ||
132 | |||
133 | "${modifier}+Shift+ampersand" = "move container to workspace 1"; | ||
134 | "${modifier}+Shift+eacute" = "move container to workspace 2"; | ||
135 | "${modifier}+Shift+quotedbl" = "move container to workspace 3"; | ||
136 | "${modifier}+Shift+apostrophe" = "move container to workspace 4"; | ||
137 | "${modifier}+Shift+parenleft" = "move container to workspace 5"; | ||
138 | "${modifier}+Shift+minus" = "move container to workspace 6"; | ||
139 | "${modifier}+Shift+egrave" = "move container to workspace 7"; | ||
140 | "${modifier}+Shift+underscore" = "move container to workspace 8"; | ||
141 | "${modifier}+Shift+ccedilla" = "move container to workspace 9"; | ||
142 | "${modifier}+Shift+agrave" = "move container to workspace 10"; | ||
143 | |||
144 | "${modifier}+m" = "exec ${pkgs.swaylock}/bin/swaylock"; | ||
145 | }; | ||
146 | |||
147 | menu = '' | ||
148 | ${pkgs.rofi}/bin/rofi -show drun -terminal ${pkgs.alacritty}/bin/alacritty | ||
149 | ''; | ||
150 | |||
151 | modifier = "Mod4"; | ||
152 | |||
153 | output."*".bg = | ||
154 | "${../../../res/wallpapers/wallpaper-1920x1080-kernel-card-black.png} fill"; | ||
155 | |||
156 | startup = [ | ||
157 | { command = "${pkgs.mako}/bin/mako"; always = true; } | ||
158 | { | ||
159 | command = "systemctl --user import-environment ${ | ||
160 | builtins.toString (lib.unique config.xsession.importedVariables) | ||
161 | }; systemctl --user start sway-session.target"; | ||
162 | } | ||
163 | ]; | ||
164 | |||
165 | terminal = "${pkgs.alacritty}/bin/alacritty"; | ||
166 | |||
167 | window = { | ||
168 | border = 2; | ||
169 | hideEdgeBorders = "smart"; | ||
170 | titlebar = true; | ||
171 | }; | ||
172 | }; | ||
173 | }; | ||
174 | |||
175 | # TODO: 21.05 | ||
176 | /* | ||
177 | services.wlsunset = { | ||
178 | enable = true; | ||
179 | latitude = "48.864716"; | ||
180 | longitude = "2.349014"; | ||
181 | # Reduce blue light anyways | ||
182 | temperature = { | ||
183 | day = 4000; | ||
184 | night = 2500; | ||
185 | }; | ||
186 | systemdTarget = "sway-session.target"; | ||
187 | }; | ||
188 | */ | ||
189 | |||
190 | # TODO: upstream a PR to beautify this | ||
191 | xdg.configFile."swaylock/config".text = with globalConfig.theme.colors; '' | ||
192 | ignore-empty-password | ||
193 | image=${../../../res/wallpapers/wallpaper-1920x1080-install-gentoo.png} | ||
194 | |||
195 | font=monospace | ||
196 | |||
197 | inside-color=${lib.removePrefix "#" dominant}dd | ||
198 | inside-clear-color=${lib.removePrefix "#" neutralOrange}dd | ||
199 | inside-ver-color=${lib.removePrefix "#" neutralOrange}dd | ||
200 | inside-wrong-color=${lib.removePrefix "#" neutralRed}dd | ||
201 | |||
202 | key-hl-color=${lib.removePrefix "#" brightGreen}ee | ||
203 | bs-hl-color=${lib.removePrefix "#" neutralRed}ee | ||
204 | |||
205 | line-color=${lib.removePrefix "#" background}ee | ||
206 | line-clear-color=${lib.removePrefix "#" background}ee | ||
207 | line-ver-color=${lib.removePrefix "#" background}ee | ||
208 | line-wrong-color=${lib.removePrefix "#" background}ee | ||
209 | |||
210 | ring-color=${lib.removePrefix "#" dominant}ee | ||
211 | ring-clear-color=${lib.removePrefix "#" brightOrange}ee | ||
212 | ring-ver-color=${lib.removePrefix "#" brightOrange}ee | ||
213 | ring-wrong-color=${lib.removePrefix "#" brightRed}ee | ||
214 | |||
215 | separator-color=${lib.removePrefix "#" background}ee | ||
216 | |||
217 | text-color=${lib.removePrefix "#" background}ff | ||
218 | text-clear-color=${lib.removePrefix "#" background}ff | ||
219 | text-ver-color=${lib.removePrefix "#" background}ff | ||
220 | text-wrong-color=${lib.removePrefix "#" background}ff | ||
221 | |||
222 | indicator-radius=75 | ||
223 | indicator-thickness=10 | ||
224 | ''; | ||
225 | |||
226 | xsession.importedVariables = [ | ||
227 | "DBUS_SESSION_BUS_ADDRESS" | ||
228 | "DISPLAY" | ||
229 | "SSH_AUTH_SOCK" | ||
230 | "XAUTHORITY" | ||
231 | "XDG_DATA_DIRS" | ||
232 | "XDG_RUNTIME_DIR" | ||
233 | "XDG_SESSION_ID" | ||
234 | |||
235 | "WAYLAND_DISPLAY" | ||
236 | "SWAYSOCK" | ||
237 | "I3SOCK" | ||
238 | |||
239 | "XDG_CURRENT_DESKTOP" | ||
240 | "XDG_SESSION_TYPE" | ||
241 | ]; | ||
242 | |||
243 | systemd.user.targets.sway-session = { | ||
244 | Unit = { | ||
245 | Description = "sway compositor session"; | ||
246 | Documentation = [ "man:systemd.special(7)" ]; | ||
247 | BindsTo = [ "graphical-session.target" ]; | ||
248 | Wants = [ "graphical-session-pre.target" ]; | ||
249 | After = [ "graphical-session-pre.target" ]; | ||
250 | }; | ||
251 | }; | ||
252 | }; | ||
253 | |||
254 | environment.systemPackages = with pkgs; [ qt5.qtwayland ]; | ||
255 | |||
256 | # TODO: in 21.05 | ||
257 | #programs.xwayland.enable = true; | ||
258 | security.pam.services.swaylock = { }; | ||
259 | |||
260 | xdg.portal.extraPortals = with pkgs; [ | ||
261 | unstable.xdg-desktop-portal-wlr | ||
262 | ]; | ||
263 | } | ||