diff options
88 files changed, 2791 insertions, 3238 deletions
@@ -1,7 +1,5 @@ | |||
1 | **/result | 1 | **/result |
2 | **/result-* | 2 | **/result-* |
3 | **/#*# | ||
4 | **/.#* | ||
5 | **/.gup | 3 | **/.gup |
6 | .direnv | 4 | .direnv |
7 | 5 | ||
@@ -26,3 +26,6 @@ creation_rules: | |||
26 | - path_regex: ^hosts/sif/ | 26 | - path_regex: ^hosts/sif/ |
27 | key_groups: | 27 | key_groups: |
28 | - age: [ *admin_gkleen, *machine_sif ] | 28 | - age: [ *admin_gkleen, *machine_sif ] |
29 | - path_regex: ^modules/nix-access-tokens/ | ||
30 | key_groups: | ||
31 | - age: [ *admin_gkleen, *machine_sif, *machine_surtr, *machine_vidhar ] | ||
diff --git a/_sources/generated.json b/_sources/generated.json index 47e088c4..b3d09fc4 100644 --- a/_sources/generated.json +++ b/_sources/generated.json | |||
@@ -20,20 +20,6 @@ | |||
20 | }, | 20 | }, |
21 | "version": "8ef9a5b73e5d1063cf912c70027c655fb19d1109" | 21 | "version": "8ef9a5b73e5d1063cf912c70027c655fb19d1109" |
22 | }, | 22 | }, |
23 | "batman-adv": { | ||
24 | "cargoLocks": null, | ||
25 | "date": null, | ||
26 | "extract": null, | ||
27 | "name": "batman-adv", | ||
28 | "passthru": null, | ||
29 | "pinned": false, | ||
30 | "src": { | ||
31 | "sha256": "sha256-VYyIkH5IFfKN6EOHZxSx6AaepD3a22/hhmLhqkle5Z0=", | ||
32 | "type": "tarball", | ||
33 | "url": "https://downloads.open-mesh.org/batman/stable/sources/batman-adv/batman-adv-2024.4.tar.gz" | ||
34 | }, | ||
35 | "version": "2024.4" | ||
36 | }, | ||
37 | "bpf-examples": { | 23 | "bpf-examples": { |
38 | "cargoLocks": null, | 24 | "cargoLocks": null, |
39 | "date": "2025-01-03", | 25 | "date": "2025-01-03", |
@@ -111,6 +97,26 @@ | |||
111 | }, | 97 | }, |
112 | "version": "2.17" | 98 | "version": "2.17" |
113 | }, | 99 | }, |
100 | "mako": { | ||
101 | "cargoLocks": null, | ||
102 | "date": "2025-01-19", | ||
103 | "extract": null, | ||
104 | "name": "mako", | ||
105 | "passthru": null, | ||
106 | "pinned": false, | ||
107 | "src": { | ||
108 | "deepClone": false, | ||
109 | "fetchSubmodules": false, | ||
110 | "leaveDotGit": false, | ||
111 | "name": null, | ||
112 | "rev": "57a258c1f8861200e0623153f1b79065d4ddabd8", | ||
113 | "sha256": "sha256-9PcZLpIfGR8SmZf5e2rDZhF+y3kfSaFw5DneDXHMGTc=", | ||
114 | "sparseCheckout": [], | ||
115 | "type": "git", | ||
116 | "url": "https://github.com/emersion/mako" | ||
117 | }, | ||
118 | "version": "57a258c1f8861200e0623153f1b79065d4ddabd8" | ||
119 | }, | ||
114 | "mpv-autosave": { | 120 | "mpv-autosave": { |
115 | "cargoLocks": null, | 121 | "cargoLocks": null, |
116 | "date": "2020-10-22", | 122 | "date": "2020-10-22", |
@@ -359,6 +365,26 @@ | |||
359 | }, | 365 | }, |
360 | "version": "0.2.1" | 366 | "version": "0.2.1" |
361 | }, | 367 | }, |
368 | "swayosd": { | ||
369 | "cargoLocks": null, | ||
370 | "date": "2025-01-27", | ||
371 | "extract": null, | ||
372 | "name": "swayosd", | ||
373 | "passthru": null, | ||
374 | "pinned": false, | ||
375 | "src": { | ||
376 | "deepClone": false, | ||
377 | "fetchSubmodules": false, | ||
378 | "leaveDotGit": false, | ||
379 | "name": null, | ||
380 | "rev": "993180b5e7db1dfc453a556bf208f05b04283c8f", | ||
381 | "sha256": "sha256-qwtGkRJlCYu+dO3xCmnRexX+E4QvXRAHXUslLO7mrAI=", | ||
382 | "sparseCheckout": [], | ||
383 | "type": "git", | ||
384 | "url": "https://github.com/ErikReider/SwayOSD" | ||
385 | }, | ||
386 | "version": "993180b5e7db1dfc453a556bf208f05b04283c8f" | ||
387 | }, | ||
362 | "tomorrow-night-paradise-theme": { | 388 | "tomorrow-night-paradise-theme": { |
363 | "cargoLocks": null, | 389 | "cargoLocks": null, |
364 | "date": "2012-06-04", | 390 | "date": "2012-06-04", |
@@ -381,7 +407,7 @@ | |||
381 | }, | 407 | }, |
382 | "v4l2loopback": { | 408 | "v4l2loopback": { |
383 | "cargoLocks": null, | 409 | "cargoLocks": null, |
384 | "date": "2024-11-26", | 410 | "date": "2025-02-03", |
385 | "extract": null, | 411 | "extract": null, |
386 | "name": "v4l2loopback", | 412 | "name": "v4l2loopback", |
387 | "passthru": null, | 413 | "passthru": null, |
@@ -393,12 +419,12 @@ | |||
393 | "name": null, | 419 | "name": null, |
394 | "owner": "umlaeute", | 420 | "owner": "umlaeute", |
395 | "repo": "v4l2loopback", | 421 | "repo": "v4l2loopback", |
396 | "rev": "e750af9eb17d729b8c5257a4bcd2faba2b28029c", | 422 | "rev": "7164d6e6b9aad52a27652c8bb8bd3c3d7a5b336b", |
397 | "sha256": "sha256-ePA1LcxQInrLLpbZ7Wljv75lWl6V6s9KkdMp0tF1vhk=", | 423 | "sha256": "sha256-1f4+pIbPM/TOJOc7Ns2VDXlBCGyrXiNpmKfThl5kZfk=", |
398 | "sparseCheckout": [], | 424 | "sparseCheckout": [], |
399 | "type": "github" | 425 | "type": "github" |
400 | }, | 426 | }, |
401 | "version": "e750af9eb17d729b8c5257a4bcd2faba2b28029c" | 427 | "version": "7164d6e6b9aad52a27652c8bb8bd3c3d7a5b336b" |
402 | }, | 428 | }, |
403 | "xcompose": { | 429 | "xcompose": { |
404 | "cargoLocks": null, | 430 | "cargoLocks": null, |
@@ -430,10 +456,10 @@ | |||
430 | "pinned": false, | 456 | "pinned": false, |
431 | "src": { | 457 | "src": { |
432 | "name": null, | 458 | "name": null, |
433 | "sha256": "sha256-rA5ytakBe6EEtCWFRiAafO3DjovSByfgxjt3yCm0Jek=", | 459 | "sha256": "sha256-HJc4JmkhrUPFaK0BrDNi+3x69Uknb77JK9cvFA2hYkA=", |
434 | "type": "url", | 460 | "type": "url", |
435 | "url": "https://pypi.org/packages/source/y/yt_dlp/yt_dlp-2024.12.23.tar.gz" | 461 | "url": "https://pypi.org/packages/source/y/yt_dlp/yt_dlp-2025.1.26.tar.gz" |
436 | }, | 462 | }, |
437 | "version": "2024.12.23" | 463 | "version": "2025.1.26" |
438 | } | 464 | } |
439 | } \ No newline at end of file | 465 | } \ No newline at end of file |
diff --git a/_sources/generated.nix b/_sources/generated.nix index 161dc4e1..63c464bb 100644 --- a/_sources/generated.nix +++ b/_sources/generated.nix | |||
@@ -16,14 +16,6 @@ | |||
16 | }; | 16 | }; |
17 | date = "2021-05-30"; | 17 | date = "2021-05-30"; |
18 | }; | 18 | }; |
19 | batman-adv = { | ||
20 | pname = "batman-adv"; | ||
21 | version = "2024.4"; | ||
22 | src = fetchTarball { | ||
23 | url = "https://downloads.open-mesh.org/batman/stable/sources/batman-adv/batman-adv-2024.4.tar.gz"; | ||
24 | sha256 = "sha256-VYyIkH5IFfKN6EOHZxSx6AaepD3a22/hhmLhqkle5Z0="; | ||
25 | }; | ||
26 | }; | ||
27 | bpf-examples = { | 19 | bpf-examples = { |
28 | pname = "bpf-examples"; | 20 | pname = "bpf-examples"; |
29 | version = "8d53e6fc46ae625bd16b38eb1007ece99460eada"; | 21 | version = "8d53e6fc46ae625bd16b38eb1007ece99460eada"; |
@@ -67,6 +59,20 @@ | |||
67 | sha256 = "sha256-afJuTByGUMU6kFqGGa3pbPaFVdYGcJYiR0RfDNYNgDk="; | 59 | sha256 = "sha256-afJuTByGUMU6kFqGGa3pbPaFVdYGcJYiR0RfDNYNgDk="; |
68 | }; | 60 | }; |
69 | }; | 61 | }; |
62 | mako = { | ||
63 | pname = "mako"; | ||
64 | version = "57a258c1f8861200e0623153f1b79065d4ddabd8"; | ||
65 | src = fetchgit { | ||
66 | url = "https://github.com/emersion/mako"; | ||
67 | rev = "57a258c1f8861200e0623153f1b79065d4ddabd8"; | ||
68 | fetchSubmodules = false; | ||
69 | deepClone = false; | ||
70 | leaveDotGit = false; | ||
71 | sparseCheckout = [ ]; | ||
72 | sha256 = "sha256-9PcZLpIfGR8SmZf5e2rDZhF+y3kfSaFw5DneDXHMGTc="; | ||
73 | }; | ||
74 | date = "2025-01-19"; | ||
75 | }; | ||
70 | mpv-autosave = { | 76 | mpv-autosave = { |
71 | pname = "mpv-autosave"; | 77 | pname = "mpv-autosave"; |
72 | version = "744c3ee61d2f0a8e9bb4e308dec6897215ae4704"; | 78 | version = "744c3ee61d2f0a8e9bb4e308dec6897215ae4704"; |
@@ -218,6 +224,20 @@ | |||
218 | sha256 = "sha256-7d/0fepOvdswuBGJCCMULB2kXOFBLP78yqX4NmByCF8="; | 224 | sha256 = "sha256-7d/0fepOvdswuBGJCCMULB2kXOFBLP78yqX4NmByCF8="; |
219 | }; | 225 | }; |
220 | }; | 226 | }; |
227 | swayosd = { | ||
228 | pname = "swayosd"; | ||
229 | version = "993180b5e7db1dfc453a556bf208f05b04283c8f"; | ||
230 | src = fetchgit { | ||
231 | url = "https://github.com/ErikReider/SwayOSD"; | ||
232 | rev = "993180b5e7db1dfc453a556bf208f05b04283c8f"; | ||
233 | fetchSubmodules = false; | ||
234 | deepClone = false; | ||
235 | leaveDotGit = false; | ||
236 | sparseCheckout = [ ]; | ||
237 | sha256 = "sha256-qwtGkRJlCYu+dO3xCmnRexX+E4QvXRAHXUslLO7mrAI="; | ||
238 | }; | ||
239 | date = "2025-01-27"; | ||
240 | }; | ||
221 | tomorrow-night-paradise-theme = { | 241 | tomorrow-night-paradise-theme = { |
222 | pname = "tomorrow-night-paradise-theme"; | 242 | pname = "tomorrow-night-paradise-theme"; |
223 | version = "70225a5bf90d495e13a9260bfdc268632ece0801"; | 243 | version = "70225a5bf90d495e13a9260bfdc268632ece0801"; |
@@ -234,15 +254,15 @@ | |||
234 | }; | 254 | }; |
235 | v4l2loopback = { | 255 | v4l2loopback = { |
236 | pname = "v4l2loopback"; | 256 | pname = "v4l2loopback"; |
237 | version = "e750af9eb17d729b8c5257a4bcd2faba2b28029c"; | 257 | version = "7164d6e6b9aad52a27652c8bb8bd3c3d7a5b336b"; |
238 | src = fetchFromGitHub { | 258 | src = fetchFromGitHub { |
239 | owner = "umlaeute"; | 259 | owner = "umlaeute"; |
240 | repo = "v4l2loopback"; | 260 | repo = "v4l2loopback"; |
241 | rev = "e750af9eb17d729b8c5257a4bcd2faba2b28029c"; | 261 | rev = "7164d6e6b9aad52a27652c8bb8bd3c3d7a5b336b"; |
242 | fetchSubmodules = true; | 262 | fetchSubmodules = true; |
243 | sha256 = "sha256-ePA1LcxQInrLLpbZ7Wljv75lWl6V6s9KkdMp0tF1vhk="; | 263 | sha256 = "sha256-1f4+pIbPM/TOJOc7Ns2VDXlBCGyrXiNpmKfThl5kZfk="; |
244 | }; | 264 | }; |
245 | date = "2024-11-26"; | 265 | date = "2025-02-03"; |
246 | }; | 266 | }; |
247 | xcompose = { | 267 | xcompose = { |
248 | pname = "xcompose"; | 268 | pname = "xcompose"; |
@@ -258,10 +278,10 @@ | |||
258 | }; | 278 | }; |
259 | yt-dlp = { | 279 | yt-dlp = { |
260 | pname = "yt-dlp"; | 280 | pname = "yt-dlp"; |
261 | version = "2024.12.23"; | 281 | version = "2025.1.26"; |
262 | src = fetchurl { | 282 | src = fetchurl { |
263 | url = "https://pypi.org/packages/source/y/yt_dlp/yt_dlp-2024.12.23.tar.gz"; | 283 | url = "https://pypi.org/packages/source/y/yt_dlp/yt_dlp-2025.1.26.tar.gz"; |
264 | sha256 = "sha256-rA5ytakBe6EEtCWFRiAafO3DjovSByfgxjt3yCm0Jek="; | 284 | sha256 = "sha256-HJc4JmkhrUPFaK0BrDNi+3x69Uknb77JK9cvFA2hYkA="; |
265 | }; | 285 | }; |
266 | }; | 286 | }; |
267 | } | 287 | } |
diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index 83dcf989..f4f7daed 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix | |||
@@ -80,7 +80,7 @@ let | |||
80 | ]; | 80 | ]; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | lockCommand = "${config.systemd.package}/bin/systemctl --user start gtklock.service"; | 83 | lockCommand = "${lib.getExe' config.systemd.package "systemctl"} --user start gtklock.service"; |
84 | in { | 84 | in { |
85 | imports = with flake.nixosModules.userProfiles.${userName}; [ | 85 | imports = with flake.nixosModules.userProfiles.${userName}; [ |
86 | mpv yt-dlp (args: import ./xcompose.nix (inputs // args)) | 86 | mpv yt-dlp (args: import ./xcompose.nix (inputs // args)) |
@@ -92,6 +92,7 @@ in { | |||
92 | home-manager.users.${userName} = { | 92 | home-manager.users.${userName} = { |
93 | imports = [ | 93 | imports = [ |
94 | ./libvirt | 94 | ./libvirt |
95 | ./niri | ||
95 | flakeInputs.nix-index-database.hmModules.nix-index | 96 | flakeInputs.nix-index-database.hmModules.nix-index |
96 | flakeInputs.impermanence.nixosModules.home-manager.impermanence | 97 | flakeInputs.impermanence.nixosModules.home-manager.impermanence |
97 | ]; | 98 | ]; |
@@ -184,7 +185,12 @@ in { | |||
184 | }; | 185 | }; |
185 | }; | 186 | }; |
186 | 187 | ||
187 | zathura.enable = true; | 188 | zathura = { |
189 | enable = true; | ||
190 | options = { | ||
191 | scroll-page-aware = true; | ||
192 | }; | ||
193 | }; | ||
188 | imv.enable = true; | 194 | imv.enable = true; |
189 | 195 | ||
190 | mpv.config = { | 196 | mpv.config = { |
@@ -250,292 +256,11 @@ in { | |||
250 | "kitty_mod+m" = "detach_window ask"; | 256 | "kitty_mod+m" = "detach_window ask"; |
251 | }; | 257 | }; |
252 | }; | 258 | }; |
253 | waybar = { | ||
254 | enable = true; | ||
255 | systemd = { | ||
256 | enable = true; | ||
257 | target = "hyprland-session.target"; | ||
258 | }; | ||
259 | settings = let | ||
260 | windowRewrites = { | ||
261 | "(.*) — Mozilla Firefox" = "$1"; | ||
262 | "(.*) - Mozilla Thunderbird" = "$1"; | ||
263 | "(.*) - mpv" = "$1"; | ||
264 | }; | ||
265 | iconSize = 11; | ||
266 | in [ | ||
267 | { | ||
268 | layer = "top"; | ||
269 | position = "top"; | ||
270 | height = 14; | ||
271 | output = [ "eDP-1" "DP-2" "DP-3" ]; | ||
272 | modules-left = [ "hyprland/workspaces" ]; | ||
273 | modules-center = [ "hyprland/window" ]; | ||
274 | modules-right = [ # "custom/worktime" "custom/worktime-today" | ||
275 | "custom/weather" "custom/keymap" "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "clock" ]; | ||
276 | |||
277 | "custom/weather" = { | ||
278 | format = "{}"; | ||
279 | tooltip = true; | ||
280 | interval = 3600; | ||
281 | exec = "${lib.getExe pkgs.wttrbar} --hide-conditions --nerd --custom-indicator \"<span font=\\\"Symbols Nerd Font Mono\\\" size=\\\"120%\\\">{ICON}</span> {FeelsLikeC}°\""; | ||
282 | return-type = "json"; | ||
283 | }; | ||
284 | "custom/keymap" = { | ||
285 | format = "{}"; | ||
286 | tooltip = true; | ||
287 | return-type = "json"; | ||
288 | exec = pkgs.writers.writePython3 "keymap" {} '' | ||
289 | import os | ||
290 | import socket | ||
291 | import re | ||
292 | import subprocess | ||
293 | import json | ||
294 | |||
295 | |||
296 | def output(keymap): | ||
297 | short = keymap | ||
298 | if keymap == "English (programmer Dvorak)": | ||
299 | short = "dvp" | ||
300 | elif keymap == "English (US)": | ||
301 | short = "<span color=\"#ffffff\">us</span>" | ||
302 | print(json.dumps({'text': short, 'tooltip': keymap}, separators=(',', ':')), flush=True) # noqa: E501 | ||
303 | |||
304 | |||
305 | r = subprocess.run(["hyprctl", "devices", "-j"], check=True, stdout=subprocess.PIPE, text=True) # noqa: E501 | ||
306 | for keyboard in json.loads(r.stdout)['keyboards']: | ||
307 | if keyboard['name'] != "at-translated-set-2-keyboard": | ||
308 | continue | ||
309 | output(keyboard['active_keymap']) | ||
310 | |||
311 | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | ||
312 | sock.connect(os.environ["XDG_RUNTIME_DIR"] + "/hypr/" + os.environ["HYPRLAND_INSTANCE_SIGNATURE"] + "/.socket2.sock") # noqa: E501 | ||
313 | expected = re.compile(r'^activelayout>>at-translated-set-2-keyboard,(?P<keymap>.+)$') # noqa: E501 | ||
314 | for line in sock.makefile(buffering=1, encoding='utf-8'): | ||
315 | if match := expected.match(line): | ||
316 | output(match.group("keymap")) | ||
317 | ''; | ||
318 | on-click = "hyprctl switchxkblayout at-translated-set-2-keyboard next"; | ||
319 | }; | ||
320 | "custom/worktime" = { | ||
321 | interval = 60; | ||
322 | exec = getExe pkgs.worktime; | ||
323 | tooltip = false; | ||
324 | }; | ||
325 | "custom/worktime-today" = { | ||
326 | interval = 60; | ||
327 | exec = "${getExe pkgs.worktime} today"; | ||
328 | tooltip = false; | ||
329 | }; | ||
330 | "hyprland/workspaces" = { | ||
331 | all-outputs = true; | ||
332 | }; | ||
333 | "hyprland/window" = { | ||
334 | separate-outputs = true; | ||
335 | icon = true; | ||
336 | icon-size = 14; | ||
337 | rewrite = windowRewrites; | ||
338 | }; | ||
339 | clock = { | ||
340 | interval = 1; | ||
341 | # timezone = "Europe/Berlin"; | ||
342 | format = "W{:%V-%u %F %H:%M:%S%Ez}"; | ||
343 | tooltip-format = "<tt><small>{calendar}</small></tt>"; | ||
344 | calendar = { | ||
345 | mode = "year"; | ||
346 | mode-mon-col = 3; | ||
347 | weeks-pos = "left"; | ||
348 | on-scroll = 1; | ||
349 | format = { | ||
350 | months = "<span color='#ffead3'><b>{}</b></span>"; | ||
351 | days = "{}"; | ||
352 | weeks = "<span color='#99ffdd'><b>{}</b></span>"; | ||
353 | weekdays = "<span color='#ffcc66'><b>{}</b></span>"; | ||
354 | today = "<span color='#ff6699'><b>{}</b></span>"; | ||
355 | }; | ||
356 | }; | ||
357 | }; | ||
358 | battery = { | ||
359 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
360 | icon-size = iconSize - 2; | ||
361 | states = { warning = 30; critical = 15; }; | ||
362 | format-icons = ["󰂎" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹" ]; | ||
363 | format-charging = "󰂄"; | ||
364 | format-plugged = "󰚥"; | ||
365 | tooltip-format = "{capacity}% {timeTo}"; | ||
366 | interval = 20; | ||
367 | }; | ||
368 | tray = { | ||
369 | icon-size = 16; | ||
370 | # show-passive-items = true; | ||
371 | spacing = 1; | ||
372 | }; | ||
373 | privacy = { | ||
374 | icon-spacing = 7; | ||
375 | icon-size = iconSize; | ||
376 | modules = [ | ||
377 | { type = "screenshare"; } | ||
378 | { type = "audio-in"; } | ||
379 | ]; | ||
380 | }; | ||
381 | idle_inhibitor = { | ||
382 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
383 | icon-size = iconSize; | ||
384 | format-icons = { activated = "󰈈"; deactivated = "󰈉"; }; | ||
385 | timeout = 120; | ||
386 | }; | ||
387 | backlight = { | ||
388 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
389 | icon-size = iconSize; | ||
390 | tooltip-format = "{percent}%"; | ||
391 | format-icons = ["󰃚" "󰃛" "󰃜" "󰃝" "󰃞" "󰃟" "󰃠"]; | ||
392 | on-scroll-up = "lightctl -d -e4 -n1 up"; | ||
393 | on-scroll-down = "lightctl -d -e4 -n1 down"; | ||
394 | }; | ||
395 | wireplumber = { | ||
396 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
397 | icon-size = iconSize; | ||
398 | tooltip-format = "{volume}% {node_name}"; | ||
399 | format-icons = ["󰕿" "󰖀" "󰕾"]; | ||
400 | format-muted = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">󰝟</span>"; | ||
401 | # ignored-sinks = ["Easy Effects Sink"]; | ||
402 | on-scroll-up = "volumectl -d -u up"; | ||
403 | on-scroll-down = "volumectl -d -u down"; | ||
404 | on-click = "volumectl -d toggle-mute"; | ||
405 | }; | ||
406 | } | ||
407 | { | ||
408 | layer = "top"; | ||
409 | position = "top"; | ||
410 | height = 14; | ||
411 | output = [ "!eDP-1" "!DP-2" "!DP-3" ]; | ||
412 | modules-left = [ "hyprland/workspaces" ]; | ||
413 | modules-center = [ "hyprland/window" ]; | ||
414 | modules-right = [ "clock" ]; | ||
415 | |||
416 | "hyprland/workspaces" = { | ||
417 | all-outputs = false; | ||
418 | }; | ||
419 | "hyprland/window" = { | ||
420 | separate-outputs = true; | ||
421 | icon = true; | ||
422 | icon-size = 14; | ||
423 | rewrite = windowRewrites; | ||
424 | }; | ||
425 | clock = { | ||
426 | interval = 1; | ||
427 | # timezone = "Europe/Berlin"; | ||
428 | format = "{:%H:%M}"; | ||
429 | tooltip-format = "W{:%V-%u %F %H:%M:%S%Ez}"; | ||
430 | }; | ||
431 | } | ||
432 | ]; | ||
433 | style = '' | ||
434 | @define-color white #ffffff; | ||
435 | @define-color grey #555555; | ||
436 | @define-color blue #1a8fff; | ||
437 | @define-color green #23fd00; | ||
438 | @define-color orange #f28a21; | ||
439 | @define-color red #f2201f; | ||
440 | |||
441 | * { | ||
442 | border: none; | ||
443 | font-family: "Fira Sans Nerd Font"; | ||
444 | font-size: 10pt; | ||
445 | min-height: 0; | ||
446 | } | ||
447 | |||
448 | window#waybar { | ||
449 | background-color: rgba(0, 0, 0, 0.66); | ||
450 | color: @white; | ||
451 | } | ||
452 | |||
453 | .modules-left { | ||
454 | margin-left: 9px; | ||
455 | } | ||
456 | .modules-right { | ||
457 | margin-right: 9px; | ||
458 | } | ||
459 | |||
460 | .module { | ||
461 | margin: 0 5px; | ||
462 | } | ||
463 | |||
464 | #workspaces button { | ||
465 | color: @grey; | ||
466 | } | ||
467 | #workspaces button.hosting-monitor { | ||
468 | color: @white; | ||
469 | } | ||
470 | #workspaces button.visible { | ||
471 | color: @blue; | ||
472 | } | ||
473 | #workspaces button.active { | ||
474 | color: @green; | ||
475 | } | ||
476 | #workspaces button.urgent { | ||
477 | color: @red; | ||
478 | } | ||
479 | |||
480 | #custom-weather, #custom-keymap, #custom-worktime, #custom-worktime-today { | ||
481 | color: @grey; | ||
482 | margin: 0 5px; | ||
483 | } | ||
484 | #custom-weather, #custom-worktime-today { | ||
485 | margin-right: 3px; | ||
486 | } | ||
487 | #custom-keymap, #custom-weather { | ||
488 | margin-left: 3px; | ||
489 | } | ||
490 | |||
491 | #tray { | ||
492 | margin: 0; | ||
493 | } | ||
494 | #battery, #idle_inhibitor, #backlight, #wireplumber { | ||
495 | color: @grey; | ||
496 | margin: 0 5px 0 2px; | ||
497 | } | ||
498 | #idle_inhibitor { | ||
499 | margin-right: 2px; | ||
500 | margin-left: 3px; | ||
501 | } | ||
502 | #battery { | ||
503 | margin-right: 3px; | ||
504 | } | ||
505 | #battery.discharging { | ||
506 | color: @white; | ||
507 | } | ||
508 | #battery.warning { | ||
509 | color: @orange; | ||
510 | } | ||
511 | #battery.critical { | ||
512 | color: @red; | ||
513 | } | ||
514 | #battery.charging { | ||
515 | color: @white; | ||
516 | } | ||
517 | #idle_inhibitor.activated { | ||
518 | color: @white; | ||
519 | } | ||
520 | |||
521 | #idle_inhibitor { | ||
522 | padding-top: 1px; | ||
523 | } | ||
524 | |||
525 | #privacy { | ||
526 | color: @red; | ||
527 | margin: -1px 2px 0px 5px; | ||
528 | } | ||
529 | #clock { | ||
530 | /* margin-right: 5px; */ | ||
531 | } | ||
532 | ''; | ||
533 | }; | ||
534 | wpaperd = { | 259 | wpaperd = { |
535 | enable = true; | 260 | enable = true; |
536 | settings.default = { | 261 | settings.default = { |
537 | path = "~/.wallpapers"; | 262 | path = "~/.wallpapers"; |
538 | duration = "8h"; | 263 | duration = "15m"; |
539 | mode = "center"; | 264 | mode = "center"; |
540 | }; | 265 | }; |
541 | }; | 266 | }; |
@@ -543,7 +268,7 @@ in { | |||
543 | enable = true; | 268 | enable = true; |
544 | settings = { | 269 | settings = { |
545 | main = { | 270 | main = { |
546 | terminal = lib.getExe pkgs.kitty; | 271 | terminal = lib.getExe cfg.programs.kitty.package; |
547 | layer = "overlay"; | 272 | layer = "overlay"; |
548 | icon-theme = "Paper"; | 273 | icon-theme = "Paper"; |
549 | font = "Fira Sans"; | 274 | font = "Fira Sans"; |
@@ -565,14 +290,6 @@ in { | |||
565 | }; | 290 | }; |
566 | 291 | ||
567 | services = { | 292 | services = { |
568 | dunst = { | ||
569 | settings = import ./dunst-settings.nix inputs; | ||
570 | iconTheme = { | ||
571 | package = pkgs.paper-icon-theme; | ||
572 | name = "Paper"; | ||
573 | }; | ||
574 | enable = true; | ||
575 | }; | ||
576 | emacs = { | 293 | emacs = { |
577 | enable = true; | 294 | enable = true; |
578 | socketActivation.enable = true; | 295 | socketActivation.enable = true; |
@@ -601,8 +318,11 @@ in { | |||
601 | device_mounted = []; | 318 | device_mounted = []; |
602 | }; | 319 | }; |
603 | device_config = [ | 320 | device_config = [ |
604 | { mount_path = "/run/etc-metadata"; ignore = true; } | 321 | { loop_file = "/nix/store/*-etc-metadata.erofs"; is_mounted = false; ignore = true; } |
322 | { mount_path = "/run/nixos-etc-metadata"; ignore = true; } | ||
323 | { mount_path = "/run/nixos-etc-metadata.*"; ignore = true; } | ||
605 | ]; | 324 | ]; |
325 | icon_names.media = ["drive-removable-media-symbolic"]; | ||
606 | }; | 326 | }; |
607 | }; | 327 | }; |
608 | network-manager-applet.enable = true; | 328 | network-manager-applet.enable = true; |
@@ -639,31 +359,17 @@ in { | |||
639 | enable = true; | 359 | enable = true; |
640 | events = [ | 360 | events = [ |
641 | { event = "before-sleep"; command = lockCommand; } | 361 | { event = "before-sleep"; command = lockCommand; } |
642 | { event = "after-resume"; command = "${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on"; } | ||
643 | { event = "lock"; command = lockCommand; } | 362 | { event = "lock"; command = lockCommand; } |
644 | ]; | 363 | ]; |
645 | timeouts = [ | 364 | timeouts = [ |
646 | { timeout = 300; | ||
647 | command = "${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off"; | ||
648 | } | ||
649 | { timeout = 330; command = lockCommand; } | 365 | { timeout = 330; command = lockCommand; } |
650 | ]; | 366 | ]; |
651 | extraArgs = [ | 367 | extraArgs = [ |
368 | "-w" | ||
652 | "idlehint" "30" | 369 | "idlehint" "30" |
653 | ]; | 370 | ]; |
654 | }; | 371 | }; |
655 | poweralertd.enable = true; | 372 | poweralertd.enable = true; |
656 | avizo = { | ||
657 | enable = true; | ||
658 | settings.default = { | ||
659 | time = "1.0"; | ||
660 | background = "rgba(0, 0, 0, 0.8)"; | ||
661 | border-color = "rgba(0, 0, 0, 1)"; | ||
662 | bar-fg-color = "rgba(160, 160, 160, 1)"; | ||
663 | bar-bg-color = "rgba(32, 32, 32, 0.96)"; | ||
664 | # y-offset = "0.25"; | ||
665 | }; | ||
666 | }; | ||
667 | }; | 373 | }; |
668 | 374 | ||
669 | home.pointerCursor = { | 375 | home.pointerCursor = { |
@@ -704,16 +410,18 @@ in { | |||
704 | fira fira-code pwvucontrol wrappedKeepassxc wl-clipboard-rs | 410 | fira fira-code pwvucontrol wrappedKeepassxc wl-clipboard-rs |
705 | mumble pulseaudio-ctl pamixer libnotify screen-message | 411 | mumble pulseaudio-ctl pamixer libnotify screen-message |
706 | wrappedYTMDesktop libsForQt5.qt5ct playerctl evince | 412 | wrappedYTMDesktop libsForQt5.qt5ct playerctl evince |
707 | thunderbird zoom-us steam steam-run wireshark virt-manager | 413 | thunderbird zoom-us xdg-desktop-portal steam steam-run |
708 | rclone cached-nix-shell worktime fira-code-symbols | 414 | wireshark virt-manager rclone cached-nix-shell worktime |
709 | libreoffice xournalpp google-chrome nixos-shell virt-viewer | 415 | fira-code-symbols libreoffice xournalpp google-chrome |
710 | freerdp gnome-icon-theme paper-icon-theme sshpassSecret | 416 | nixos-shell virt-viewer freerdp gnome-icon-theme |
711 | weechat element-desktop matrix-synapse-tools.synadm | 417 | paper-icon-theme sshpassSecret weechat element-desktop |
418 | matrix-synapse-tools.synadm | ||
712 | flakeInputs.deploy-rs.packages.${config.nixpkgs.system}.deploy-rs | 419 | flakeInputs.deploy-rs.packages.${config.nixpkgs.system}.deploy-rs |
713 | sieve-connect gimp inkscape udiskie glab nitrokey-app | 420 | sieve-connect gimp inkscape udiskie glab nitrokey-app |
714 | pynitrokey gtklock wlrctl remmina openscad spice-record | 421 | pynitrokey gtklock wlrctl remmina openscad spice-record |
715 | libguestfs-with-appliance nerd-fonts.fira-mono | 422 | libguestfs-with-appliance nerd-fonts.fira-mono |
716 | nerd-fonts.symbols-only nerd-fonts.fira-code powerline-fonts | 423 | nerd-fonts.symbols-only nerd-fonts.fira-code powerline-fonts |
424 | swtpm | ||
717 | ]; | 425 | ]; |
718 | 426 | ||
719 | file = { | 427 | file = { |
@@ -748,13 +456,6 @@ in { | |||
748 | }; | 456 | }; |
749 | 457 | ||
750 | xdg.configFile = { | 458 | xdg.configFile = { |
751 | "dunst/dunstrc.d" = { | ||
752 | source = ./dunstrc.d; | ||
753 | recursive = true; | ||
754 | onChange = '' | ||
755 | ${pkgs.systemd}/bin/systemctl --user try-restart dunst | ||
756 | ''; | ||
757 | }; | ||
758 | "wireplumber" = { | 459 | "wireplumber" = { |
759 | source = ./wireplumber; | 460 | source = ./wireplumber; |
760 | recursive = true; | 461 | recursive = true; |
@@ -786,6 +487,18 @@ in { | |||
786 | }; | 487 | }; |
787 | }; | 488 | }; |
788 | "emacs/init.el".source = ./emacs.el; | 489 | "emacs/init.el".source = ./emacs.el; |
490 | "systemd/user/xdg-desktop-portal.service.d/after-graphical-session.conf".text = '' | ||
491 | [Unit] | ||
492 | After=graphical-session.target | ||
493 | ''; | ||
494 | "systemd/user/home-manager.service.d/before-graphical-session.conf".text = '' | ||
495 | [Unit] | ||
496 | Before=graphical-session-pre.target | ||
497 | ''; | ||
498 | "pdfpc/pdfpcrc".text = '' | ||
499 | mouse 8 prev | ||
500 | mouse 9 next | ||
501 | ''; | ||
789 | }; | 502 | }; |
790 | 503 | ||
791 | xdg.dataFile = { | 504 | xdg.dataFile = { |
@@ -903,7 +616,6 @@ in { | |||
903 | --property 'CPUAccounting=yes' --property 'CPUQuotaPeriodSec=50ms' \ | 616 | --property 'CPUAccounting=yes' --property 'CPUQuotaPeriodSec=50ms' \ |
904 | --property 'Environment=DSCP=46' \ | 617 | --property 'Environment=DSCP=46' \ |
905 | -- ${pkgs.dscp}/bin/dscp ${pkgs.google-chrome}/bin/google-chrome-stable \ | 618 | -- ${pkgs.dscp}/bin/dscp ${pkgs.google-chrome}/bin/google-chrome-stable \ |
906 | --force-device-scale-factor=1.5 \ | ||
907 | --class=Rainbow \ | 619 | --class=Rainbow \ |
908 | --kiosk "https://web.openrainbow.com" \ | 620 | --kiosk "https://web.openrainbow.com" \ |
909 | --user-data-dir=''${HOME}/.config/google-chrome-rainbow | 621 | --user-data-dir=''${HOME}/.config/google-chrome-rainbow |
@@ -912,6 +624,9 @@ in { | |||
912 | url = "https://web.openrainbow.com/rb/2.139.17/assets/skins/rainbow/images/homepage/logo__rainbow.svg"; | 624 | url = "https://web.openrainbow.com/rb/2.139.17/assets/skins/rainbow/images/homepage/logo__rainbow.svg"; |
913 | hash = "sha256-5fmo8rDqVDpzkGaPjk4Y+SsSZpAsY7VUQSFW6WdHwuU="; | 625 | hash = "sha256-5fmo8rDqVDpzkGaPjk4Y+SsSZpAsY7VUQSFW6WdHwuU="; |
914 | }; | 626 | }; |
627 | settings = { | ||
628 | StartupWMClass = "Rainbow"; | ||
629 | }; | ||
915 | }; | 630 | }; |
916 | }; | 631 | }; |
917 | 632 | ||
@@ -927,23 +642,6 @@ in { | |||
927 | color-scheme = "prefer-dark"; | 642 | color-scheme = "prefer-dark"; |
928 | }; | 643 | }; |
929 | }; | 644 | }; |
930 | |||
931 | wayland.windowManager.hyprland = { | ||
932 | enable = true; | ||
933 | settings = import ./hyprland.nix inputs; | ||
934 | }; | ||
935 | |||
936 | xdg.portal = { | ||
937 | enable = true; | ||
938 | xdgOpenUsePortal = true; | ||
939 | config = { | ||
940 | common.default = [ "gtk" ]; | ||
941 | hyprland.default = [ "gtk" "kde" "hyprland" ]; | ||
942 | }; | ||
943 | extraPortals = with pkgs; [ | ||
944 | xdg-desktop-portal-kde xdg-desktop-portal-gtk xdg-desktop-portal-wlr xdg-desktop-portal-hyprland | ||
945 | ]; | ||
946 | }; | ||
947 | }; | 645 | }; |
948 | }; | 646 | }; |
949 | } | 647 | } |
diff --git a/accounts/gkleen@sif/dunst-settings.nix b/accounts/gkleen@sif/dunst-settings.nix deleted file mode 100644 index 72687aea..00000000 --- a/accounts/gkleen@sif/dunst-settings.nix +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | { pkgs, ... }: | ||
2 | { | ||
3 | global = { | ||
4 | font = "Fira Sans 12"; | ||
5 | markup = "full"; | ||
6 | format = "<i>%s</i> %p\\n%b"; | ||
7 | alignment = "left"; | ||
8 | # geometry = "1216x10-32+64"; | ||
9 | width = 500; | ||
10 | height = 100; | ||
11 | offset = "4x4"; | ||
12 | origin = "top-right"; | ||
13 | shrink = true; | ||
14 | monitor = 0; | ||
15 | follow = "none"; | ||
16 | padding = 6; | ||
17 | horizontal_padding = 6; | ||
18 | separator_height = 1; | ||
19 | separator_color = "frame"; | ||
20 | idle_threshold = 0; | ||
21 | |||
22 | transparency = 10; | ||
23 | |||
24 | frame_width = 1; | ||
25 | frame_color = "#999999"; | ||
26 | |||
27 | word_wrap = true; | ||
28 | show_age_threshold = 15; | ||
29 | show_indicators = false; | ||
30 | icon_position = "right"; | ||
31 | min_icon_size = 25; | ||
32 | max_icon_size = 25; | ||
33 | sort = false; | ||
34 | sticky_history = false; | ||
35 | |||
36 | dmenu = "fuzzel --dmenu"; | ||
37 | browser = "${pkgs.xdg-utils}/bin/xdg-open"; | ||
38 | }; | ||
39 | # shortcuts = { | ||
40 | # close = "ctrl+space"; | ||
41 | # close_all = "ctrl+shift+space"; | ||
42 | # history = "ctrl+comma"; | ||
43 | # context = "ctrl+period"; | ||
44 | # }; | ||
45 | } | ||
diff --git a/accounts/gkleen@sif/dunstrc.d/00-urgency_low.conf b/accounts/gkleen@sif/dunstrc.d/00-urgency_low.conf deleted file mode 100644 index 98c94b64..00000000 --- a/accounts/gkleen@sif/dunstrc.d/00-urgency_low.conf +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | [urgency_low] | ||
2 | background="#000000aa" | ||
3 | foreground="#999999" | ||
4 | timeout=5 \ No newline at end of file | ||
diff --git a/accounts/gkleen@sif/dunstrc.d/01-urgency_normal.conf b/accounts/gkleen@sif/dunstrc.d/01-urgency_normal.conf deleted file mode 100644 index f8fa8e2d..00000000 --- a/accounts/gkleen@sif/dunstrc.d/01-urgency_normal.conf +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | [urgency_normal] | ||
2 | background="#000000aa" | ||
3 | foreground="#ffffff" | ||
4 | timeout=15 \ No newline at end of file | ||
diff --git a/accounts/gkleen@sif/dunstrc.d/02-urgency_critical.conf b/accounts/gkleen@sif/dunstrc.d/02-urgency_critical.conf deleted file mode 100644 index a08bf4b1..00000000 --- a/accounts/gkleen@sif/dunstrc.d/02-urgency_critical.conf +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | [urgency_critical] | ||
2 | background="#900000aa" | ||
3 | foreground="#ffffff" | ||
4 | timeout=0 | ||
diff --git a/accounts/gkleen@sif/dunstrc.d/10-brightness.conf b/accounts/gkleen@sif/dunstrc.d/10-brightness.conf deleted file mode 100644 index c54595ab..00000000 --- a/accounts/gkleen@sif/dunstrc.d/10-brightness.conf +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | [brightness] | ||
2 | appname="brightness" | ||
3 | set_stack_tag="brightness" | ||
4 | set_transient=yes | ||
5 | history_ignore=yes | ||
diff --git a/accounts/gkleen@sif/dunstrc.d/10-pulseaudio-ctl.conf b/accounts/gkleen@sif/dunstrc.d/10-pulseaudio-ctl.conf deleted file mode 100644 index 074f4535..00000000 --- a/accounts/gkleen@sif/dunstrc.d/10-pulseaudio-ctl.conf +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | [pulseaudio-ctl] | ||
2 | body="Current is *" | ||
3 | history_ignore=yes | ||
4 | set_stack_tag="volume" | ||
5 | summary="Volume *" | ||
diff --git a/accounts/gkleen@sif/dunstrc.d/20-element.conf b/accounts/gkleen@sif/dunstrc.d/20-element.conf deleted file mode 100644 index 5ff6031e..00000000 --- a/accounts/gkleen@sif/dunstrc.d/20-element.conf +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | [element-im] | ||
2 | appname=Element | ||
3 | timeout=0 \ No newline at end of file | ||
diff --git a/accounts/gkleen@sif/dunstrc.d/20-kitty.conf b/accounts/gkleen@sif/dunstrc.d/20-kitty.conf deleted file mode 100644 index b27ee27e..00000000 --- a/accounts/gkleen@sif/dunstrc.d/20-kitty.conf +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | [kitty] | ||
2 | appname=kitty | ||
3 | urgency=low | ||
diff --git a/accounts/gkleen@sif/dunstrc.d/20-mail.conf b/accounts/gkleen@sif/dunstrc.d/20-mail.conf deleted file mode 100644 index cb568e01..00000000 --- a/accounts/gkleen@sif/dunstrc.d/20-mail.conf +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | [element] | ||
2 | appname="notmuch" | ||
3 | timeout=0 \ No newline at end of file | ||
diff --git a/accounts/gkleen@sif/dunstrc.d/20-zulip.conf b/accounts/gkleen@sif/dunstrc.d/20-zulip.conf deleted file mode 100644 index d7fbd32c..00000000 --- a/accounts/gkleen@sif/dunstrc.d/20-zulip.conf +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | [zulip] | ||
2 | appname="Zulip" | ||
3 | timeout=0 \ No newline at end of file | ||
diff --git a/accounts/gkleen@sif/emacs.el b/accounts/gkleen@sif/emacs.el index 183cb322..5cee16b0 100644 --- a/accounts/gkleen@sif/emacs.el +++ b/accounts/gkleen@sif/emacs.el | |||
@@ -228,6 +228,7 @@ necessarily running." | |||
228 | (global-set-key (kbd "C-x k") 'kill-buffer-with-special-emacsclient-handling)) | 228 | (global-set-key (kbd "C-x k") 'kill-buffer-with-special-emacsclient-handling)) |
229 | 229 | ||
230 | (add-hook 'server-switch-hook 'install-emacsclient-wrapped-kill-buffer) | 230 | (add-hook 'server-switch-hook 'install-emacsclient-wrapped-kill-buffer) |
231 | (add-hook 'server-switch-hook #'raise-frame) | ||
231 | 232 | ||
232 | (defun move-file (new-location) | 233 | (defun move-file (new-location) |
233 | "Write this file to NEW-LOCATION, and delete the old one." | 234 | "Write this file to NEW-LOCATION, and delete the old one." |
diff --git a/accounts/gkleen@sif/hyprland.nix b/accounts/gkleen@sif/hyprland.nix deleted file mode 100644 index cc7472ea..00000000 --- a/accounts/gkleen@sif/hyprland.nix +++ /dev/null | |||
@@ -1,425 +0,0 @@ | |||
1 | { pkgs, lib, config, userName, ... }: | ||
2 | let | ||
3 | cfg = config.home-manager.users.${userName}; | ||
4 | in { | ||
5 | monitor = [ | ||
6 | ",preferred,auto,auto,bitdepth,8" | ||
7 | "eDP-1,3840x2160@60,auto,1.5,bitdepth,8" | ||
8 | ]; | ||
9 | |||
10 | "$terminal" = "kitty"; | ||
11 | "$menu" = "fuzzel"; | ||
12 | |||
13 | env = [ | ||
14 | "NIXOS_OZONE_WL,1" | ||
15 | "QT_QPA_PLATFORM,wayland" | ||
16 | "QT_WAYLAND_DISABLE_WINDOWDECORATION,1" | ||
17 | "GDK_BACKEND,wayland" | ||
18 | "GDK_SCALE,0.66" | ||
19 | "QT_AUTO_SCREEN_SCALE_FACTOR,1" | ||
20 | "SDL_VIDEODRIVER,wayland" | ||
21 | # "AQ_DRM_DEVICES,/dev/dri/by-path/pci-0000:01:00.0-card" | ||
22 | "__NV_PRIME_RENDER_OFFLOAD,1" | ||
23 | "__NV_PRIME_RENDER_OFFLOAD_PROVIDER,NVIDIA-G0" | ||
24 | "__GLX_VENDOR_LIBRARY_NAME,nvidia" | ||
25 | "__VK_LAYER_NV_optimus,NVIDIA_only" | ||
26 | ]; | ||
27 | |||
28 | xwayland.force_zero_scaling = true; | ||
29 | |||
30 | general = { | ||
31 | gaps_in = 3; | ||
32 | gaps_out = 9; | ||
33 | "col.active_border" = "rgba(33ccffee) rgba(00ff95ee) 45deg"; | ||
34 | "col.inactive_border" = "rgba(595959aa)"; | ||
35 | |||
36 | resize_on_border = false; | ||
37 | |||
38 | allow_tearing = false; | ||
39 | |||
40 | layout = "dwindle"; | ||
41 | }; | ||
42 | |||
43 | decoration = { | ||
44 | rounding = 5; | ||
45 | dim_special = 0.0; | ||
46 | }; | ||
47 | |||
48 | animations = { | ||
49 | enabled = true; | ||
50 | bezier = "myBezier, 0.05, 0.9, 0.1, 1.05"; | ||
51 | animation = [ | ||
52 | "windows, 1, 1, default, popin 80%" | ||
53 | "windowsMove, 0" | ||
54 | # "windows, 1, 7, myBezier" | ||
55 | # "windowsOut, 1, 7, myBezier, popin 80%" | ||
56 | "border, 1, 10, default" | ||
57 | "borderangle, 1, 8, default" | ||
58 | "fade, 1, 1, default" | ||
59 | "workspaces, 1, 1, default, fade" | ||
60 | # "workspaces, 1, 6, default" | ||
61 | ]; | ||
62 | }; | ||
63 | |||
64 | dwindle = { | ||
65 | pseudotile = false; | ||
66 | preserve_split = true; | ||
67 | }; | ||
68 | |||
69 | master = { | ||
70 | new_status = "master"; | ||
71 | }; | ||
72 | |||
73 | misc = { | ||
74 | disable_hyprland_logo = true; | ||
75 | disable_splash_rendering = true; | ||
76 | # focus_on_activate = true; | ||
77 | mouse_move_enables_dpms = true; | ||
78 | key_press_enables_dpms = true; | ||
79 | new_window_takes_over_fullscreen = 1; | ||
80 | exit_window_retains_fullscreen = true; | ||
81 | }; | ||
82 | |||
83 | cursor = { | ||
84 | use_cpu_buffer = true; | ||
85 | hide_on_key_press = true; | ||
86 | no_hardware_cursors = 0; | ||
87 | }; | ||
88 | |||
89 | input = { | ||
90 | kb_layout = "us,us"; | ||
91 | kb_variant = "dvp,"; | ||
92 | kb_model = ""; | ||
93 | kb_options = "compose:caps,grp:win_space_toggle"; | ||
94 | kb_rules = ""; | ||
95 | |||
96 | follow_mouse = 1; | ||
97 | |||
98 | sensitivity = 0; | ||
99 | |||
100 | touchpad = { | ||
101 | natural_scroll = false; | ||
102 | }; | ||
103 | }; | ||
104 | |||
105 | device = [ | ||
106 | { name = "synaptics-tm3512-010"; | ||
107 | sensitivity = 0.4; | ||
108 | } | ||
109 | { name = "tpps/2-elan-trackpoint"; | ||
110 | sensitivity = 0.2; | ||
111 | } | ||
112 | { name = "logitech-ergo-m575"; | ||
113 | sensitivity = 1.333; | ||
114 | } | ||
115 | ]; | ||
116 | |||
117 | gestures = { | ||
118 | workspace_swipe = false; | ||
119 | }; | ||
120 | |||
121 | dwindle = { | ||
122 | # no_gaps_when_only = 1; | ||
123 | }; | ||
124 | |||
125 | "$mainMod" = "SUPER"; | ||
126 | |||
127 | bind = [ | ||
128 | "$mainMod, return, exec, $terminal" | ||
129 | "$mainMod, Q, killactive" | ||
130 | "$mainMod SHIFT, Q, exec, hyprctl kill" | ||
131 | "$mainMod, V, togglefloating" | ||
132 | "$mainMod, D, exec, $menu" | ||
133 | "$mainMod SHIFT, D, exec, $menu --list-executables-in-path" | ||
134 | # "$mainMod, J, togglesplit," | ||
135 | |||
136 | "$mainMod SHIFT, L, exec, loginctl lock-session" | ||
137 | "$mainMod SHIFT, E, exit" | ||
138 | |||
139 | "$mainMod, left, movefocus, l" | ||
140 | "$mainMod, right, movefocus, r" | ||
141 | "$mainMod, up, movefocus, u" | ||
142 | "$mainMod, down, movefocus, d" | ||
143 | "$mainMod SHIFT, left, swapwindow, l" | ||
144 | "$mainMod SHIFT, right, swapwindow, r" | ||
145 | "$mainMod SHIFT, up, swapwindow, u" | ||
146 | "$mainMod SHIFT, down, swapwindow, d" | ||
147 | |||
148 | "$mainMod, N, cyclenext, tiled" | ||
149 | "$mainMod, T, cyclenext, prev tiled" | ||
150 | "$mainMod SHIFT, N, swapnext" | ||
151 | "$mainMod SHIFT, T, swapnext, prev" | ||
152 | |||
153 | "$mainMod, G, focusmonitor, 0" | ||
154 | "$mainMod, C, focusmonitor, 1" | ||
155 | "$mainMod, R, focusmonitor, 2" | ||
156 | "$mainMod, L, focusmonitor, 3" | ||
157 | |||
158 | "$mainMod CTRL, G, movecurrentworkspacetomonitor, 0" | ||
159 | "$mainMod CTRL, C, movecurrentworkspacetomonitor, 1" | ||
160 | "$mainMod CTRL, R, movecurrentworkspacetomonitor, 2" | ||
161 | "$mainMod CTRL, L, movecurrentworkspacetomonitor, 3" | ||
162 | |||
163 | "$mainMod, F, fullscreen, 1" | ||
164 | "$mainMod SHIFT, F, fullscreen, 0" | ||
165 | "$mainMod CTRL SHIFT, F, fullscreenstate, 1, 2" | ||
166 | |||
167 | "$mainMod, code:14, workspace, 1" | ||
168 | "$mainMod, code:17, workspace, 2" | ||
169 | "$mainMod, code:13, workspace, 3" | ||
170 | "$mainMod, code:18, workspace, 4" | ||
171 | "$mainMod, code:12, workspace, 5" | ||
172 | "$mainMod, code:19, workspace, 6" | ||
173 | "$mainMod, code:11, workspace, 7" | ||
174 | "$mainMod, code:20, workspace, 8" | ||
175 | "$mainMod, code:15, workspace, 9" | ||
176 | "$mainMod, code:16, workspace, 10" | ||
177 | |||
178 | "$mainMod SHIFT, code:14, movetoworkspacesilent, 1" | ||
179 | "$mainMod SHIFT, code:17, movetoworkspacesilent, 2" | ||
180 | "$mainMod SHIFT, code:13, movetoworkspacesilent, 3" | ||
181 | "$mainMod SHIFT, code:18, movetoworkspacesilent, 4" | ||
182 | "$mainMod SHIFT, code:12, movetoworkspacesilent, 5" | ||
183 | "$mainMod SHIFT, code:19, movetoworkspacesilent, 6" | ||
184 | "$mainMod SHIFT, code:11, movetoworkspacesilent, 7" | ||
185 | "$mainMod SHIFT, code:20, movetoworkspacesilent, 8" | ||
186 | "$mainMod SHIFT, code:15, movetoworkspacesilent, 9" | ||
187 | "$mainMod SHIFT, code:16, movetoworkspacesilent, 10" | ||
188 | |||
189 | "$mainMod, semicolon, exec, dunstctl close" | ||
190 | "$mainMod SHIFT, semicolon, exec, dunstctl close-all" | ||
191 | "$mainMod, period, exec, dunstctl context" | ||
192 | "$mainMod, comma, exec, dunstctl history-pop" | ||
193 | |||
194 | "$mainMod ALT, E, exec, emacsclient -c" | ||
195 | "$mainMod ALT, Y, exec, ${pkgs.writeShellScript "yt-dlp" '' | ||
196 | export PATH="${lib.makeBinPath (with pkgs; [ wl-clipboard-rs socat ])}:$PATH" | ||
197 | socat STDIO UNIX-CONNECT:"$XDG_RUNTIME_DIR"/yt-dlp.sock <<<$'{ "urls": ["'"$(wl-paste)"$'"] }' | ||
198 | ''}" | ||
199 | "$mainMod ALT, L, exec, ${pkgs.writeShellScript "mpv" '' | ||
200 | export PATH="${lib.makeBinPath (with pkgs; [ wl-clipboard-rs ])}:$PATH" | ||
201 | exec mpv "$(wl-paste)" | ||
202 | ''}" | ||
203 | |||
204 | ", Print, exec, ${pkgs.writeShellScript "screenshot" '' | ||
205 | export PATH="${lib.makeBinPath (with pkgs; [ grim slurp wl-clipboard-rs coreutils ])}:$PATH" | ||
206 | |||
207 | outFile="$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" | ||
208 | grim -g "$(slurp -b 00000080 -c FFFFFFFF -s 00000000 -w 1)" "$outFile" | ||
209 | wl-copy --type image/png <"$outFile" | ||
210 | ''}" | ||
211 | "SHIFT, Print, exec, ${pkgs.writeShellScript "screenshot" '' | ||
212 | export PATH="${lib.makeBinPath (with pkgs; [ grim jq wl-clipboard-rs coreutils ])}:$PATH" | ||
213 | |||
214 | outFile="$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" | ||
215 | grim -o "$(hyprctl monitors -j | jq -r '.[] | select(.focused) | .name')" "$outFile" | ||
216 | wl-copy --type image/png <"$outFile" | ||
217 | ''}" | ||
218 | "CTRL SHIFT, Print, exec, ${pkgs.runCommand "picker" { | ||
219 | buildInputs = [ pkgs.makeWrapper ]; | ||
220 | } '' | ||
221 | makeWrapper ${lib.getExe pkgs.hyprpicker} $out \ | ||
222 | --prefix PATH : ${lib.makeBinPath [pkgs.wl-clipboard-rs]} | ||
223 | ''} -a" | ||
224 | "$mainMod, M, exec, ${pkgs.writeShellScript "qalc-fuzzel" '' | ||
225 | export PATH="${lib.makeBinPath (with pkgs; [ wl-clipboard-rs libqalculate cfg.programs.fuzzel.package coreutils findutils libnotify gnugrep ])}:$PATH" | ||
226 | |||
227 | RESULTS_DIR="$HOME/.cache/qalc-fuzzel" | ||
228 | prev() { | ||
229 | FOUND=false | ||
230 | while IFS= read -r line; do | ||
231 | [[ -n "$line" ]] || continue | ||
232 | FOUND=true | ||
233 | echo $line | ||
234 | done < <(export LC_ALL=C.UTF-8; echo; find "$RESULTS_DIR" -type f -printf $'%T@ %p\n' | sort -n | cut -d' ' -f2- | xargs -r cat) | ||
235 | $FOUND || echo | ||
236 | } | ||
237 | FUZZEL_RES=$(prev | fuzzel --dmenu --prompt "qalc> ") || exit $? | ||
238 | if [[ "$FUZZEL_RES" =~ .*\ =\ .* ]]; then | ||
239 | QALC_RES="$FUZZEL_RES" | ||
240 | QALC_RET=0 | ||
241 | else | ||
242 | QALC_RES=$(qalc "$FUZZEL_RES" 2>&1) | ||
243 | QALC_RET=$? | ||
244 | fi | ||
245 | [[ -n "$QALC_RES" ]] || exit 1 | ||
246 | EXISTING=false | ||
247 | fgrep -xrl "$QALC_RES" "$RESULTS_DIR" | xargs -r touch | ||
248 | [[ ''${PIPESTATUS[0]} -eq 0 ]] && EXISTING=true | ||
249 | if [[ $QALC_RET -eq 0 ]] && ! $EXISTING; then | ||
250 | RES_FILE="$RESULTS_DIR"/$(date -uIs).$(tr -Cd 'a-zA-Z0-9' </dev/random | head -c 10) | ||
251 | cat >"$RES_FILE" <<<"$QALC_RES" | ||
252 | fi | ||
253 | [[ "$QALC_RES" =~ .*\ =\ (.*) ]] && QALC_RES="''${BASH_REMATCH[1]}" | ||
254 | [[ $QALC_RET -eq 0 ]] && wl-copy "$QALC_RES" | ||
255 | notify-send "$QALC_RES" | ||
256 | ''}" | ||
257 | "$mainMod, E, exec, ${pkgs.writeShellScript "emoji-fuzzel" '' | ||
258 | export PATH="${lib.makeBinPath (with pkgs; [ cfg.programs.fuzzel.package wtype wl-clipboard-rs ])}:$PATH" | ||
259 | |||
260 | FUZZEL_RES=$(fuzzel --dmenu --prompt "emoji> " <$HOME/.local/share/emoji-data/list.txt) || exit $? | ||
261 | [[ -n "$FUZZEL_RES" ]] || exit 1 | ||
262 | wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste | ||
263 | ''}" | ||
264 | "$mainMod, B, exec, ${pkgs.writeShellScript "bring" '' | ||
265 | export PATH="${lib.makeBinPath (with pkgs; [ cfg.programs.fuzzel.package gawk gojq cfg.wayland.windowManager.hyprland.package ])}:$PATH" | ||
266 | |||
267 | state="$(hyprctl -j clients)" | ||
268 | active_window="$(hyprctl -j activewindow)" | ||
269 | active_workspace="$(hyprctl -j activeworkspace | gojq -r '.id')" | ||
270 | |||
271 | current_addr="$(echo "$active_window" | gojq -r '.address')" | ||
272 | |||
273 | window="$(echo "$state" | | ||
274 | gojq -r '.[] | select(.workspace.id == '"$active_workspace"') | select(.monitor != -1 ) | "\(.title)\t\(.address)"' | | ||
275 | fuzzel --log-level=warning --dmenu)" | ||
276 | |||
277 | addr="$(echo "$window" | awk -F $'\t' '{print $2}')" | ||
278 | |||
279 | if [[ "$addr" = "$current_addr" ]]; then | ||
280 | exit 0 | ||
281 | fi | ||
282 | |||
283 | fullscreen_on_same_ws="$(echo "$state" | gojq -r '.[] | select(.fullscreen == true) | select(.workspace.id == '"$active_workspace"') | .address')" | ||
284 | |||
285 | if [[ "$window" != "" ]]; then | ||
286 | if [[ "$fullscreen_on_same_ws" == "" ]]; then | ||
287 | hyprctl dispatch focuswindow address:"''${addr}" | ||
288 | else | ||
289 | # If we want to focus app_A and app_B is fullscreen on the same workspace, | ||
290 | # app_A will get focus, but app_B will remain on top. | ||
291 | # This monstrosity is to make sure app_A will end up on top instead. | ||
292 | # XXX: doesn't handle fullscreen 0, but I don't care. | ||
293 | hyprctl --batch "dispatch focuswindow address:''${fullscreen_on_same_ws}; dispatch fullscreen 1; dispatch focuswindow address:''${addr}; dispatch fullscreen 1" | ||
294 | fi | ||
295 | fi | ||
296 | ''}" | ||
297 | "$mainMod SHIFT, B, exec, ${pkgs.writeShellScript "bring" '' | ||
298 | export PATH="${lib.makeBinPath (with pkgs; [ cfg.programs.fuzzel.package gawk gojq cfg.wayland.windowManager.hyprland.package ])}:$PATH" | ||
299 | |||
300 | state="$(hyprctl -j clients)" | ||
301 | active_window="$(hyprctl -j activewindow)" | ||
302 | |||
303 | current_addr="$(echo "$active_window" | gojq -r '.address')" | ||
304 | |||
305 | window="$(echo "$state" | | ||
306 | gojq -r '.[] | select(.monitor != -1 ) | "\(.title)\t\(.workspace.name)\t\(.address)"' | | ||
307 | fuzzel --log-level=warning --dmenu)" | ||
308 | |||
309 | addr="$(echo "$window" | awk -F $'\t' '{print $3}')" | ||
310 | ws="$(echo "$window" | awk -F $'\t' '{print $2}')" | ||
311 | |||
312 | if [[ "$addr" = "$current_addr" ]]; then | ||
313 | exit 0 | ||
314 | fi | ||
315 | |||
316 | fullscreen_on_same_ws="$(echo "$state" | gojq -r ".[] | select(.fullscreen == true) | select(.workspace.name == \"$ws\") | .address")" | ||
317 | |||
318 | if [[ "$window" != "" ]]; then | ||
319 | if [[ "$fullscreen_on_same_ws" == "" ]]; then | ||
320 | hyprctl dispatch focuswindow address:"''${addr}" | ||
321 | else | ||
322 | # If we want to focus app_A and app_B is fullscreen on the same workspace, | ||
323 | # app_A will get focus, but app_B will remain on top. | ||
324 | # This monstrosity is to make sure app_A will end up on top instead. | ||
325 | # XXX: doesn't handle fullscreen 0, but I don't care. | ||
326 | hyprctl --batch "dispatch focuswindow address:''${fullscreen_on_same_ws}; dispatch fullscreen 1; dispatch focuswindow address:''${addr}; dispatch fullscreen 1" | ||
327 | fi | ||
328 | fi | ||
329 | ''}" | ||
330 | |||
331 | "$mainMod CTRL, return, togglespecialworkspace, term" | ||
332 | "$mainMod CTRL, e, togglespecialworkspace, edit" | ||
333 | "$mainMod CTRL, a, togglespecialworkspace, pwvucontrol" | ||
334 | "$mainMod CTRL, o, togglespecialworkspace, easyeffects" | ||
335 | "$mainMod CTRL, b, togglespecialworkspace, blueman" | ||
336 | "$mainMod CTRL, p, togglespecialworkspace, keepass" | ||
337 | ]; | ||
338 | bindm = [ | ||
339 | "$mainMod, mouse:272, movewindow" | ||
340 | "$mainMod, mouse:273, resizewindow" | ||
341 | ]; | ||
342 | bindel = [ | ||
343 | ", XF86MonBrightnessUp, exec, lightctl -d -e4 -n1 up" | ||
344 | ", XF86MonBrightnessDown, exec, lightctl -d -e4 -n1 down" | ||
345 | ", XF86AudioRaiseVolume, exec, volumectl -d -u up" | ||
346 | ", XF86AudioLowerVolume, exec, volumectl -d -u down" | ||
347 | ]; | ||
348 | bindl = [ | ||
349 | ", XF86AudioMute, exec, volumectl -d toggle-mute" | ||
350 | ", XF86AudioMicMute, exec, volumectl -d -m toggle-mute" | ||
351 | "$mainMod SHIFT, S, exec, systemctl suspend" | ||
352 | |||
353 | ", switch:off:Lid Switch,exec,hyprctl dispatch dpms on eDP-1" | ||
354 | ", switch:on:Lid Switch,exec,hyprctl dispatch dpms off eDP-1" | ||
355 | |||
356 | ", switch:off:Lid Switch,exec,${pkgs.writeShellScript "clamshell-off" '' | ||
357 | export PATH="${lib.makeBinPath (with pkgs; [ jq ])}:$PATH" | ||
358 | [[ $(hyprctl monitors -j | jq '.[] | select(.name == "eDP-1") | .disabled') = "true" ]] || exit 0 | ||
359 | |||
360 | hyprctl keyword monitor "eDP-1,3840x2160@60,auto,1.5" | ||
361 | ''}" | ||
362 | ", switch:on:Lid Switch,exec,${pkgs.writeShellScript "clamshell-on" '' | ||
363 | export PATH="${lib.makeBinPath (with pkgs; [ jq ])}:$PATH" | ||
364 | |||
365 | [[ $(hyprctl monitors -j | jq 'reduce (.[] | select(.disabled == false)) as $_ (0; .+1)') -gt 1 ]] || exit 0 | ||
366 | |||
367 | hyprctl keyword monitor "eDP-1,disable" | ||
368 | ''}" | ||
369 | ]; | ||
370 | |||
371 | windowrulev2 = [ | ||
372 | "suppressevent maximize fullscreen, class:.*" | ||
373 | |||
374 | # "maximize, class:^(Element|thunderbird)$" | ||
375 | "workspace special:pwvucontrol, class:^com\.saivert\.pwvucontrol$" | ||
376 | "workspace special:easyeffects, class:^com\.github\.wwmm\.easyeffects$" | ||
377 | "workspace special:blueman, class:^\.blueman-manager-wrapped$" | ||
378 | "workspace special:keepass silent, class:^org\.keepassxc\.KeePassXC$, title:^(?!Unlock Database.*)(?!.*(Access Request|Passkey credentials)).*$" | ||
379 | # "group set always lock invade, class:^Element$" | ||
380 | "workspace 2, class:^firefox$" | ||
381 | "workspace 4, class:^evince$" | ||
382 | "workspace 4, class:^imv$" | ||
383 | "workspace 4, class:^org\.pwmt\.zathura$" | ||
384 | "workspace 10, class:^mpv$" | ||
385 | "workspace 1, class:^Element$" | ||
386 | "workspace 1, class:^thunderbird$" | ||
387 | "workspace 5, class:^virt-manager$" | ||
388 | "workspace 5, class:^qemu$" | ||
389 | "float, class:^org\.keepassxc\.KeePassXC$, title:^.*Access Request$" | ||
390 | "center, class:^org\.keepassxc\.KeePassXC$, title:^.*Access Request$" | ||
391 | "float, class:^org\.keepassxc\.KeePassXC$, title:^.*Passkey credentials$" | ||
392 | "center, class:^org\.keepassxc\.KeePassXC$, title:^.*Passkey credentials$" | ||
393 | "float, class:^org\.keepassxc\.KeePassXC$, title:^Unlock Database.*$" | ||
394 | "center, class:^org\.keepassxc\.KeePassXC$, title:^Unlock Database.*$" | ||
395 | "float, class:^xdg-desktop-portal-gtk$" | ||
396 | "center, class:^xdg-desktop-portal-gtk$" | ||
397 | |||
398 | "bordercolor rgba(ffaa33ee) rgba(bfff00ee) 45deg, fullscreen:1" | ||
399 | "bordercolor rgba(3366ffee) rgba(6a00ffee) 45deg, xwayland:1" | ||
400 | "bordercolor rgba(6633ffee) rgba(ea00ffee) 45deg, xwayland:1, fullscreen:1" | ||
401 | ]; | ||
402 | |||
403 | workspace = [ | ||
404 | "s[true], gapsout:100" | ||
405 | |||
406 | "special:term, on-created-empty:kitty" | ||
407 | "special:edit, on-created-empty:emacsclient -c" | ||
408 | "special:pwvucontrol, on-created-empty:pwvucontrol" | ||
409 | "special:easyeffects, on-created-empty:easyeffects" | ||
410 | "special:blueman, on-created-empty:blueman-manager" | ||
411 | "special:keepass, on-created-empty:keepassxc" | ||
412 | |||
413 | "1, defaultName:comm" | ||
414 | "2, defaultName:web" | ||
415 | "3, defaultName:work" | ||
416 | "4, defaultName:read" | ||
417 | ]; | ||
418 | |||
419 | layerrule = [ | ||
420 | "blur, waybar" | ||
421 | "blur, launcher" | ||
422 | "noanim, notifications" | ||
423 | "blur, notifications" | ||
424 | ]; | ||
425 | } | ||
diff --git a/accounts/gkleen@sif/libvirt/default.nix b/accounts/gkleen@sif/libvirt/default.nix index f86a68a2..4e5a9b90 100644 --- a/accounts/gkleen@sif/libvirt/default.nix +++ b/accounts/gkleen@sif/libvirt/default.nix | |||
@@ -7,6 +7,7 @@ with flakeInputs.nixVirt.lib; | |||
7 | config = { | 7 | config = { |
8 | virtualisation.libvirt = { | 8 | virtualisation.libvirt = { |
9 | enable = true; | 9 | enable = true; |
10 | swtpm.enable = true; | ||
10 | connections."qemu:///session" = { | 11 | connections."qemu:///session" = { |
11 | domains = [ | 12 | domains = [ |
12 | { definition = domain.writeXML (updateManyAttrsByPath [ | 13 | { definition = domain.writeXML (updateManyAttrsByPath [ |
@@ -16,8 +17,8 @@ with flakeInputs.nixVirt.lib; | |||
16 | memory = { count = 16; unit = "GiB"; }; | 17 | memory = { count = 16; unit = "GiB"; }; |
17 | storage_vol = "/home/gkleen/.local/share/libvirt/images/lmmirzm-vmrz01.qcow2"; | 18 | storage_vol = "/home/gkleen/.local/share/libvirt/images/lmmirzm-vmrz01.qcow2"; |
18 | nvram_path = "/home/gkleen/.local/share/libvirt/lmmirzm-vmrz01.nvram"; | 19 | nvram_path = "/home/gkleen/.local/share/libvirt/lmmirzm-vmrz01.nvram"; |
19 | virtio_drive = false; | 20 | virtio_drive = true; |
20 | virtio_video = false; | 21 | virtio_video = true; |
21 | install_virtio = false; | 22 | install_virtio = false; |
22 | }) { | 23 | }) { |
23 | qemu-commandline.env = [ | 24 | qemu-commandline.env = [ |
@@ -33,11 +34,12 @@ with flakeInputs.nixVirt.lib; | |||
33 | os.bootmenu.enable = true; | 34 | os.bootmenu.enable = true; |
34 | devices.graphics = { | 35 | devices.graphics = { |
35 | listen.type = "address"; | 36 | listen.type = "address"; |
36 | # gl.enable = true; | 37 | gl.enable = false; |
37 | }; | 38 | }; |
39 | devices.video.model.acceleration.accel3d = false; | ||
38 | devices.interface = { | 40 | devices.interface = { |
39 | # model.type = "virtio"; | 41 | model.type = "virtio"; |
40 | model.type = "e1000e"; | 42 | # model.type = "e1000e"; |
41 | type = "bridge"; | 43 | type = "bridge"; |
42 | mac.address = "52:54:00:b9:f3:ed"; | 44 | mac.address = "52:54:00:b9:f3:ed"; |
43 | source.bridge = "rz-0971"; | 45 | source.bridge = "rz-0971"; |
@@ -47,6 +49,15 @@ with flakeInputs.nixVirt.lib; | |||
47 | type = "unix"; | 49 | type = "unix"; |
48 | target = { type = "virtio"; name = "org.qemu.guest_agent.0"; }; | 50 | target = { type = "virtio"; name = "org.qemu.guest_agent.0"; }; |
49 | } | 51 | } |
52 | { | ||
53 | type = "spicevmc"; | ||
54 | target = { type = "virtio"; name = "com.redhat.spice.0"; }; | ||
55 | } | ||
56 | { | ||
57 | type = "spiceport"; | ||
58 | target = { type = "virtio"; name = "org.spice-space.webdav.0"; }; | ||
59 | source.channel = "org.spice-space.webdav.0"; | ||
60 | } | ||
50 | ]; | 61 | ]; |
51 | devices.tpm.model = "tpm-tis"; | 62 | devices.tpm.model = "tpm-tis"; |
52 | })); | 63 | })); |
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix new file mode 100644 index 00000000..e4a93a49 --- /dev/null +++ b/accounts/gkleen@sif/niri/default.nix | |||
@@ -0,0 +1,850 @@ | |||
1 | { config, hostConfig, pkgs, lib, flakeInputs, ... }: | ||
2 | let | ||
3 | cfg = config.programs.niri; | ||
4 | |||
5 | kdl = flakeInputs.niri-flake.lib.kdl; | ||
6 | |||
7 | niri = cfg.package; | ||
8 | terminal = lib.getExe config.programs.kitty.package; | ||
9 | makoctl = lib.getExe' config.services.mako.package "makoctl"; | ||
10 | loginctl = lib.getExe' hostConfig.systemd.package "loginctl"; | ||
11 | systemctl = lib.getExe' hostConfig.systemd.package "systemctl"; | ||
12 | swayosd-client = lib.getExe' config.services.swayosd.package "swayosd-client"; | ||
13 | |||
14 | focus_or_spawn = pkgs.writeShellApplication { | ||
15 | name = "focus-or-spawn"; | ||
16 | runtimeInputs = [ niri pkgs.gojq pkgs.gnugrep pkgs.socat ]; | ||
17 | text = '' | ||
18 | window_select="$1" | ||
19 | shift | ||
20 | workspace_name="$1" | ||
21 | shift | ||
22 | |||
23 | workspaces_json="$(niri msg -j workspaces)" | ||
24 | workspace_output="$(jq -r --arg workspace_name "$workspace_name" '.[] | select(.name == $workspace_name) | .output' <<<"$workspaces_json")" | ||
25 | # active_workspace="$(jq -r --arg workspace_output "$workspace_output" '.[] | select(.output == $workspace_output and .is_active) | .id' <<<"$workspaces_json")" | ||
26 | active_output="$(jq -r '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" | ||
27 | if [[ $workspace_output != "$active_output" ]]; then | ||
28 | niri msg action move-workspace-to-monitor --reference "$workspace_name" "$active_output" | ||
29 | # socat STDIO "$NIRI_SOCKET" <<<'{"Action":{"FocusWorkspace":{"reference":{"Id":'"''${active_workspace}"'}}}}' | ||
30 | # niri msg action move-workspace-to-index --reference "$workspace_name" 1 | ||
31 | fi | ||
32 | |||
33 | while IFS=$'\n' read -r window_json; do | ||
34 | if [[ -n $(jq -c "$window_select" <<<"$window_json") ]]; then | ||
35 | if jq -e '.is_focused' <<<"$window_json" >/dev/null; then | ||
36 | niri msg action focus-workspace-previous | ||
37 | else | ||
38 | niri msg action focus-window --id "$(jq -r '.id' <<<"$window_json")" | ||
39 | fi | ||
40 | exit 0 | ||
41 | fi | ||
42 | done < <(niri msg -j windows | jq -c '.[]') | ||
43 | |||
44 | exec "$@" | ||
45 | ''; | ||
46 | }; | ||
47 | focus-or-spawn-action = config.lib.niri.actions.spawn (lib.getExe focus_or_spawn); | ||
48 | focus-or-spawn-action-app_id = app_id: focus-or-spawn-action ''select(.app_id == "${app_id}")''; | ||
49 | |||
50 | with_adjacent_workspace = pkgs.writeShellApplication { | ||
51 | name = "with-adjacent-workspace"; | ||
52 | runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; | ||
53 | text = '' | ||
54 | blacklist="$1" | ||
55 | shift | ||
56 | direction="$1" | ||
57 | shift | ||
58 | action="$1" | ||
59 | shift | ||
60 | |||
61 | workspaces_json="$(niri msg -j workspaces)" | ||
62 | active_workspace="$(jq -r '.[] | select(.is_focused) | .id' <<<"$workspaces_json")" | ||
63 | workspace_output="$(jq -r --arg active_workspace "$active_workspace" '.[] | select(.id == ($active_workspace | tonumber)) | .output' <<<"$workspaces_json")" | ||
64 | workspace_idx="$(jq -r '.[] | select(.is_focused) | .idx' <<<"$workspaces_json")" | ||
65 | |||
66 | jq_script='map(select(' | ||
67 | case "$direction" in | ||
68 | down) | ||
69 | # shellcheck disable=SC2016 | ||
70 | jq_script=''${jq_script}'.idx > ($workspace_idx | tonumber)';; | ||
71 | up) | ||
72 | # shellcheck disable=SC2016 | ||
73 | jq_script=''${jq_script}'.idx < ($workspace_idx | tonumber)';; | ||
74 | esac | ||
75 | # shellcheck disable=SC2016 | ||
76 | jq_script=''${jq_script}' and .output == $workspace_output and ((.name == null) or (.name | test($blacklist) | not)))) | sort_by(.idx)' | ||
77 | [[ $direction == "up" ]] && jq_script=''${jq_script}' | reverse' | ||
78 | jq_script=''${jq_script}' | .[0]' | ||
79 | |||
80 | workspace_json=$(jq -c --arg blacklist "$blacklist" --arg workspace_output "$workspace_output" --arg workspace_idx "$workspace_idx" "$jq_script" <<<"$workspaces_json") | ||
81 | [[ -n $workspace_json && $workspace_json != null ]] || exit 0 | ||
82 | jq --arg active_workspace "$active_workspace" -c "$action" <<<"$workspace_json" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" | ||
83 | ''; | ||
84 | }; | ||
85 | with-adjacent-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_adjacent_workspace) "^${lib.concatMapStringsSep "|" ({ name, ...}: name) cfg.scratchspaces}$"; | ||
86 | focus-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; | ||
87 | move-column-to-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}}}}''; | ||
88 | |||
89 | with_unnamed_workspace = pkgs.writeShellApplication { | ||
90 | name = "with-unnamed-workspace"; | ||
91 | runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; | ||
92 | text = '' | ||
93 | action="$1" | ||
94 | shift | ||
95 | |||
96 | workspaces_json="$(niri msg -j workspaces)" | ||
97 | active_output="$(jq -r '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" | ||
98 | active_workspace="$(jq -r '.[] | select(.is_focused) | .id' <<<"$workspaces_json")" | ||
99 | |||
100 | history_json="$(socat STDIO UNIX-CONNECT:"$XDG_RUNTIME_DIR"/niri-workspace-history.sock)" | ||
101 | workspace_json="$(jq -c --arg active_output "$active_output" --argjson history "$history_json" 'map(select(.output == $active_output and .name == null)) | map({"value": ., "history_idx": ((. as $workspace | ($history[$active_output] | index($workspace | .id))) as $active_idx | if $active_idx then $active_idx else ($history[$active_output] | length) + 1 end)}) | sort_by(.history_idx, .value.idx) | map(.value) | .[0]' <<<"$workspaces_json")" | ||
102 | [[ -n $workspace_json && $workspace_json != null ]] || exit 0 | ||
103 | jq --arg active_workspace "$active_workspace" -c "$action" <<<"$workspace_json" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" | ||
104 | ''; | ||
105 | }; | ||
106 | with-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_unnamed_workspace); | ||
107 | |||
108 | with_empty_unnamed_workspace = pkgs.writeShellApplication { | ||
109 | name = "with-empty-unnamed-workspace"; | ||
110 | runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; | ||
111 | text = '' | ||
112 | action="$1" | ||
113 | shift | ||
114 | |||
115 | workspaces_json="$(niri msg -j workspaces)" | ||
116 | active_output="$(jq '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" | ||
117 | target_workspace_id="$(jq --argjson active_output "$active_output" 'map(select(.active_window_id == null and .name == null and .output == $active_output)) | sort_by(.idx) | .[0].id' <<<"$workspaces_json")" | ||
118 | jq --argjson workspace_id "$target_workspace_id" -nc "$action" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" | ||
119 | ''; | ||
120 | }; | ||
121 | with-empty-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_empty_unnamed_workspace); | ||
122 | |||
123 | with_select_window = pkgs.writeShellApplication { | ||
124 | name = "with-select-window"; | ||
125 | runtimeInputs = [ niri pkgs.gojq pkgs.socat config.programs.fuzzel.package pkgs.gawk ]; | ||
126 | text = '' | ||
127 | window_select="$1" | ||
128 | shift | ||
129 | action="$1" | ||
130 | shift | ||
131 | |||
132 | windows_json="$(niri msg -j windows)" | ||
133 | active_workspace="$(jq -r '.[] | select(.is_focused) | .workspace_id' <<<"$windows_json")" | ||
134 | window_ix="$(gojq -r --arg active_workspace "$active_workspace" '.[] | select('"$window_select"') | "\(.title)\u0000icon\u001f\(.app_id)"' <<<"$windows_json" | fuzzel --log-level=warning --dmenu --index)" | ||
135 | # shellcheck disable=SC2016 | ||
136 | window_json="$(gojq -rc --arg active_workspace "$active_workspace" --arg window_ix "$window_ix" 'map(select('"$window_select"')) | .[($window_ix | tonumber)]' <<<"$windows_json")" | ||
137 | |||
138 | [[ -z "$window_json" ]] && exit 1 | ||
139 | |||
140 | jq -c "$action" <<<"$window_json" | socat STDIO "$NIRI_SOCKET" | ||
141 | ''; | ||
142 | }; | ||
143 | with-select-window-action = config.lib.niri.actions.spawn (lib.getExe with_select_window); | ||
144 | in { | ||
145 | imports = [ | ||
146 | ./waybar.nix | ||
147 | ./mako.nix | ||
148 | ./swayosd.nix | ||
149 | ]; | ||
150 | |||
151 | options = { | ||
152 | programs.niri.scratchspaces = lib.mkOption { | ||
153 | type = lib.types.listOf (lib.types.submodule ({ config, ... }: { | ||
154 | options = { | ||
155 | name = lib.mkOption { | ||
156 | type = lib.types.str; | ||
157 | }; | ||
158 | match = lib.mkOption { | ||
159 | type = lib.types.listOf (lib.types.attrsOf kdl.types.kdl-args); | ||
160 | default = []; | ||
161 | }; | ||
162 | exclude = lib.mkOption { | ||
163 | type = lib.types.listOf (lib.types.attrsOf kdl.types.kdl-args); | ||
164 | default = []; | ||
165 | }; | ||
166 | windowRuleExtra = lib.mkOption { | ||
167 | type = kdl.types.kdl-nodes; | ||
168 | default = []; | ||
169 | }; | ||
170 | key = lib.mkOption { | ||
171 | type = lib.types.nullOr lib.types.str; | ||
172 | default = null; | ||
173 | }; | ||
174 | spawn = lib.mkOption { | ||
175 | type = lib.types.nullOr (lib.types.listOf lib.types.str); | ||
176 | default = null; | ||
177 | }; | ||
178 | app-id = lib.mkOption { | ||
179 | type = lib.types.nullOr lib.types.str; | ||
180 | default = null; | ||
181 | }; | ||
182 | selector = lib.mkOption { | ||
183 | type = lib.types.nullOr lib.types.str; | ||
184 | default = null; | ||
185 | }; | ||
186 | }; | ||
187 | |||
188 | config = lib.mkMerge [ | ||
189 | (lib.mkIf (config.app-id != null) { | ||
190 | match = lib.mkDefault [ { app-id = "^${lib.escapeRegex config.app-id}$"; } ]; | ||
191 | selector = lib.mkDefault "select(.app_id == \"${config.app-id}\")"; | ||
192 | }) | ||
193 | ]; | ||
194 | })); | ||
195 | default = []; | ||
196 | }; | ||
197 | }; | ||
198 | |||
199 | config = { | ||
200 | systemd.user.services.xwayland-satellite = { | ||
201 | Unit = { | ||
202 | BindsTo = [ "graphical-session.target" ]; | ||
203 | PartOf = [ "graphical-session.target" ]; | ||
204 | After = [ "graphical-session.target" ]; | ||
205 | Requisite = [ "graphical-session.target" ]; | ||
206 | }; | ||
207 | Service = { | ||
208 | Type = "notify"; | ||
209 | NotifyAccess = "all"; | ||
210 | Environment = [ "DISPLAY=:0" ]; | ||
211 | ExecStart = ''${lib.getExe pkgs.xwayland-satellite-unstable} ''${DISPLAY}''; | ||
212 | ExecStartPre = "${systemctl} --user import-environment DISPLAY"; | ||
213 | StandardOutput = "journal"; | ||
214 | }; | ||
215 | Install = { | ||
216 | WantedBy = [ "graphical-session.target" ]; | ||
217 | }; | ||
218 | }; | ||
219 | |||
220 | services.swayidle = { | ||
221 | events = [ | ||
222 | { event = "after-resume"; command = "${lib.getExe niri} msg action power-on-monitors"; } | ||
223 | ]; | ||
224 | timeouts = [ | ||
225 | { timeout = 300; | ||
226 | command = "${lib.getExe niri} msg action power-off-monitors"; | ||
227 | } | ||
228 | ]; | ||
229 | }; | ||
230 | |||
231 | systemd.user.sockets.niri-workspace-history = { | ||
232 | Socket = { | ||
233 | ListenStream = "%t/niri-workspace-history.sock"; | ||
234 | SocketMode = "0600"; | ||
235 | }; | ||
236 | }; | ||
237 | systemd.user.services.niri-workspace-history = { | ||
238 | Unit = { | ||
239 | BindsTo = [ "niri.service" ]; | ||
240 | After = [ "niri.service" ]; | ||
241 | }; | ||
242 | Install = { | ||
243 | WantedBy = [ "niri.service" ]; | ||
244 | }; | ||
245 | Service = { | ||
246 | Type = "simple"; | ||
247 | Sockets = [ "niri-workspace-history.socket" ]; | ||
248 | ExecStart = pkgs.writers.writePython3 "niri-workspace-history" {} '' | ||
249 | import os | ||
250 | import socket | ||
251 | import json | ||
252 | import sys | ||
253 | from collections import defaultdict | ||
254 | from threading import Thread, Lock | ||
255 | from socketserver import StreamRequestHandler, ThreadingTCPServer | ||
256 | from contextlib import contextmanager | ||
257 | from io import TextIOWrapper | ||
258 | |||
259 | |||
260 | @contextmanager | ||
261 | def detaching(thing): | ||
262 | try: | ||
263 | yield thing | ||
264 | finally: | ||
265 | thing.detach() | ||
266 | |||
267 | |||
268 | workspace_history = defaultdict(list) | ||
269 | history_lock = Lock() | ||
270 | |||
271 | |||
272 | def monitor_niri(): | ||
273 | workspaces = list() | ||
274 | |||
275 | def focus_workspace(output, workspace): | ||
276 | global workspace_history, history_lock | ||
277 | |||
278 | with history_lock: | ||
279 | workspace_history[output] = [workspace] + [ws for ws in workspace_history[output] if ws != workspace] # noqa: E501 | ||
280 | print(json.dumps(workspace_history), file=sys.stderr) | ||
281 | |||
282 | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | ||
283 | sock.connect(os.environ["NIRI_SOCKET"]) | ||
284 | sock.send(b"\"EventStream\"\n") | ||
285 | for line in sock.makefile(buffering=1, encoding='utf-8'): | ||
286 | if line_json := json.loads(line): | ||
287 | if "WorkspacesChanged" in line_json: | ||
288 | workspaces = line_json["WorkspacesChanged"]["workspaces"] | ||
289 | for ws in workspaces: | ||
290 | if ws["is_focused"]: | ||
291 | focus_workspace(ws["output"], ws["id"]) | ||
292 | if "WorkspaceActivated" in line_json: | ||
293 | for ws in workspaces: | ||
294 | if ws["id"] != line_json["WorkspaceActivated"]["id"]: | ||
295 | continue | ||
296 | focus_workspace(ws["output"], ws["id"]) | ||
297 | break | ||
298 | |||
299 | |||
300 | class RequestHandler(StreamRequestHandler): | ||
301 | def handle(self): | ||
302 | global workspace_history, history_lock | ||
303 | |||
304 | with detaching(TextIOWrapper(self.wfile, encoding='utf-8', write_through=True)) as out: # noqa: E501 | ||
305 | with history_lock: | ||
306 | json.dump(workspace_history, out) | ||
307 | |||
308 | |||
309 | class Server(ThreadingTCPServer): | ||
310 | def __init__(self): | ||
311 | ThreadingTCPServer.__init__(self, ("", 8000), RequestHandler, bind_and_activate=False) # noqa: E501 | ||
312 | self.socket = socket.fromfd(3, self.address_family, self.socket_type) | ||
313 | |||
314 | |||
315 | def run_server(): | ||
316 | with Server() as server: | ||
317 | server.serve_forever() | ||
318 | |||
319 | |||
320 | niri = Thread(target=monitor_niri) | ||
321 | niri.daemon = True | ||
322 | niri.start() | ||
323 | |||
324 | server_thread = Thread(target=run_server) | ||
325 | server_thread.daemon = True | ||
326 | server_thread.start() | ||
327 | |||
328 | while True: | ||
329 | server_thread.join(timeout=0.5) | ||
330 | niri.join(timeout=0.5) | ||
331 | |||
332 | if not (niri.is_alive() and server_thread.is_alive()): | ||
333 | break | ||
334 | ''; | ||
335 | }; | ||
336 | }; | ||
337 | |||
338 | programs.niri.scratchspaces = [ | ||
339 | { name = "pwctl"; | ||
340 | key = "Mod+Control+A"; | ||
341 | spawn = ["pwvucontrol"]; | ||
342 | app-id = "com.saivert.pwvucontrol"; | ||
343 | } | ||
344 | { name = "kpxc"; | ||
345 | exclude = [ | ||
346 | { title = "^Unlock Database.*"; } | ||
347 | { title = "^Access Request.*"; } | ||
348 | { title = ".*Passkey credentials$"; } | ||
349 | ]; | ||
350 | windowRuleExtra = [ | ||
351 | (kdl.leaf "open-focused" false) | ||
352 | ]; | ||
353 | key = "Mod+Control+P"; | ||
354 | app-id = "org.keepassxc.KeePassXC"; | ||
355 | spawn = [ "keepassxc" ]; | ||
356 | } | ||
357 | { name = "bmgr"; | ||
358 | key = "Mod+Control+B"; | ||
359 | app-id = ".blueman-manager-wrapped"; | ||
360 | spawn = [ "blueman-manager" ]; | ||
361 | } | ||
362 | { name = "term"; | ||
363 | key = "Mod+Control+Return"; | ||
364 | app-id = "kitty-scratch"; | ||
365 | spawn = [ "kitty" "--app-id" "kitty-scratch" ]; | ||
366 | } | ||
367 | { name = "edit"; | ||
368 | match = [ { title = "^scratch$"; app-id = "^emacs$"; } ]; | ||
369 | key = "Mod+Control+E"; | ||
370 | selector = "select(.app_id == \"emacs\" and .title == \"scratch\")"; | ||
371 | spawn = [ "emacsclient" "-c" "--frame-parameters=(quote (name . \"scratch\"))" ]; | ||
372 | } | ||
373 | { name = "eff"; | ||
374 | key = "Mod+Control+O"; | ||
375 | app-id = "com.github.wwmm.easyeffects"; | ||
376 | spawn = [ "easyeffects" ]; | ||
377 | } | ||
378 | ]; | ||
379 | programs.niri.config = | ||
380 | let | ||
381 | inherit (kdl) node plain leaf flag; | ||
382 | optional-node = cond: v: | ||
383 | if cond | ||
384 | then v | ||
385 | else null; | ||
386 | opt-props = lib.filterAttrs (lib.const (value: value != null)); | ||
387 | in | ||
388 | [ (flag "prefer-no-csd") | ||
389 | |||
390 | (plain "hotkey-overlay" [ | ||
391 | (flag "skip-at-startup") | ||
392 | ]) | ||
393 | |||
394 | (plain "input" [ | ||
395 | (plain "keyboard" [ | ||
396 | (leaf "repeat-delay" 300) | ||
397 | (leaf "repeat-rate" 50) | ||
398 | |||
399 | (plain "xkb" [ | ||
400 | (leaf "layout" "us,us") | ||
401 | (leaf "variant" "dvp,") | ||
402 | (leaf "options" "compose:caps,grp:win_space_toggle") | ||
403 | ]) | ||
404 | ]) | ||
405 | |||
406 | (flag "workspace-auto-back-and-forth") | ||
407 | # (leaf "focus-follows-mouse" {}) | ||
408 | # (flag "warp-mouse-to-focus") | ||
409 | |||
410 | (plain "touchpad" [ (flag "off") ]) | ||
411 | (plain "trackball" [ | ||
412 | (leaf "scroll-method" "on-button-down") | ||
413 | (leaf "scroll-button" 278) | ||
414 | ]) | ||
415 | (plain "touch" [ | ||
416 | (leaf "map-to-output" "eDP-1") | ||
417 | ]) | ||
418 | ]) | ||
419 | |||
420 | (plain "environment" (lib.mapAttrsToList leaf { | ||
421 | NIXOS_OZONE_WL = "1"; | ||
422 | QT_QPA_PLATFORM = "wayland"; | ||
423 | QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; | ||
424 | GDK_BACKEND = "wayland"; | ||
425 | SDL_VIDEODRIVER = "wayland"; | ||
426 | DISPLAY = ":0"; | ||
427 | })) | ||
428 | |||
429 | (node "output" "eDP-1" [ | ||
430 | (leaf "scale" 1.5) | ||
431 | (leaf "position" { x = 0; y = 0; }) | ||
432 | ]) | ||
433 | (node "output" "Ancor Communications Inc ASUS PB287Q 0x0000DD9B" [ | ||
434 | (leaf "scale" 1.5) | ||
435 | (leaf "position" { x = 2560; y = 0; }) | ||
436 | ]) | ||
437 | (node "output" "HP Inc. HP 727pu CN4417143K" [ | ||
438 | (leaf "mode" "2560x1440@119.998") | ||
439 | (leaf "scale" 1) | ||
440 | (leaf "position" { x = 2560; y = 0; }) | ||
441 | (flag "variable-refresh-rate") | ||
442 | ]) | ||
443 | |||
444 | (plain "debug" [ | ||
445 | (leaf "render-drm-device" "/dev/dri/by-path/pci-0000:00:02.0-render") | ||
446 | ]) | ||
447 | |||
448 | (plain "animations" [ | ||
449 | (leaf "slowdown" 0.5) | ||
450 | (plain "workspace-switch" [(flag "off")]) | ||
451 | ]) | ||
452 | |||
453 | (plain "layout" [ | ||
454 | (leaf "gaps" 8) | ||
455 | (plain "struts" [ | ||
456 | (leaf "left" 0) | ||
457 | (leaf "right" 0) | ||
458 | (leaf "top" 0) | ||
459 | (leaf "bottom" 0) | ||
460 | ]) | ||
461 | (plain "border" [ | ||
462 | (leaf "width" 2) | ||
463 | (leaf "active-gradient" { | ||
464 | from = "hsla(195 100% 45% 1)"; | ||
465 | to = "hsla(155 100% 37.5% 1)"; | ||
466 | angle = 29; | ||
467 | relative-to = "workspace-view"; | ||
468 | }) | ||
469 | (leaf "inactive-gradient" { | ||
470 | from = "hsla(0 0% 27.7% 1)"; | ||
471 | to = "hsla(0 0% 23% 1)"; | ||
472 | angle = 29; | ||
473 | relative-to = "workspace-view"; | ||
474 | }) | ||
475 | ]) | ||
476 | (plain "focus-ring" [ | ||
477 | (flag "off") | ||
478 | ]) | ||
479 | |||
480 | (plain "preset-column-widths" (map (prop: leaf "proportion" prop) [ | ||
481 | (1. / 4.) (1. / 3.) (1. / 2.) (2. / 3.) (3. / 4.) (1.) | ||
482 | ])) | ||
483 | (plain "default-column-width" [ (leaf "proportion" (1. / 2.)) ]) | ||
484 | (plain "preset-window-heights" (map (prop: leaf "proportion" prop) [ | ||
485 | (1. / 3.) (1. / 2.) (2. / 3.) (1.) | ||
486 | ])) | ||
487 | |||
488 | (flag "always-center-single-column") | ||
489 | |||
490 | (plain "tab-indicator" [ | ||
491 | (leaf "gap" 4) | ||
492 | (leaf "width" 8) | ||
493 | (leaf "gaps-between-tabs" 4) | ||
494 | (flag "place-within-column") | ||
495 | (leaf "length" { total-proportion = 1.; }) | ||
496 | (leaf "active-gradient" { | ||
497 | from = "hsla(195 100% 60% 0.75)"; | ||
498 | to = "hsla(155 100% 50% 0.75)"; | ||
499 | angle = 29; | ||
500 | relative-to = "workspace-view"; | ||
501 | }) | ||
502 | (leaf "inactive-gradient" { | ||
503 | from = "hsla(0 0% 42% 0.66)"; | ||
504 | to = "hsla(0 0% 35% 0.66)"; | ||
505 | angle = 29; | ||
506 | relative-to = "workspace-view"; | ||
507 | }) | ||
508 | ]) | ||
509 | ]) | ||
510 | |||
511 | (plain "cursor" [ | ||
512 | (flag "hide-when-typing") | ||
513 | ]) | ||
514 | |||
515 | (map (name: | ||
516 | (node "workspace" name [ | ||
517 | (leaf "open-on-output" "eDP-1") | ||
518 | ]) | ||
519 | ) (map ({name, ...}: name) cfg.scratchspaces)) | ||
520 | (map (name: | ||
521 | (leaf "workspace" name) | ||
522 | ) ["comm" "web" "vid" "bmr"]) | ||
523 | |||
524 | (plain "window-rule" [ | ||
525 | (leaf "clip-to-geometry" true) | ||
526 | ]) | ||
527 | |||
528 | (plain "window-rule" [ | ||
529 | (leaf "match" { is-floating = true; }) | ||
530 | (leaf "geometry-corner-radius" 8) | ||
531 | (plain "shadow" [ (flag "on") ]) | ||
532 | ]) | ||
533 | |||
534 | (plain "window-rule" [ | ||
535 | (leaf "match" { app-id = "^org\\.keepassxc\\.KeePassXC$"; }) | ||
536 | (leaf "block-out-from" "screencast") | ||
537 | ]) | ||
538 | (plain "window-rule" [ | ||
539 | (map (title: | ||
540 | (leaf "match" { app-id = "^org\\.keepassxc\\.KeePassXC$"; inherit title; }) | ||
541 | ) ["^Unlock Database.*" "^Access Request.*" ".*Passkey credentials$"]) | ||
542 | (leaf "open-focused" true) | ||
543 | (leaf "open-floating" true) | ||
544 | ]) | ||
545 | |||
546 | (map ({ name, match, exclude, windowRuleExtra, ... }: | ||
547 | (optional-node (match != []) (plain "window-rule" [ | ||
548 | (map (leaf "match") match) | ||
549 | (map (leaf "exclude") exclude) | ||
550 | (leaf "open-on-workspace" name) | ||
551 | (leaf "open-maximized" true) | ||
552 | windowRuleExtra | ||
553 | ])) | ||
554 | ) cfg.scratchspaces) | ||
555 | |||
556 | (plain "window-rule" [ | ||
557 | (leaf "match" { app-id = "^emacs$"; }) | ||
558 | (leaf "match" { app-id = "^firefox$"; }) | ||
559 | (plain "default-column-width" [(leaf "proportion" (2. / 3.))]) | ||
560 | ]) | ||
561 | (plain "window-rule" [ | ||
562 | (leaf "match" { app-id = "^kitty$"; }) | ||
563 | (leaf "match" { app-id = "^kitty-play$"; }) | ||
564 | (plain "default-column-width" [(leaf "proportion" (1. / 3.))]) | ||
565 | ]) | ||
566 | |||
567 | (plain "window-rule" [ | ||
568 | (leaf "match" { app-id = "^thunderbird$"; }) | ||
569 | (leaf "match" { app-id = "^Element$"; }) | ||
570 | (leaf "match" { app-id = "^Rainbow$"; }) | ||
571 | (leaf "open-on-workspace" "comm") | ||
572 | ]) | ||
573 | (plain "window-rule" [ | ||
574 | (leaf "match" { app-id = "^firefox$"; }) | ||
575 | (leaf "open-on-workspace" "web") | ||
576 | (leaf "open-maximized" true) | ||
577 | ]) | ||
578 | (plain "window-rule" [ | ||
579 | (leaf "match" { app-id = "^mpv$"; }) | ||
580 | (leaf "open-on-workspace" "vid") | ||
581 | (plain "default-column-width" [(leaf "proportion" 1.)]) | ||
582 | ]) | ||
583 | (plain "window-rule" [ | ||
584 | (leaf "match" { app-id = "^kitty-play$"; }) | ||
585 | (leaf "open-on-workspace" "vid") | ||
586 | (leaf "open-focused" false) | ||
587 | ]) | ||
588 | (plain "window-rule" [ | ||
589 | (leaf "match" { app-id = "^pdfpc$"; }) | ||
590 | (plain "default-column-width" [(leaf "proportion" 1.)]) | ||
591 | ]) | ||
592 | (plain "window-rule" [ | ||
593 | (leaf "match" { app-id = "^pdfpc$"; title = "^pdfpc - presentation$"; }) | ||
594 | (plain "default-column-width" [(leaf "proportion" 1.)]) | ||
595 | (leaf "open-fullscreen" true) | ||
596 | (leaf "open-on-workspace" "bmr") | ||
597 | (leaf "open-focused" false) | ||
598 | ]) | ||
599 | (plain "window-rule" [ | ||
600 | (map (leaf "match") [ | ||
601 | { app-id = "^Gimp-"; title = "^Quit GIMP$"; } | ||
602 | { app-id = "^org\\.kde\\.polkit-kde-authentication-agent-1$"; } | ||
603 | { app-id = "^xdg-desktop-portal-gtk$"; } | ||
604 | ]) | ||
605 | (leaf "open-floating" true) | ||
606 | ]) | ||
607 | (plain "window-rule" [ | ||
608 | (leaf "match" { app-id = "^org\\.pwmt\\.zathura$"; }) | ||
609 | (leaf "match" { app-id = "^evince$"; }) | ||
610 | (leaf "default-column-display" "tabbed") | ||
611 | ]) | ||
612 | |||
613 | (plain "layer-rule" [ | ||
614 | (leaf "match" { namespace = "^notifications$"; }) | ||
615 | (leaf "match" { namespace = "^waybar$"; }) | ||
616 | (leaf "match" { namespace = "^launcher$"; }) | ||
617 | (leaf "block-out-from" "screencast") | ||
618 | ]) | ||
619 | |||
620 | (plain "binds" | ||
621 | (let | ||
622 | bind = name: cfg: node name (opt-props { | ||
623 | cooldown-ms = cfg.cooldown-ms or null; | ||
624 | } | ||
625 | // (lib.optionalAttrs (!(cfg.repeat or true)) { | ||
626 | repeat = false; | ||
627 | }) | ||
628 | // (lib.optionalAttrs (cfg.allow-when-locked or false) { | ||
629 | allow-when-locked = true; | ||
630 | })) (lib.mapAttrsToList leaf (lib.removeAttrs cfg.action ["__functor"])); | ||
631 | in | ||
632 | [ | ||
633 | (lib.mapAttrsToList bind (with config.lib.niri.actions; { | ||
634 | "Mod+Slash".action = show-hotkey-overlay; | ||
635 | |||
636 | "Mod+Return".action = spawn terminal; | ||
637 | "Mod+Q".action = close-window; | ||
638 | "Mod+O".action = spawn (lib.getExe config.programs.fuzzel.package); | ||
639 | "Mod+Shift+O".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path"; | ||
640 | |||
641 | "Mod+Alt+E".action = spawn (lib.getExe' config.services.emacs.package "emacsclient") "-c"; | ||
642 | "Mod+Alt+Y".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
643 | name = "queue-yt-dlp"; | ||
644 | runtimeInputs = with pkgs; [ wl-clipboard-rs socat ]; | ||
645 | text = '' | ||
646 | socat STDIO UNIX-CONNECT:"$XDG_RUNTIME_DIR"/yt-dlp.sock <<<$'{ "urls": ["'"$(wl-paste)"$'"] }' | ||
647 | ''; | ||
648 | })); | ||
649 | "Mod+Alt+L".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
650 | name = "queue-yt-dlp"; | ||
651 | runtimeInputs = with pkgs; [ wl-clipboard-rs config.programs.kitty.package ]; | ||
652 | text = '' | ||
653 | exec -- kitty --app-id kitty-play --directory "$HOME"/media mpv "$(wl-paste)" | ||
654 | ''; | ||
655 | })); | ||
656 | "Mod+Alt+M".action = spawn (lib.getExe' pkgs.screen-message "sm") "-n" "Fira Mono" "-a" "1" "-f" "#fff" "-b" "#000"; | ||
657 | |||
658 | "Mod+U".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
659 | name = "qalc-fuzzel"; | ||
660 | runtimeInputs = with pkgs; [ wl-clipboard-rs libqalculate config.programs.fuzzel.package coreutils findutils libnotify gnugrep ]; | ||
661 | text = '' | ||
662 | RESULTS_DIR="$HOME/.cache/qalc-fuzzel" | ||
663 | prev() { | ||
664 | FOUND=false | ||
665 | while IFS= read -r line; do | ||
666 | [[ -n "$line" ]] || continue | ||
667 | FOUND=true | ||
668 | echo "$line" | ||
669 | done < <(export LC_ALL=C.UTF-8; echo; find "$RESULTS_DIR" -type f -printf $'%T@ %p\n' | sort -n | cut -d' ' -f2- | xargs -r cat) | ||
670 | $FOUND || echo | ||
671 | } | ||
672 | FUZZEL_RES=$(prev | fuzzel --dmenu --prompt "qalc> ") || exit $? | ||
673 | if [[ "$FUZZEL_RES" =~ .*\ =\ .* ]]; then | ||
674 | QALC_RES="$FUZZEL_RES" | ||
675 | QALC_RET=0 | ||
676 | else | ||
677 | QALC_RES=$(qalc "$FUZZEL_RES" 2>&1) | ||
678 | QALC_RET=$? | ||
679 | fi | ||
680 | [[ -n "$QALC_RES" ]] || exit 1 | ||
681 | EXISTING=false | ||
682 | set +o pipefail | ||
683 | grep -Fxrl "$QALC_RES" "$RESULTS_DIR" | xargs -r touch | ||
684 | [[ ''${PIPESTATUS[0]} -eq 0 ]] && EXISTING=true | ||
685 | set -o pipefail | ||
686 | if [[ $QALC_RET -eq 0 ]] && ! $EXISTING; then | ||
687 | set +o pipefail | ||
688 | RES_FILE="$RESULTS_DIR"/$(date -uIs).$(tr -Cd 'a-zA-Z0-9' </dev/random | head -c 10) | ||
689 | set -o pipefail | ||
690 | cat >"$RES_FILE" <<<"$QALC_RES" | ||
691 | fi | ||
692 | [[ "$QALC_RES" =~ .*\ =\ (.*) ]] && QALC_RES="''${BASH_REMATCH[1]}" | ||
693 | [[ $QALC_RET -eq 0 ]] && wl-copy "$QALC_RES" | ||
694 | notify-send "$QALC_RES" | ||
695 | ''; | ||
696 | })); | ||
697 | "Mod+E".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
698 | name = "emoji-fuzzel"; | ||
699 | runtimeInputs = with pkgs; [ config.programs.fuzzel.package wtype wl-clipboard-rs ]; | ||
700 | text = '' | ||
701 | FUZZEL_RES=$(fuzzel --dmenu --prompt "emoji> " <"$HOME"/.local/share/emoji-data/list.txt) || exit $? | ||
702 | [[ -n "$FUZZEL_RES" ]] || exit 1 | ||
703 | wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste | ||
704 | ''; | ||
705 | })); | ||
706 | "Print".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
707 | name = "screenshot"; | ||
708 | runtimeInputs = with pkgs; [ grim slurp wl-clipboard-rs coreutils ]; | ||
709 | text = '' | ||
710 | grim -g "$(slurp -b 00000080 -c FFFFFFFF -s 00000000 -w 1)" - \ | ||
711 | | tee "$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" \ | ||
712 | | wl-copy --type image/png | ||
713 | ''; | ||
714 | })); | ||
715 | "Shift+Print".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
716 | name = "screenshot"; | ||
717 | runtimeInputs = with pkgs; [ grim niri gojq wl-clipboard-rs coreutils ]; | ||
718 | text = '' | ||
719 | grim -o "$(niri msg -j workspaces | jq -r '.[] | select(.is_focused) | .output')" - \ | ||
720 | | tee "$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" \ | ||
721 | | wl-copy --type image/png | ||
722 | ''; | ||
723 | })); | ||
724 | "Mod+B".action = with-select-window-action ".workspace_id == ($active_workspace | tonumber)" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; | ||
725 | "Mod+Shift+B".action = with-select-window-action "true" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; | ||
726 | |||
727 | "Mod+H".action = focus-column-left; | ||
728 | "Mod+T".action = focus-window-down; | ||
729 | "Mod+N".action = focus-window-up; | ||
730 | "Mod+S".action = focus-column-right; | ||
731 | |||
732 | "Mod+Shift+H".action = move-column-left; | ||
733 | "Mod+Shift+T".action = move-window-down; | ||
734 | "Mod+Shift+N".action = move-window-up; | ||
735 | "Mod+Shift+S".action = move-column-right; | ||
736 | |||
737 | "Mod+Control+H".action = focus-monitor-left; | ||
738 | "Mod+Control+T".action = focus-monitor-down; | ||
739 | "Mod+Control+N".action = focus-monitor-up; | ||
740 | "Mod+Control+S".action = focus-monitor-right; | ||
741 | |||
742 | "Mod+Shift+Control+H".action = move-workspace-to-monitor-left; | ||
743 | "Mod+Shift+Control+T".action = move-workspace-to-monitor-down; | ||
744 | "Mod+Shift+Control+N".action = move-workspace-to-monitor-up; | ||
745 | "Mod+Shift+Control+S".action = move-workspace-to-monitor-right; | ||
746 | |||
747 | "Mod+G".action = focus-adjacent-workspace "down"; | ||
748 | "Mod+C".action = focus-adjacent-workspace "up"; | ||
749 | |||
750 | "Mod+Shift+G".action = move-column-to-adjacent-workspace "down"; | ||
751 | "Mod+Shift+C".action = move-column-to-adjacent-workspace "up"; | ||
752 | |||
753 | "Mod+Shift+Control+G".action = move-workspace-down; | ||
754 | "Mod+Shift+Control+C".action = move-workspace-up; | ||
755 | |||
756 | "Mod+ParenLeft".action = focus-workspace "comm"; | ||
757 | "Mod+Shift+ParenLeft".action = move-column-to-workspace "comm"; | ||
758 | |||
759 | "Mod+ParenRight".action = focus-workspace "web"; | ||
760 | "Mod+Shift+ParenRight".action = move-column-to-workspace "web"; | ||
761 | |||
762 | "Mod+BraceRight".action = focus-workspace "read"; | ||
763 | "Mod+Shift+BraceRight".action = move-column-to-workspace "read"; | ||
764 | |||
765 | "Mod+BraceLeft".action = focus-workspace "mon"; | ||
766 | "Mod+Shift+BraceLeft".action = move-column-to-workspace "mon"; | ||
767 | |||
768 | "Mod+Asterisk".action = focus-workspace "vid"; | ||
769 | "Mod+Shift+Asterisk".action = move-column-to-workspace "vid"; | ||
770 | |||
771 | "Mod+Plus".action = with-unnamed-workspace-action ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; | ||
772 | "Mod+Shift+Plus".action = with-unnamed-workspace-action ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}}}}''; | ||
773 | |||
774 | "Mod+M".action = consume-or-expel-window-left; | ||
775 | "Mod+W".action = consume-or-expel-window-right; | ||
776 | |||
777 | "Mod+Shift+M".action = toggle-column-tabbed-display; | ||
778 | |||
779 | "Mod+R".action = switch-preset-column-width; | ||
780 | "Mod+Shift+R".action = switch-preset-window-height; | ||
781 | "Mod+F".action = center-column; | ||
782 | "Mod+Shift+F".action = maximize-column; | ||
783 | "Mod+Shift+Ctrl+F".action = fullscreen-window; | ||
784 | |||
785 | "Mod+V".action = switch-focus-between-floating-and-tiling; | ||
786 | "Mod+Shift+V".action = toggle-window-floating; | ||
787 | |||
788 | "Mod+Left".action = set-column-width "-10%"; | ||
789 | "Mod+Down".action = set-window-height "-10%"; | ||
790 | "Mod+Up".action = set-window-height "+10%"; | ||
791 | "Mod+Right".action = set-column-width "+10%"; | ||
792 | |||
793 | "Mod+Shift+Z" = { | ||
794 | action = spawn (lib.getExe niri) "msg" "action" "power-off-monitors"; | ||
795 | allow-when-locked = true; | ||
796 | }; | ||
797 | "Mod+Shift+L".action = spawn loginctl "lock-session"; | ||
798 | "Mod+Shift+E".action = quit; | ||
799 | "Mod+Shift+Minus" = { | ||
800 | action = spawn systemctl "suspend"; | ||
801 | allow-when-locked = true; | ||
802 | }; | ||
803 | "Mod+Shift+Control+Minus" = { | ||
804 | action = spawn systemctl "hibernate"; | ||
805 | allow-when-locked = true; | ||
806 | }; | ||
807 | "Mod+Shift+P" = { | ||
808 | action = spawn (lib.getExe pkgs.playerctl) "-a" "pause"; | ||
809 | allow-when-locked = true; | ||
810 | }; | ||
811 | |||
812 | "XF86MonBrightnessUp" = { | ||
813 | action = spawn swayosd-client "--brightness" "raise"; | ||
814 | allow-when-locked = true; | ||
815 | }; | ||
816 | "XF86MonBrightnessDown" = { | ||
817 | action = spawn swayosd-client "--brightness" "lower"; | ||
818 | allow-when-locked = true; | ||
819 | }; | ||
820 | "XF86AudioRaiseVolume" = { | ||
821 | action = spawn swayosd-client "--output-volume" "raise"; | ||
822 | allow-when-locked = true; | ||
823 | }; | ||
824 | "XF86AudioLowerVolume" = { | ||
825 | action = spawn swayosd-client "--output-volume" "lower"; | ||
826 | allow-when-locked = true; | ||
827 | }; | ||
828 | "XF86AudioMute" = { | ||
829 | action = spawn swayosd-client "--output-volume" "mute-toggle"; | ||
830 | allow-when-locked = true; | ||
831 | }; | ||
832 | "XF86AudioMicMute" = { | ||
833 | action = spawn swayosd-client "--input-volume" "mute-toggle"; | ||
834 | allow-when-locked = true; | ||
835 | }; | ||
836 | |||
837 | "Mod+Semicolon".action = spawn makoctl "dismiss" "--group"; | ||
838 | "Mod+Shift+Semicolon".action = spawn makoctl "dismiss" "--all"; | ||
839 | "Mod+Period".action = spawn makoctl "menu" (lib.getExe config.programs.fuzzel.package) "--dmenu"; | ||
840 | "Mod+Comma".action = spawn makoctl "restore"; | ||
841 | |||
842 | "Mod+Control+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"FocusWorkspace\":{\"reference\":{\"Id\": $workspace_id}}}}"; | ||
843 | "Mod+Control+Shift+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"MoveColumnToWorkspace\":{\"reference\":{\"Id\": $workspace_id}}}}"; | ||
844 | })) | ||
845 | (map ({ name, selector, spawn, key, ...}: if key != null && selector != null && spawn != null then bind key { action = focus-or-spawn-action selector name spawn; } else null) cfg.scratchspaces) | ||
846 | ] | ||
847 | )) | ||
848 | ]; | ||
849 | }; | ||
850 | } | ||
diff --git a/accounts/gkleen@sif/niri/mako.nix b/accounts/gkleen@sif/niri/mako.nix new file mode 100644 index 00000000..2788fb82 --- /dev/null +++ b/accounts/gkleen@sif/niri/mako.nix | |||
@@ -0,0 +1,119 @@ | |||
1 | { config, lib, pkgs, ... }: | ||
2 | { | ||
3 | config = { | ||
4 | services.mako = { | ||
5 | enable = true; | ||
6 | font = "Fira Sans 10"; | ||
7 | format = "<i>%s</i>\\n%b"; | ||
8 | margin = "2"; | ||
9 | maxVisible = -1; | ||
10 | backgroundColor = "#000000dd"; | ||
11 | progressColor = "source #223544ff"; | ||
12 | width = 384; | ||
13 | extraConfig = '' | ||
14 | outer-margin=1 | ||
15 | max-history=100 | ||
16 | max-icon-size=48 | ||
17 | |||
18 | [grouped] | ||
19 | format=<b>(%g)</b> <i>%s</i>\n%b | ||
20 | |||
21 | [urgency=low] | ||
22 | text-color=#999999ff | ||
23 | |||
24 | [urgency=critical] | ||
25 | background-color=#900000dd | ||
26 | |||
27 | [app-name=Element] | ||
28 | group-by=summary | ||
29 | |||
30 | [app-name=poweralertd] | ||
31 | ignore-timeout=1 | ||
32 | default-timeout=2000 | ||
33 | |||
34 | [mode=silent] | ||
35 | invisible=1 | ||
36 | ''; | ||
37 | package = pkgs.symlinkJoin { | ||
38 | name = "${pkgs.mako.name}-wrapped"; | ||
39 | paths = with pkgs; [ mako ]; | ||
40 | inherit (pkgs.mako) meta; | ||
41 | postBuild = '' | ||
42 | rm -r $out/share/dbus-1 | ||
43 | ''; | ||
44 | }; | ||
45 | }; | ||
46 | systemd.user.services.mako = { | ||
47 | Unit = { | ||
48 | Description = "Mako notification daemon"; | ||
49 | PartOf = [ "graphical-session.target" ]; | ||
50 | }; | ||
51 | Install = { | ||
52 | WantedBy = [ "graphical-session.target" ]; | ||
53 | }; | ||
54 | Service = { | ||
55 | Type = "dbus"; | ||
56 | BusName = "org.freedesktop.Notifications"; | ||
57 | ExecStart = lib.getExe config.services.mako.package; | ||
58 | RestartSec = 5; | ||
59 | Restart = "always"; | ||
60 | }; | ||
61 | }; | ||
62 | |||
63 | systemd.user.services.mako-follows-focus = { | ||
64 | Unit = { | ||
65 | BindsTo = [ "niri.service" "mako.service" ]; | ||
66 | After = [ "niri.service" "mako.service" ]; | ||
67 | }; | ||
68 | Service = { | ||
69 | Type = "simple"; | ||
70 | Restart = "always"; | ||
71 | ExecStart = pkgs.writers.writePython3 "mako-follows-focus" { | ||
72 | libraries = with pkgs.python3Packages; []; | ||
73 | } '' | ||
74 | import os | ||
75 | import socket | ||
76 | import json | ||
77 | import subprocess | ||
78 | |||
79 | |||
80 | current_output = None | ||
81 | workspaces = [] | ||
82 | |||
83 | |||
84 | def output_changed(new_output): | ||
85 | global current_output | ||
86 | |||
87 | if current_output == new_output: | ||
88 | return | ||
89 | |||
90 | current_output = new_output | ||
91 | subprocess.run(["makoctl", "reload"]) | ||
92 | |||
93 | |||
94 | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | ||
95 | sock.connect(os.environ["NIRI_SOCKET"]) | ||
96 | sock.send(b"\"EventStream\"\n") | ||
97 | for line in sock.makefile(buffering=1, encoding='utf-8'): | ||
98 | if line_json := json.loads(line): | ||
99 | if "WorkspacesChanged" in line_json: | ||
100 | workspaces = line_json["WorkspacesChanged"]["workspaces"] | ||
101 | for workspace in workspaces: | ||
102 | if not workspace["is_focused"]: | ||
103 | continue | ||
104 | output_changed(workspace["output"]) | ||
105 | break | ||
106 | if "WorkspaceActivated" in line_json and line_json["WorkspaceActivated"]["focused"]: # noqa: E501 | ||
107 | for workspace in workspaces: | ||
108 | if not workspace["id"] == line_json["WorkspaceActivated"]["id"]: # noqa: E501 | ||
109 | continue | ||
110 | output_changed(workspace["output"]) | ||
111 | break | ||
112 | ''; | ||
113 | }; | ||
114 | Install = { | ||
115 | WantedBy = [ "mako.service" ]; | ||
116 | }; | ||
117 | }; | ||
118 | }; | ||
119 | } | ||
diff --git a/accounts/gkleen@sif/niri/swayosd.nix b/accounts/gkleen@sif/niri/swayosd.nix new file mode 100644 index 00000000..984927c2 --- /dev/null +++ b/accounts/gkleen@sif/niri/swayosd.nix | |||
@@ -0,0 +1,65 @@ | |||
1 | { pkgs, ... }: | ||
2 | { | ||
3 | config = { | ||
4 | services.swayosd = { | ||
5 | enable = true; | ||
6 | topMargin = 0.946154; | ||
7 | stylePath = pkgs.runCommand "style.css" { | ||
8 | src = pkgs.writeText "style.scss" '' | ||
9 | window#osd { | ||
10 | padding: 12px 20px; | ||
11 | border-radius: 999px; | ||
12 | border: none; | ||
13 | background: rgba(0, 0, 0, 0.87); | ||
14 | |||
15 | #container { | ||
16 | margin: 16px; | ||
17 | } | ||
18 | |||
19 | image, | ||
20 | label { | ||
21 | color: rgb(255, 255, 255); | ||
22 | |||
23 | &:disabled { | ||
24 | opacity: 1; | ||
25 | color: rgb(84, 84, 84); | ||
26 | } | ||
27 | } | ||
28 | |||
29 | progressbar { | ||
30 | min-height: 6px; | ||
31 | border-radius: 999px; | ||
32 | background: transparent; | ||
33 | border: none; | ||
34 | |||
35 | trough, progress { | ||
36 | min-height: inherit; | ||
37 | border-radius: inherit; | ||
38 | border: none; | ||
39 | } | ||
40 | |||
41 | trough { | ||
42 | background: rgb(127, 127, 127); | ||
43 | } | ||
44 | progress { | ||
45 | background: rgb(255, 255, 255); | ||
46 | } | ||
47 | |||
48 | &:disabled { | ||
49 | opacity: 1; | ||
50 | |||
51 | trough { | ||
52 | background: rgb(19, 19, 19); | ||
53 | } | ||
54 | progress { | ||
55 | background: rgb(38, 38, 38); | ||
56 | } | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | ''; | ||
61 | buildInputs = with pkgs; [sass]; | ||
62 | } "scss -C --sourcemap=none --style=compact $src $out"; | ||
63 | }; | ||
64 | }; | ||
65 | } | ||
diff --git a/accounts/gkleen@sif/niri/waybar.nix b/accounts/gkleen@sif/niri/waybar.nix new file mode 100644 index 00000000..bae818f6 --- /dev/null +++ b/accounts/gkleen@sif/niri/waybar.nix | |||
@@ -0,0 +1,347 @@ | |||
1 | { lib, config, pkgs, ... }: | ||
2 | let | ||
3 | swayosd-client = lib.getExe' config.services.swayosd.package "swayosd-client"; | ||
4 | in { | ||
5 | config = { | ||
6 | programs.waybar = { | ||
7 | enable = true; | ||
8 | systemd = { | ||
9 | enable = true; | ||
10 | target = "graphical-session.target"; | ||
11 | }; | ||
12 | settings = let | ||
13 | windowRewrites = { | ||
14 | "(.*) — Mozilla Firefox" = "$1"; | ||
15 | "(.*) - Mozilla Thunderbird" = "$1"; | ||
16 | "(.*) - mpv" = "$1"; | ||
17 | }; | ||
18 | iconSize = 11; | ||
19 | in [ | ||
20 | { | ||
21 | layer = "top"; | ||
22 | position = "top"; | ||
23 | height = 14; | ||
24 | output = [ "eDP-1" "DP-2" "DP-3" ]; | ||
25 | modules-left = [ "niri/workspaces" ]; | ||
26 | modules-center = [ "niri/window" ]; | ||
27 | modules-right = [ "custom/worktime" "custom/worktime-today" | ||
28 | "custom/weather" | ||
29 | "custom/keymap" | ||
30 | "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "custom/mako" "clock" ]; | ||
31 | |||
32 | "custom/mako" = { | ||
33 | format = "{}"; | ||
34 | return-type = "json"; | ||
35 | exec = pkgs.writers.writePython3 "mako-silent" { libraries = [ pkgs.python3Packages.dbus-next ]; } '' | ||
36 | from dbus_next.aio import MessageBus | ||
37 | |||
38 | import asyncio | ||
39 | |||
40 | import json | ||
41 | |||
42 | |||
43 | loop = asyncio.new_event_loop() | ||
44 | asyncio.set_event_loop(loop) | ||
45 | |||
46 | |||
47 | async def main(): | ||
48 | bus = await MessageBus().connect() | ||
49 | # the introspection xml would normally be included in your project, but | ||
50 | # this is convenient for development | ||
51 | introspection = await bus.introspect('org.freedesktop.Notifications', '/fr/emersion/Mako') # noqa: E501 | ||
52 | |||
53 | obj = bus.get_proxy_object('org.freedesktop.Notifications', '/fr/emersion/Mako', introspection) # noqa: E501 | ||
54 | mako = obj.get_interface('fr.emersion.Mako') | ||
55 | properties = obj.get_interface('org.freedesktop.DBus.Properties') | ||
56 | |||
57 | async def print_mode(): | ||
58 | modes = await mako.get_modes() | ||
59 | is_silent = "silent" in modes | ||
60 | icon = "󰂛" if is_silent else "󰂚" | ||
61 | text = f"<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>" # noqa: E501 | ||
62 | if is_silent: | ||
63 | text = f"<span color=\"#ffffff\">{text}</span>" | ||
64 | print(json.dumps({'text': text, 'tooltip': ', '.join(modes)}, separators=(',', ':')), flush=True) # noqa: E501 | ||
65 | |||
66 | async def on_properties_changed(interface_name, changed_properties, invalidated_properties): # noqa: E501 | ||
67 | if "Modes" not in invalidated_properties: | ||
68 | return | ||
69 | |||
70 | await print_mode() | ||
71 | |||
72 | properties.on_properties_changed(on_properties_changed) | ||
73 | await print_mode() | ||
74 | |||
75 | await loop.create_future() | ||
76 | |||
77 | |||
78 | loop.run_until_complete(main()) | ||
79 | ''; | ||
80 | on-click = "makoctl mode -t silent"; | ||
81 | }; | ||
82 | "custom/weather" = { | ||
83 | format = "{}"; | ||
84 | tooltip = true; | ||
85 | interval = 3600; | ||
86 | exec = "${lib.getExe pkgs.wttrbar} --hide-conditions --nerd --custom-indicator \"<span font=\\\"Symbols Nerd Font Mono\\\" size=\\\"100%\\\">{ICON}</span> {FeelsLikeC}°\""; | ||
87 | return-type = "json"; | ||
88 | }; | ||
89 | "custom/keymap" = { | ||
90 | format = "{}"; | ||
91 | tooltip = true; | ||
92 | return-type = "json"; | ||
93 | exec = pkgs.writers.writePython3 "keymap" {} '' | ||
94 | import os | ||
95 | import socket | ||
96 | import json | ||
97 | |||
98 | |||
99 | def output(keymap): | ||
100 | short = keymap | ||
101 | if keymap == "English (programmer Dvorak)": | ||
102 | short = "dvp" | ||
103 | elif keymap == "English (US)": | ||
104 | short = "<span color=\"#ffffff\">us</span>" | ||
105 | print(json.dumps({'text': short, 'tooltip': keymap}, separators=(',', ':')), flush=True) # noqa: E501 | ||
106 | |||
107 | |||
108 | keyboard_layouts = [] | ||
109 | |||
110 | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | ||
111 | sock.connect(os.environ["NIRI_SOCKET"]) | ||
112 | sock.send(b"\"EventStream\"\n") | ||
113 | for line in sock.makefile(buffering=1, encoding='utf-8'): | ||
114 | if line_json := json.loads(line): | ||
115 | if "KeyboardLayoutsChanged" in line_json: | ||
116 | keyboard_layouts = line_json["KeyboardLayoutsChanged"]["keyboard_layouts"]["names"] # noqa: E501 | ||
117 | output(keyboard_layouts[line_json["KeyboardLayoutsChanged"]["keyboard_layouts"]["current_idx"]]) # noqa: E501 | ||
118 | if "KeyboardLayoutSwitched" in line_json: | ||
119 | output(keyboard_layouts[line_json["KeyboardLayoutSwitched"]["idx"]]) # noqa: E501 | ||
120 | ''; | ||
121 | on-click = "niri msg action switch-layout next"; | ||
122 | }; | ||
123 | "custom/worktime" = { | ||
124 | interval = 60; | ||
125 | exec = "${lib.getExe pkgs.worktime} time --waybar"; | ||
126 | return-type = "json"; | ||
127 | }; | ||
128 | "custom/worktime-today" = { | ||
129 | interval = 60; | ||
130 | exec = "${lib.getExe pkgs.worktime} today --waybar"; | ||
131 | return-type = "json"; | ||
132 | }; | ||
133 | "niri/workspaces" = { | ||
134 | ignore = map ({ name, ... }: name) config.programs.niri.scratchspaces; | ||
135 | }; | ||
136 | "niri/window" = { | ||
137 | separate-outputs = true; | ||
138 | icon = true; | ||
139 | icon-size = 14; | ||
140 | rewrite = windowRewrites; | ||
141 | }; | ||
142 | clock = { | ||
143 | interval = 1; | ||
144 | # timezone = "Europe/Berlin"; | ||
145 | format = "W{:%V-%u %F %H:%M:%S%Ez}"; | ||
146 | tooltip-format = "<tt><small>{calendar}</small></tt>"; | ||
147 | calendar = { | ||
148 | mode = "year"; | ||
149 | mode-mon-col = 3; | ||
150 | weeks-pos = "left"; | ||
151 | on-scroll = 1; | ||
152 | format = { | ||
153 | months = "<span color='#ffead3'><b>{}</b></span>"; | ||
154 | days = "{}"; | ||
155 | weeks = "<span color='#99ffdd'><b>{}</b></span>"; | ||
156 | weekdays = "<span color='#ffcc66'><b>{}</b></span>"; | ||
157 | today = "<span color='#ff6699'><b>{}</b></span>"; | ||
158 | }; | ||
159 | }; | ||
160 | }; | ||
161 | battery = { | ||
162 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
163 | icon-size = iconSize - 2; | ||
164 | states = { warning = 30; critical = 15; }; | ||
165 | format-icons = ["󰂎" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹" ]; | ||
166 | format-charging = "󰂄"; | ||
167 | format-plugged = "󰚥"; | ||
168 | tooltip-format = "{capacity}% {timeTo}"; | ||
169 | interval = 20; | ||
170 | }; | ||
171 | tray = { | ||
172 | icon-size = 16; | ||
173 | # show-passive-items = true; | ||
174 | spacing = 1; | ||
175 | }; | ||
176 | privacy = { | ||
177 | icon-spacing = 7; | ||
178 | icon-size = iconSize; | ||
179 | modules = [ | ||
180 | { type = "screenshare"; } | ||
181 | { type = "audio-in"; } | ||
182 | ]; | ||
183 | }; | ||
184 | idle_inhibitor = { | ||
185 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
186 | icon-size = iconSize; | ||
187 | format-icons = { activated = "󰈈"; deactivated = "󰈉"; }; | ||
188 | timeout = 120; | ||
189 | }; | ||
190 | backlight = { | ||
191 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
192 | icon-size = iconSize; | ||
193 | tooltip-format = "{percent}%"; | ||
194 | format-icons = ["󰃚" "󰃛" "󰃜" "󰃝" "󰃞" "󰃟" "󰃠"]; | ||
195 | on-scroll-up = "${swayosd-client} --brightness raise"; | ||
196 | on-scroll-down = "${swayosd-client} --brightness lower"; | ||
197 | }; | ||
198 | wireplumber = { | ||
199 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
200 | icon-size = iconSize; | ||
201 | tooltip-format = "{volume}% {node_name}"; | ||
202 | format-icons = ["󰕿" "󰖀" "󰕾"]; | ||
203 | format-muted = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">󰝟</span>"; | ||
204 | # ignored-sinks = ["Easy Effects Sink"]; | ||
205 | on-scroll-up = "${swayosd-client} --output-volume raise"; | ||
206 | on-scroll-down = "${swayosd-client} --output-volume lower"; | ||
207 | on-click = "${swayosd-client} --output-volume mute-toggle"; | ||
208 | }; | ||
209 | } | ||
210 | { | ||
211 | layer = "top"; | ||
212 | position = "top"; | ||
213 | height = 14; | ||
214 | output = [ "!eDP-1" "!DP-2" "!DP-3" ]; | ||
215 | modules-left = [ "niri/workspaces" ]; | ||
216 | modules-center = [ "niri/window" ]; | ||
217 | modules-right = [ "clock" ]; | ||
218 | |||
219 | "niri/workspaces" = { | ||
220 | ignore = map ({ name, ... }: name) config.programs.niri.scratchspaces; | ||
221 | }; | ||
222 | "niri/window" = { | ||
223 | separate-outputs = true; | ||
224 | icon = true; | ||
225 | icon-size = 14; | ||
226 | rewrite = windowRewrites; | ||
227 | }; | ||
228 | clock = { | ||
229 | interval = 1; | ||
230 | # timezone = "Europe/Berlin"; | ||
231 | format = "{:%H:%M}"; | ||
232 | tooltip-format = "W{:%V-%u %F %H:%M:%S%Ez}"; | ||
233 | }; | ||
234 | } | ||
235 | ]; | ||
236 | style = '' | ||
237 | @define-color white #ffffff; | ||
238 | @define-color grey #555555; | ||
239 | @define-color blue #1a8fff; | ||
240 | @define-color green #23fd00; | ||
241 | @define-color orange #f28a21; | ||
242 | @define-color red #f2201f; | ||
243 | |||
244 | * { | ||
245 | border: none; | ||
246 | font-family: "Fira Sans"; | ||
247 | font-size: 10pt; | ||
248 | min-height: 0; | ||
249 | } | ||
250 | |||
251 | window#waybar { | ||
252 | background-color: rgba(0, 0, 0, 0.66); | ||
253 | color: @white; | ||
254 | } | ||
255 | |||
256 | .modules-left { | ||
257 | margin-left: 12px; | ||
258 | } | ||
259 | .modules-right { | ||
260 | margin-right: 12px; | ||
261 | } | ||
262 | |||
263 | .module { | ||
264 | margin: 0 5px; | ||
265 | } | ||
266 | |||
267 | #workspaces button { | ||
268 | color: @white; | ||
269 | padding: 2px 5px; | ||
270 | } | ||
271 | #workspaces button.empty { | ||
272 | color: @grey; | ||
273 | } | ||
274 | #workspaces button.active { | ||
275 | color: @green; | ||
276 | } | ||
277 | #workspaces button.urgent { | ||
278 | color: @red; | ||
279 | } | ||
280 | |||
281 | #custom-weather, #custom-keymap, #custom-worktime, #custom-worktime-today { | ||
282 | color: @grey; | ||
283 | margin: 0 5px; | ||
284 | } | ||
285 | #custom-weather { | ||
286 | margin-right: 3px; | ||
287 | } | ||
288 | #custom-keymap { | ||
289 | margin-left: 3px; | ||
290 | margin-right: 3px; | ||
291 | } | ||
292 | |||
293 | #tray { | ||
294 | margin: 0; | ||
295 | } | ||
296 | #battery, #idle_inhibitor, #backlight, #wireplumber, #custom-mako { | ||
297 | color: @grey; | ||
298 | margin: 0 5px 0 2px; | ||
299 | } | ||
300 | #idle_inhibitor { | ||
301 | margin-right: 4px; | ||
302 | margin-left: 6px; | ||
303 | } | ||
304 | #custom-mako { | ||
305 | margin-right: 2px; | ||
306 | margin-left: 3px; | ||
307 | } | ||
308 | #battery { | ||
309 | margin-right: 3px; | ||
310 | } | ||
311 | #battery.discharging { | ||
312 | color: @white; | ||
313 | } | ||
314 | #battery.warning { | ||
315 | color: @orange; | ||
316 | } | ||
317 | #battery.critical { | ||
318 | color: @red; | ||
319 | } | ||
320 | #battery.charging { | ||
321 | color: @white; | ||
322 | } | ||
323 | #idle_inhibitor.activated { | ||
324 | color: @white; | ||
325 | } | ||
326 | #custom-worktime.running, #custom-worktime-today.running { | ||
327 | color: @white; | ||
328 | } | ||
329 | #custom-worktime.over, #custom-worktime-today.over { | ||
330 | color: @orange; | ||
331 | } | ||
332 | |||
333 | #idle_inhibitor { | ||
334 | padding-top: 1px; | ||
335 | } | ||
336 | |||
337 | #privacy { | ||
338 | color: @red; | ||
339 | margin: -1px 4px 0px 3px; | ||
340 | } | ||
341 | #clock { | ||
342 | /* margin-right: 5px; */ | ||
343 | } | ||
344 | ''; | ||
345 | }; | ||
346 | }; | ||
347 | } | ||
diff --git a/accounts/gkleen@sif/ssh-hosts.nix b/accounts/gkleen@sif/ssh-hosts.nix index 107f1e76..ac930614 100644 --- a/accounts/gkleen@sif/ssh-hosts.nix +++ b/accounts/gkleen@sif/ssh-hosts.nix | |||
@@ -554,9 +554,4 @@ | |||
554 | HostKeyAlgorithms = "+ecdsa-sha2-nistp256"; | 554 | HostKeyAlgorithms = "+ecdsa-sha2-nistp256"; |
555 | }; | 555 | }; |
556 | }; | 556 | }; |
557 | "game01" = | ||
558 | { hostname = "game01.yggdrasil.li"; | ||
559 | user = "factorio"; | ||
560 | identityFile = "~/.ssh/gkleen@sif.midgard.yggdrasil"; | ||
561 | }; | ||
562 | } | 557 | } |
diff --git a/accounts/gkleen@sif/systemd.nix b/accounts/gkleen@sif/systemd.nix index c8400c28..a89b46c2 100644 --- a/accounts/gkleen@sif/systemd.nix +++ b/accounts/gkleen@sif/systemd.nix | |||
@@ -123,16 +123,8 @@ in { | |||
123 | }; | 123 | }; |
124 | emacs = { | 124 | emacs = { |
125 | Unit = { | 125 | Unit = { |
126 | After = ["graphical-session-pre.target"]; | 126 | After = [ "graphical-session.target" ]; |
127 | }; | 127 | BindsTo = [ "graphical-session.target" ]; |
128 | }; | ||
129 | dunst = { | ||
130 | Service = { | ||
131 | ExecStart = lib.mkForce "${cfg.services.dunst.package}/bin/dunst"; | ||
132 | Restart = "always"; | ||
133 | }; | ||
134 | Install = { | ||
135 | WantedBy = ["graphical-session.target"]; | ||
136 | }; | 128 | }; |
137 | }; | 129 | }; |
138 | keepassxc = { | 130 | keepassxc = { |
@@ -144,8 +136,8 @@ in { | |||
144 | Environment = [ "QT_QPA_PLATFORM=wayland" ]; | 136 | Environment = [ "QT_QPA_PLATFORM=wayland" ]; |
145 | }; | 137 | }; |
146 | Unit = { | 138 | Unit = { |
147 | Requires = ["graphical-session-pre.target"]; | 139 | After = [ "graphical-session.target" ]; |
148 | After = ["graphical-session-pre.target"]; | 140 | BindsTo = [ "graphical-session.target" ]; |
149 | }; | 141 | }; |
150 | }; | 142 | }; |
151 | mpris-proxy = { | 143 | mpris-proxy = { |
@@ -193,8 +185,8 @@ in { | |||
193 | WantedBy = ["graphical-session.target"]; | 185 | WantedBy = ["graphical-session.target"]; |
194 | }; | 186 | }; |
195 | Unit = { | 187 | Unit = { |
196 | Requires = ["graphical-session-pre.target"]; | 188 | After = [ "graphical-session.target" ]; |
197 | After = ["graphical-session-pre.target"]; | 189 | PartOf = [ "graphical-session.target" ]; |
198 | }; | 190 | }; |
199 | Service = { | 191 | Service = { |
200 | ExecStart = lib.getExe pkgs.psi-notify; | 192 | ExecStart = lib.getExe pkgs.psi-notify; |
@@ -204,23 +196,10 @@ in { | |||
204 | WatchdogSec = "2s"; | 196 | WatchdogSec = "2s"; |
205 | }; | 197 | }; |
206 | }; | 198 | }; |
207 | polkit-gnome-authentication-agent-1 = { | ||
208 | Install = { | ||
209 | WantedBy = ["graphical-session.target"]; | ||
210 | }; | ||
211 | Unit = { | ||
212 | PartOf = ["graphical-session.target"]; | ||
213 | Requires = ["graphical-session-pre.target"]; | ||
214 | After = ["graphical-session-pre.target"]; | ||
215 | }; | ||
216 | Service = { | ||
217 | ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; | ||
218 | Restart = "on-failure"; | ||
219 | }; | ||
220 | }; | ||
221 | gtklock = { | 199 | gtklock = { |
222 | Unit = { | 200 | Unit = { |
223 | Requisite = ["graphical-session.target"]; | 201 | Requisite = ["graphical-session.target"]; |
202 | After = [ "graphical-session.target" ]; | ||
224 | PartOf = ["graphical-session.target"]; | 203 | PartOf = ["graphical-session.target"]; |
225 | }; | 204 | }; |
226 | Service = { | 205 | Service = { |
@@ -228,53 +207,55 @@ in { | |||
228 | RuntimeDirectory = "gtklock"; | 207 | RuntimeDirectory = "gtklock"; |
229 | CacheDirectory = "gtklock"; | 208 | CacheDirectory = "gtklock"; |
230 | ExecStartPre = [ | 209 | ExecStartPre = [ |
231 | "${pkgs.libsForQt5.qt5.qttools.bin}/bin/qdbus org.keepassxc.KeePassXC.MainWindow /keepassxc org.keepassxc.KeePassXC.MainWindow.lockAllDatabases" | 210 | "-${lib.getExe' pkgs.libsForQt5.qt5.qttools.bin "qdbus"} org.keepassxc.KeePassXC.MainWindow /keepassxc org.keepassxc.KeePassXC.MainWindow.lockAllDatabases" |
232 | "${config.systemd.package}/bin/systemctl --user stop gpg-agent.service" | 211 | "-${lib.getExe' config.systemd.package "systemctl"} --user stop gpg-agent.service" |
233 | (pkgs.writeShellScript "generate-css" '' | 212 | "-${lib.getExe pkgs.playerctl} -a pause" |
234 | set -x | 213 | "-${lib.getExe (pkgs.writeShellApplication { |
235 | export PATH="${lib.makeBinPath [cfg.programs.wpaperd.package pkgs.jq pkgs.coreutils pkgs.imagemagick pkgs.findutils]}:$PATH" | 214 | name = "generate-css"; |
236 | 215 | runtimeInputs = with pkgs; [cfg.programs.wpaperd.package jq coreutils imagemagick findutils]; | |
237 | declare -A monitors | 216 | text = '' |
238 | monitors=() | 217 | declare -A monitors |
239 | while IFS= read -r entry; do | 218 | monitors=() |
240 | path=$(jq -r ".path" <<<"$entry") | 219 | while IFS= read -r entry; do |
241 | [[ -z "$path" || ! -f "$path" ]] && continue | 220 | path=$(jq -r ".path" <<<"$entry") |
242 | blurred_path="$CACHE_DIRECTORY"/"$(b2sum -l 128 <<<"$path" | cut -d' ' -f1)"."''${path##*.}" | 221 | [[ -z "$path" || ! -f "$path" ]] && continue |
243 | monitor=$(jq -r ".display" <<<"$entry") | 222 | blurred_path="$CACHE_DIRECTORY"/"$(b2sum -l 128 <<<"$path" | cut -d' ' -f1)"."''${path##*.}" |
244 | if [[ ! -f "$blurred_path" ]]; then | 223 | monitor=$(jq -r ".display" <<<"$entry") |
245 | mkdir -p "$(dirname "$blurred_path")" | 224 | if [[ ! -f "$blurred_path" ]]; then |
246 | magick "$path" -filter Gaussian -resize 6.25% -define filter:sigma=2.5 -resize 1600% "$blurred_path" & | 225 | mkdir -p "$(dirname "$blurred_path")" |
247 | fi | 226 | magick "$path" -filter Gaussian -resize 6.25% -define filter:sigma=2.5 -resize 1600% "$blurred_path" & |
248 | monitors+=([$monitor]="$blurred_path") | 227 | fi |
249 | done < <(wpaperctl all-wallpapers -j | jq -c ".[]") | 228 | monitors+=([$monitor]="$blurred_path") |
250 | wait | 229 | done < <(wpaperctl all-wallpapers -j | jq -c ".[]") |
230 | # wait | ||
251 | 231 | ||
252 | cp --no-preserve=mode ${pkgs.writeText "gtklock.css" '' | 232 | cp --no-preserve=mode ${pkgs.writeText "gtklock.css" '' |
253 | #window-box { | 233 | #window-box { |
254 | padding: 64px; | 234 | padding: 64px; |
255 | /* border: 1px solid black; */ | 235 | /* border: 1px solid black; */ |
256 | border-radius: 4px; | 236 | border-radius: 4px; |
257 | box-shadow: rgba(0, 0, 0, 0.8) 0px 4px 12px; | 237 | box-shadow: rgba(0, 0, 0, 0.8) 0px 4px 12px; |
258 | /* background-color: white; */ | 238 | /* background-color: white; */ |
259 | background-color: rgba(0, 0, 0, 0.5); | 239 | background-color: rgba(0, 0, 0, 0.5); |
240 | } | ||
241 | ''} "$RUNTIME_DIRECTORY"/style.css | ||
242 | for monitor in "''${!monitors[@]}"; do | ||
243 | cat >>"$RUNTIME_DIRECTORY"/style.css <<EOF | ||
244 | window#''${monitor} { | ||
245 | background-image: url("''${monitors[$monitor]}"); | ||
246 | background-repeat: no-repeat; | ||
247 | background-size: 100% 100%; | ||
248 | background-origin: content-box; | ||
260 | } | 249 | } |
261 | ''} "$RUNTIME_DIRECTORY"/style.css | 250 | EOF |
262 | for monitor in "''${!monitors[@]}"; do | 251 | done |
263 | cat >>"$RUNTIME_DIRECTORY"/style.css <<EOF | 252 | ''; |
264 | window#''${monitor} { | 253 | })}" |
265 | background-image: url("''${monitors[$monitor]}"); | ||
266 | background-repeat: no-repeat; | ||
267 | background-size: 100% 100%; | ||
268 | background-origin: content-box; | ||
269 | } | ||
270 | EOF | ||
271 | done | ||
272 | '') | ||
273 | ]; | 254 | ]; |
274 | NotifyAccess = "all"; | 255 | NotifyAccess = "all"; |
275 | ExecStart = ''${lib.getExe pkgs.gtklock} -s "''${RUNTIME_DIRECTORY}/style.css" -L ${pkgs.writeShellScript "after-lock" '' | 256 | ExecStart = ''${lib.getExe pkgs.gtklock} -s "''${RUNTIME_DIRECTORY}/style.css" -L ${pkgs.writeShellScript "after-lock" '' |
276 | ${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off | 257 | ${lib.getExe cfg.programs.niri.package} msg action power-off-monitors |
277 | ${config.systemd.package}/bin/systemd-notify --ready | 258 | ${lib.getExe' config.systemd.package "systemd-notify"} --ready |
278 | ''}''; | 259 | ''}''; |
279 | }; | 260 | }; |
280 | }; | 261 | }; |
@@ -327,8 +308,8 @@ in { | |||
327 | WantedBy = ["graphical-session.target"]; | 308 | WantedBy = ["graphical-session.target"]; |
328 | }; | 309 | }; |
329 | Unit = { | 310 | Unit = { |
330 | BindsTo = ["graphical-session-pre.target"]; | 311 | After = [ "graphical-session.target" ]; |
331 | After = ["graphical-session-pre.target"]; | 312 | PartOf = [ "graphical-session.target" ]; |
332 | }; | 313 | }; |
333 | Service = { | 314 | Service = { |
334 | ExecStart = lib.getExe cfg.programs.wpaperd.package; | 315 | ExecStart = lib.getExe cfg.programs.wpaperd.package; |
@@ -337,6 +318,36 @@ in { | |||
337 | RestartSec = "2s"; | 318 | RestartSec = "2s"; |
338 | }; | 319 | }; |
339 | }; | 320 | }; |
321 | xembed-sni-proxy = { | ||
322 | Unit = { | ||
323 | PartOf = lib.mkForce ["tray.target"]; | ||
324 | BindsTo = ["xwayland-satellite.service"]; | ||
325 | After = ["xwayland-satellite.service"]; | ||
326 | }; | ||
327 | }; | ||
328 | poweralertd = { | ||
329 | Unit = { | ||
330 | After = ["graphical-session.target"]; | ||
331 | }; | ||
332 | }; | ||
333 | network-manager-applet = { | ||
334 | Unit = { | ||
335 | PartOf = lib.mkForce ["tray.target"]; | ||
336 | }; | ||
337 | }; | ||
338 | udiskie = { | ||
339 | Unit = { | ||
340 | PartOf = lib.mkForce ["tray.target"]; | ||
341 | }; | ||
342 | }; | ||
343 | blueman-applet = { | ||
344 | Unit = { | ||
345 | PartOf = lib.mkForce ["tray.target"]; | ||
346 | }; | ||
347 | Install = { | ||
348 | WantedBy = lib.mkForce ["tray.target"]; | ||
349 | }; | ||
350 | }; | ||
340 | } // listToAttrs (map ({host, port}: nameValuePair "proxy-to-autossh-socks@${toString port}" { | 351 | } // listToAttrs (map ({host, port}: nameValuePair "proxy-to-autossh-socks@${toString port}" { |
341 | Unit = { | 352 | Unit = { |
342 | Requires = ["autossh-socks@${host}:${toString (port + 1)}.service" "proxy-to-autossh-socks@${toString port}.socket"]; | 353 | Requires = ["autossh-socks@${host}:${toString (port + 1)}.service" "proxy-to-autossh-socks@${toString port}.socket"]; |
@@ -387,6 +398,9 @@ in { | |||
387 | }; | 398 | }; |
388 | tray = { | 399 | tray = { |
389 | Unit = { | 400 | Unit = { |
401 | PartOf = [ "graphical-session.target" ]; | ||
402 | Requires = [ "waybar.service" ]; | ||
403 | After = [ "graphical-session.target" "waybar.service" ]; | ||
390 | Wants = ["blueman-applet.service" "udiskie.service" "network-manager-applet.service"]; | 404 | Wants = ["blueman-applet.service" "udiskie.service" "network-manager-applet.service"]; |
391 | }; | 405 | }; |
392 | }; | 406 | }; |
diff --git a/accounts/gkleen@sif/taffybar/default.nix b/accounts/gkleen@sif/taffybar/default.nix deleted file mode 100644 index 98366d8f..00000000 --- a/accounts/gkleen@sif/taffybar/default.nix +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | { haskellPackages ? (import <nixpkgs> {}).haskellPackages }: | ||
2 | haskellPackages.callCabal2nix "gkleen-sif-taffybar" ./. {} | ||
diff --git a/accounts/gkleen@sif/taffybar/gkleen-sif-taffybar.cabal b/accounts/gkleen@sif/taffybar/gkleen-sif-taffybar.cabal deleted file mode 100644 index e32cb473..00000000 --- a/accounts/gkleen@sif/taffybar/gkleen-sif-taffybar.cabal +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | name: gkleen-sif-taffybar | ||
2 | version: 0.0.0 | ||
3 | build-type: Simple | ||
4 | cabal-version: >=1.10 | ||
5 | |||
6 | data-files: taffybar.css | ||
7 | |||
8 | executable taffybar | ||
9 | hs-source-dirs: src | ||
10 | main-is: taffybar.hs | ||
11 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -O2 -Wall | ||
12 | build-depends: base | ||
13 | , containers | ||
14 | , directory | ||
15 | , filepath | ||
16 | , gtk3 | ||
17 | , taffybar | ||
18 | , X11>=1.8 | ||
19 | , transformers | ||
20 | , gi-gtk | ||
21 | , time, time-locale-compat | ||
22 | , text | ||
23 | , HStringTemplate | ||
24 | , gtk-sni-tray | ||
25 | , hslogger | ||
26 | other-modules: Paths_gkleen_sif_taffybar | ||
27 | , System.Taffybar.Widget.Clock | ||
28 | , System.Taffybar.Widget.TooltipBattery | ||
29 | default-language: Haskell2010 | ||
30 | default-extensions: ScopedTypeVariables | ||
31 | , LambdaCase | ||
32 | , NamedFieldPuns \ No newline at end of file | ||
diff --git a/accounts/gkleen@sif/taffybar/src/System/Taffybar/Widget/Clock.hs b/accounts/gkleen@sif/taffybar/src/System/Taffybar/Widget/Clock.hs deleted file mode 100644 index e8dc480f..00000000 --- a/accounts/gkleen@sif/taffybar/src/System/Taffybar/Widget/Clock.hs +++ /dev/null | |||
@@ -1,111 +0,0 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | ||
2 | module System.Taffybar.Widget.Clock | ||
3 | ( textClockNew | ||
4 | , textClockNewWith | ||
5 | , defaultClockConfig | ||
6 | , ClockConfig(..) | ||
7 | , ClockUpdateStrategy(..) | ||
8 | ) where | ||
9 | |||
10 | import Control.Monad.IO.Class | ||
11 | import Data.Maybe | ||
12 | import qualified Data.Text as T | ||
13 | import qualified Data.Time.Clock as Clock | ||
14 | import Data.Time.Format | ||
15 | import Data.Time.LocalTime | ||
16 | import qualified Data.Time.Locale.Compat as L | ||
17 | import GI.Gtk | ||
18 | import System.Taffybar.Widget.Generic.PollingLabel | ||
19 | |||
20 | type ClockFormat = L.TimeLocale -> ZonedTime -> T.Text | ||
21 | |||
22 | -- | Create the widget. I recommend passing @Nothing@ for the TimeLocale | ||
23 | -- parameter. The format string can include Pango markup | ||
24 | -- (<http://developer.gnome.org/pango/stable/PangoMarkupFormat.html>). | ||
25 | textClockNew :: | ||
26 | MonadIO m => Maybe L.TimeLocale -> ClockFormat -> Double -> m GI.Gtk.Widget | ||
27 | textClockNew userLocale format interval = | ||
28 | textClockNewWith cfg | ||
29 | where | ||
30 | cfg = defaultClockConfig { clockTimeLocale = userLocale | ||
31 | , clockFormat = format | ||
32 | , clockUpdateStrategy = ConstantInterval interval | ||
33 | } | ||
34 | |||
35 | data ClockUpdateStrategy | ||
36 | = ConstantInterval Double | ||
37 | | RoundedTargetInterval Int Double | ||
38 | deriving (Eq, Ord, Show) | ||
39 | |||
40 | data ClockConfig = ClockConfig | ||
41 | { clockTimeZone :: Maybe TimeZone | ||
42 | , clockTimeLocale :: Maybe L.TimeLocale | ||
43 | , clockFormat :: ClockFormat | ||
44 | , clockUpdateStrategy :: ClockUpdateStrategy | ||
45 | } | ||
46 | |||
47 | -- | A clock configuration that defaults to the current locale | ||
48 | defaultClockConfig :: ClockConfig | ||
49 | defaultClockConfig = ClockConfig | ||
50 | { clockTimeZone = Nothing | ||
51 | , clockTimeLocale = Nothing | ||
52 | , clockFormat = \locale zonedTime -> T.pack $ formatTime locale "%a %b %_d %r" zonedTime | ||
53 | , clockUpdateStrategy = RoundedTargetInterval 5 0.0 | ||
54 | } | ||
55 | |||
56 | systemGetTZ :: IO TimeZone | ||
57 | systemGetTZ = getCurrentTimeZone | ||
58 | |||
59 | -- | A configurable text-based clock widget. It currently allows for | ||
60 | -- a configurable time zone through the 'ClockConfig'. | ||
61 | -- | ||
62 | -- See also 'textClockNew'. | ||
63 | textClockNewWith :: MonadIO m => ClockConfig -> m Widget | ||
64 | textClockNewWith ClockConfig | ||
65 | { clockTimeZone = userZone | ||
66 | , clockTimeLocale = userLocale | ||
67 | , clockFormat = format | ||
68 | , clockUpdateStrategy = updateStrategy | ||
69 | } = liftIO $ do | ||
70 | let getTZ = maybe systemGetTZ return userZone | ||
71 | locale = fromMaybe L.defaultTimeLocale userLocale | ||
72 | |||
73 | let getUserZonedTime = | ||
74 | utcToZonedTime <$> getTZ <*> Clock.getCurrentTime | ||
75 | |||
76 | doTimeFormat = format locale | ||
77 | |||
78 | getRoundedTimeAndNextTarget = do | ||
79 | zonedTime <- getUserZonedTime | ||
80 | return $ case updateStrategy of | ||
81 | ConstantInterval interval -> | ||
82 | (doTimeFormat zonedTime, Nothing, interval) | ||
83 | RoundedTargetInterval roundSeconds offset -> | ||
84 | let roundSecondsDiffTime = fromIntegral roundSeconds | ||
85 | addTheRound = addLocalTime roundSecondsDiffTime | ||
86 | localTime = zonedTimeToLocalTime zonedTime | ||
87 | ourLocalTimeOfDay = localTimeOfDay localTime | ||
88 | seconds = round $ todSec ourLocalTimeOfDay | ||
89 | secondsFactor = seconds `div` roundSeconds | ||
90 | displaySeconds = secondsFactor * roundSeconds | ||
91 | baseLocalTimeOfDay = | ||
92 | ourLocalTimeOfDay { todSec = fromIntegral displaySeconds } | ||
93 | ourLocalTime = | ||
94 | localTime { localTimeOfDay = baseLocalTimeOfDay } | ||
95 | roundedLocalTime = | ||
96 | if seconds `mod` roundSeconds > roundSeconds `div` 2 | ||
97 | then addTheRound ourLocalTime | ||
98 | else ourLocalTime | ||
99 | roundedZonedTime = | ||
100 | zonedTime { zonedTimeToLocalTime = roundedLocalTime } | ||
101 | nextTarget = addTheRound ourLocalTime | ||
102 | amountToWait = realToFrac $ diffLocalTime nextTarget localTime | ||
103 | in (doTimeFormat roundedZonedTime, Nothing, amountToWait - offset) | ||
104 | |||
105 | label <- pollingLabelWithVariableDelay getRoundedTimeAndNextTarget | ||
106 | ebox <- eventBoxNew | ||
107 | containerAdd ebox label | ||
108 | eventBoxSetVisibleWindow ebox False | ||
109 | widgetShowAll ebox | ||
110 | toWidget ebox | ||
111 | |||
diff --git a/accounts/gkleen@sif/taffybar/src/System/Taffybar/Widget/TooltipBattery.hs b/accounts/gkleen@sif/taffybar/src/System/Taffybar/Widget/TooltipBattery.hs deleted file mode 100644 index 9dc52774..00000000 --- a/accounts/gkleen@sif/taffybar/src/System/Taffybar/Widget/TooltipBattery.hs +++ /dev/null | |||
@@ -1,101 +0,0 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | ||
2 | {-# LANGUAGE ScopedTypeVariables #-} | ||
3 | module System.Taffybar.Widget.TooltipBattery ( batteryIconTooltipNew ) where | ||
4 | |||
5 | import Control.Applicative | ||
6 | import Control.Monad | ||
7 | import Control.Monad.IO.Class | ||
8 | import Control.Monad.Trans.Reader | ||
9 | import Data.Int (Int64) | ||
10 | import qualified Data.Text as T | ||
11 | import GI.Gtk | ||
12 | import Prelude | ||
13 | import StatusNotifier.Tray (scalePixbufToSize) | ||
14 | import System.Taffybar.Context | ||
15 | import System.Taffybar.Information.Battery | ||
16 | import System.Taffybar.Util | ||
17 | import System.Taffybar.Widget.Generic.AutoSizeImage | ||
18 | import System.Taffybar.Widget.Generic.ChannelWidget | ||
19 | import Text.Printf | ||
20 | import Text.StringTemplate | ||
21 | import Data.Function ((&)) | ||
22 | |||
23 | -- | Just the battery info that will be used for display (this makes combining | ||
24 | -- several easier). | ||
25 | data BatteryWidgetInfo = BWI | ||
26 | { seconds :: Maybe Int64 | ||
27 | , percent :: Double | ||
28 | , status :: String | ||
29 | , rate :: Maybe Double | ||
30 | } deriving (Eq, Show) | ||
31 | |||
32 | -- | Format a duration expressed as seconds to hours and minutes | ||
33 | formatDuration :: Int64 -> String | ||
34 | formatDuration secs = let minutes, hours, minutes' :: Int64 | ||
35 | minutes = secs `div` 60 | ||
36 | (hours, minutes') = minutes `divMod` 60 | ||
37 | in printf "%02d:%02d" hours minutes' | ||
38 | |||
39 | getBatteryWidgetInfo :: BatteryInfo -> BatteryWidgetInfo | ||
40 | getBatteryWidgetInfo info = | ||
41 | let battPctNum :: Double | ||
42 | battPctNum = batteryPercentage info | ||
43 | battTime :: Maybe Int64 | ||
44 | battTime = | ||
45 | case batteryState info of | ||
46 | BatteryStateCharging -> Just $ batteryTimeToFull info | ||
47 | BatteryStateDischarging -> Just $ batteryTimeToEmpty info | ||
48 | _ -> Nothing | ||
49 | battStatus :: String | ||
50 | battStatus = | ||
51 | case batteryState info of | ||
52 | BatteryStateCharging -> "↑" | ||
53 | BatteryStateDischarging -> "↓" | ||
54 | BatteryStateEmpty -> "⤓" | ||
55 | BatteryStateFullyCharged -> "⤒" | ||
56 | _ -> "?" | ||
57 | battRate :: Maybe Double | ||
58 | battRate | rawRate < 0.1 = Nothing | ||
59 | | otherwise = Just rawRate | ||
60 | where rawRate = batteryEnergyRate info | ||
61 | in BWI{ seconds = battTime, percent = battPctNum, status = battStatus, rate = battRate } | ||
62 | |||
63 | -- | Given (maybe summarized) battery info and format: provides the string to display | ||
64 | formatBattInfo :: BatteryWidgetInfo -> String -> T.Text | ||
65 | formatBattInfo info fmt = | ||
66 | let tpl = newSTMP fmt | ||
67 | tpl' = tpl | ||
68 | & setManyAttrib [ ("percentage", printf "%.0f" $ percent info) | ||
69 | , ("status", status info) | ||
70 | ] | ||
71 | & setManyAttrib [ ("time", formatDuration <$> seconds info) | ||
72 | , ("rate", printf "%.0f" <$> rate info) | ||
73 | ] | ||
74 | in render tpl' | ||
75 | |||
76 | themeLoadFlags :: [IconLookupFlags] | ||
77 | themeLoadFlags = [IconLookupFlagsGenericFallback, IconLookupFlagsUseBuiltin] | ||
78 | |||
79 | batteryIconTooltipNew :: String -> TaffyIO Widget | ||
80 | batteryIconTooltipNew format = do | ||
81 | DisplayBatteryChanVar (chan, _) <- setupDisplayBatteryChanVar ["IconName", "State", "Percentage", "TimeToFull", "TimeToEmpty", "EnergyRate"] | ||
82 | ctx <- ask | ||
83 | liftIO $ do | ||
84 | image <- imageNew | ||
85 | styleCtx <- widgetGetStyleContext =<< toWidget image | ||
86 | defaultTheme <- iconThemeGetDefault | ||
87 | let getCurrentBatteryIconNameStringTooltip = do | ||
88 | info <- runReaderT getDisplayBatteryInfo ctx | ||
89 | let iconNameString = T.pack $ batteryIconName info | ||
90 | tooltip = formatBattInfo (getBatteryWidgetInfo info) format | ||
91 | return (iconNameString, tooltip) | ||
92 | extractPixbuf info = | ||
93 | fst <$> iconInfoLoadSymbolicForContext info styleCtx | ||
94 | setIconForSize size = do | ||
95 | (name, tooltip) <- getCurrentBatteryIconNameStringTooltip | ||
96 | widgetSetTooltipMarkup image $ Just tooltip | ||
97 | iconThemeLookupIcon defaultTheme name size themeLoadFlags >>= | ||
98 | traverse extractPixbuf >>= | ||
99 | traverse (scalePixbufToSize size OrientationHorizontal) | ||
100 | updateImage <- autoSizeImage image setIconForSize OrientationHorizontal | ||
101 | toWidget =<< channelWidgetNew image chan (const $ postGUIASync updateImage) | ||
diff --git a/accounts/gkleen@sif/taffybar/src/taffybar.hs b/accounts/gkleen@sif/taffybar/src/taffybar.hs deleted file mode 100644 index 67ee942d..00000000 --- a/accounts/gkleen@sif/taffybar/src/taffybar.hs +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | ||
2 | |||
3 | module Main where | ||
4 | |||
5 | import System.Taffybar (startTaffybar) | ||
6 | import System.Taffybar.Context (TaffybarConfig(..)) | ||
7 | import System.Taffybar.Hooks | ||
8 | import System.Taffybar.SimpleConfig hiding (SimpleTaffyConfig(cssPaths)) | ||
9 | import System.Taffybar.Widget | ||
10 | import qualified System.Taffybar.Widget.Clock as MyClock | ||
11 | import System.Taffybar.Widget.TooltipBattery | ||
12 | |||
13 | import Data.Time.Format | ||
14 | import Data.Time.LocalTime | ||
15 | import Data.Time.Calendar.WeekDate | ||
16 | |||
17 | import qualified Data.Text as T | ||
18 | |||
19 | import Control.Exception (SomeException, try) | ||
20 | import Control.Monad.Trans.Reader (mapReaderT) | ||
21 | |||
22 | import Paths_gkleen_sif_taffybar | ||
23 | |||
24 | import System.Log.Logger | ||
25 | |||
26 | |||
27 | main :: IO () | ||
28 | main = do | ||
29 | logger <- getLogger "System.Taffybar" | ||
30 | saveGlobalLogger $ setLevel INFO logger | ||
31 | |||
32 | myCssPath <- getDataFileName "taffybar.css" | ||
33 | startTaffybar taffybarConfig{ cssPaths = pure myCssPath } | ||
34 | |||
35 | |||
36 | taffybarConfig :: TaffybarConfig | ||
37 | taffybarConfig = | ||
38 | let myWorkspacesConfig = | ||
39 | defaultWorkspacesConfig | ||
40 | { maxIcons = Just 0 | ||
41 | , widgetGap = 7 | ||
42 | , showWorkspaceFn = \case | ||
43 | -- Workspace{ workspaceState = Empty } -> False | ||
44 | Workspace{ workspaceName } | workspaceName == "NSP" -> False | ||
45 | _other -> True | ||
46 | , getWindowIconPixbuf = \i d -> either (\(_ :: SomeException) -> Nothing) id <$> mapReaderT try (defaultGetWindowIconPixbuf i d) | ||
47 | , urgentWorkspaceState = True | ||
48 | } | ||
49 | workspaces = workspacesNew myWorkspacesConfig | ||
50 | clock = MyClock.textClockNewWith MyClock.defaultClockConfig | ||
51 | { MyClock.clockUpdateStrategy = MyClock.RoundedTargetInterval 1 0.0 | ||
52 | , MyClock.clockFormat = \tl zt@ZonedTime{ zonedTimeToLocalTime = LocalTime{ localDay } } | ||
53 | -> let date = formatTime tl "%Y-%m-%d" localDay | ||
54 | weekdate = "W" <> show2 woy <> "-" <> show dow | ||
55 | where (_, woy, dow) = toWeekDate localDay | ||
56 | show2 :: Int -> String | ||
57 | show2 x = replicate (2 - length s) '0' ++ s | ||
58 | where s = show x | ||
59 | time = formatTime tl "%H:%M:%S%Ez" zt | ||
60 | in T.intercalate " " $ map T.pack [weekdate, date, time] | ||
61 | } | ||
62 | layout = layoutNew defaultLayoutConfig | ||
63 | windowsW = windowsNew defaultWindowsConfig | ||
64 | { getMenuLabel = truncatedGetMenuLabel 80 | ||
65 | , getActiveLabel = truncatedGetActiveLabel 80 | ||
66 | } | ||
67 | worktime = commandRunnerNew 60 "worktime" [] "worktime" | ||
68 | worktimeToday = commandRunnerNew 60 "worktime" ["today"] "worktime today" | ||
69 | -- See https://github.com/taffybar/gtk-sni-tray#statusnotifierwatcher | ||
70 | -- for a better way to set up the sni tray | ||
71 | -- tray = sniTrayThatStartsWatcherEvenThoughThisIsABadWayToDoIt | ||
72 | tray = sniTrayNew | ||
73 | myConfig = defaultSimpleTaffyConfig | ||
74 | { startWidgets = | ||
75 | workspaces : map (>>= buildContentsBox) [ layout, windowsW ] | ||
76 | , endWidgets = map (>>= buildContentsBox) $ reverse | ||
77 | -- , mpris2New | ||
78 | [ worktime, worktimeToday | ||
79 | , clock | ||
80 | , tray | ||
81 | , batteryIconTooltipNew "$status$ $percentage$%$if(time)$$if(rate)$ ($rate$W $time$)$else$ ($time$)$endif$$elseif(rate)$ ($rate$W)$endif$" | ||
82 | ] | ||
83 | , barPosition = Top | ||
84 | , barPadding = 2 | ||
85 | , barHeight = ExactSize 28 | ||
86 | , widgetSpacing = 10 | ||
87 | } | ||
88 | in withBatteryRefresh $ withLogServer $ | ||
89 | withToggleServer $ toTaffyConfig myConfig | ||
diff --git a/accounts/gkleen@sif/taffybar/taffybar.css b/accounts/gkleen@sif/taffybar/taffybar.css deleted file mode 100644 index 7a297465..00000000 --- a/accounts/gkleen@sif/taffybar/taffybar.css +++ /dev/null | |||
@@ -1,146 +0,0 @@ | |||
1 | @define-color transparent rgba(0.0, 0.0, 0.0, 0.0); | ||
2 | @define-color white #808080; | ||
3 | @define-color gray #202020; | ||
4 | @define-color green #008000; | ||
5 | @define-color yellow #808000; | ||
6 | @define-color blue #000080; | ||
7 | @define-color red #800000; | ||
8 | @define-color black #000000; | ||
9 | /* @define-color taffy-blue #0c7cd5; */ | ||
10 | @define-color taffy-blue @blue; | ||
11 | |||
12 | @define-color active-window-color @white; | ||
13 | @define-color urgent-window-color @taffy-blue; | ||
14 | @define-color font-color @white; | ||
15 | @define-color menu-background-color @black; | ||
16 | @define-color menu-font-color @white; | ||
17 | |||
18 | /* Top level styling */ | ||
19 | |||
20 | .taffy-window * { | ||
21 | /* | ||
22 | This removes any existing styling from UI elements. Taffybar will not | ||
23 | cohere with your gtk theme. | ||
24 | */ | ||
25 | all: unset; | ||
26 | |||
27 | font-family: "Fira Sans", sans-serif; | ||
28 | font-size: 21px; | ||
29 | color: @font-color; | ||
30 | } | ||
31 | |||
32 | .taffy-box { | ||
33 | /* border-radius: 10px; */ | ||
34 | background-color: @black; | ||
35 | } | ||
36 | |||
37 | .inner-pad { | ||
38 | /* padding-bottom: 5px; */ | ||
39 | /* padding-top: 5px; */ | ||
40 | padding-left: 2px; | ||
41 | padding-right: 2px; | ||
42 | } | ||
43 | |||
44 | .contents { | ||
45 | /* padding-bottom: 4px; */ | ||
46 | /* padding-top: 4px; */ | ||
47 | padding-right: 2px; | ||
48 | padding-left: 2px; | ||
49 | transition: background-color .5s; | ||
50 | border-radius: 5px; | ||
51 | } | ||
52 | |||
53 | /* Workspaces styling */ | ||
54 | |||
55 | .workspace-label { | ||
56 | padding-right: 3px; | ||
57 | padding-left: 2px; | ||
58 | font-size: 21px; | ||
59 | } | ||
60 | |||
61 | .workspace-label.active { | ||
62 | color: @green; | ||
63 | } | ||
64 | .workspace-label.visible { | ||
65 | color: @yellow; | ||
66 | } | ||
67 | .workspace-label.empty { | ||
68 | color: @gray; | ||
69 | } | ||
70 | .workspace-label.urgent { | ||
71 | color: @red; | ||
72 | } | ||
73 | |||
74 | .active .contents { | ||
75 | background-color: rgba(0.0, 0.0, 0.0, 0.5); | ||
76 | } | ||
77 | |||
78 | .visible .contents { | ||
79 | background-color: rgba(0.0, 0.0, 0.0, 0.2); | ||
80 | } | ||
81 | |||
82 | .window-icon-container { | ||
83 | transition: opacity .5s, box-shadow .5s; | ||
84 | opacity: 1; | ||
85 | } | ||
86 | |||
87 | /* This gives space for the box-shadow (they look like underlines) that follow. | ||
88 | This will actually affect all widgets, (not just the workspace icons), but | ||
89 | that is what we want since we want the icons to look the same. */ | ||
90 | .auto-size-image, .sni-tray { | ||
91 | padding-top: 3px; | ||
92 | padding-bottom: 3px; | ||
93 | } | ||
94 | |||
95 | .window-icon-container.active { | ||
96 | box-shadow: inset 0 -3px @white; | ||
97 | } | ||
98 | |||
99 | .window-icon-container.urgent { | ||
100 | box-shadow: inset 0 -3px @urgent-window-color; | ||
101 | } | ||
102 | |||
103 | .window-icon-container.inactive .window-icon { | ||
104 | padding: 0px; | ||
105 | } | ||
106 | |||
107 | .window-icon-container.minimized .window-icon { | ||
108 | opacity: .3; | ||
109 | } | ||
110 | |||
111 | .window-icon { | ||
112 | opacity: 1; | ||
113 | transition: opacity .5s; | ||
114 | } | ||
115 | |||
116 | /* Button styling */ | ||
117 | |||
118 | button { | ||
119 | background-color: @transparent; | ||
120 | border-width: 0px; | ||
121 | border-radius: 0px; | ||
122 | } | ||
123 | |||
124 | button:checked, button:hover .Contents:hover { | ||
125 | box-shadow: inset 0 -3px @taffy-blue; | ||
126 | } | ||
127 | |||
128 | /* Menu styling */ | ||
129 | |||
130 | /* The ".taffy-window" prefixed selectors are needed because if they aren't present, | ||
131 | the top level .Taffybar selector takes precedence */ | ||
132 | .taffy-window menuitem *, menuitem * { | ||
133 | color: @menu-font-color; | ||
134 | } | ||
135 | |||
136 | .taffy-window menuitem, menuitem { | ||
137 | background-color: @menu-background-color; | ||
138 | } | ||
139 | |||
140 | .taffy-window menuitem:hover, menuitem:hover { | ||
141 | background-color: @taffy-blue; | ||
142 | } | ||
143 | |||
144 | .taffy-window menuitem:hover > label, menuitem:hover > label { | ||
145 | color: @white; | ||
146 | } | ||
diff --git a/accounts/gkleen@sif/xmonad/.gitignore b/accounts/gkleen@sif/xmonad/.gitignore deleted file mode 100644 index c11891cd..00000000 --- a/accounts/gkleen@sif/xmonad/.gitignore +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | **/#*# | ||
2 | **/.stack-work/ | ||
3 | /stack.yaml.lock | ||
4 | /*.cabal | ||
diff --git a/accounts/gkleen@sif/xmonad/default.nix b/accounts/gkleen@sif/xmonad/default.nix deleted file mode 100644 index 8790c12f..00000000 --- a/accounts/gkleen@sif/xmonad/default.nix +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | argumentPackages@{ ... }: | ||
2 | |||
3 | let | ||
4 | # defaultPackages = (import ./stackage.nix {}); | ||
5 | # haskellPackages = defaultPackages // argumentPackages; | ||
6 | haskellPackages = argumentPackages; | ||
7 | in haskellPackages.callPackage ./xmonad-yggdrasil.nix {} | ||
diff --git a/accounts/gkleen@sif/xmonad/lib/XMonad/Mpv.hs b/accounts/gkleen@sif/xmonad/lib/XMonad/Mpv.hs deleted file mode 100644 index e6accdcc..00000000 --- a/accounts/gkleen@sif/xmonad/lib/XMonad/Mpv.hs +++ /dev/null | |||
@@ -1,127 +0,0 @@ | |||
1 | {-# LANGUAGE DeriveGeneric, OverloadedLists, OverloadedStrings, ViewPatterns, ExistentialQuantification, MultiWayIf #-} | ||
2 | |||
3 | module XMonad.Mpv | ||
4 | ( MpvCommand(..), MpvResponse(..), MpvException(..) | ||
5 | , mpv | ||
6 | , mpvDir | ||
7 | , mpvAll, mpvOne | ||
8 | , mpvResponse | ||
9 | ) where | ||
10 | |||
11 | import Data.Aeson | ||
12 | |||
13 | import Data.Monoid | ||
14 | |||
15 | import Network.Socket hiding (recv) | ||
16 | import Network.Socket.ByteString | ||
17 | |||
18 | import qualified Data.ByteString as BS | ||
19 | import qualified Data.ByteString.Char8 as CBS | ||
20 | import qualified Data.ByteString.Lazy as LBS | ||
21 | |||
22 | import GHC.Generics (Generic) | ||
23 | import Data.Typeable (Typeable) | ||
24 | import Data.String (IsString(..)) | ||
25 | |||
26 | import Control.Exception | ||
27 | |||
28 | import System.IO.Temp (getCanonicalTemporaryDirectory) | ||
29 | |||
30 | import Control.Monad | ||
31 | import Control.Exception (bracket) | ||
32 | import Control.Monad.IO.Class (MonadIO(..)) | ||
33 | |||
34 | import System.FilePath | ||
35 | import System.Directory (getDirectoryContents) | ||
36 | |||
37 | import Data.List | ||
38 | import Data.Either | ||
39 | import Data.Maybe | ||
40 | |||
41 | import Debug.Trace | ||
42 | |||
43 | |||
44 | data MpvCommand | ||
45 | = forall a. ToJSON a => MpvSetProperty String a | ||
46 | | MpvGetProperty String | ||
47 | data MpvResponse | ||
48 | = MpvError String | ||
49 | | MpvSuccess (Maybe Value) | ||
50 | deriving (Read, Show, Generic, Eq) | ||
51 | data MpvException = MpvException String | ||
52 | | MpvNoValue | ||
53 | | MpvNoParse String | ||
54 | deriving (Generic, Typeable, Read, Show) | ||
55 | instance Exception MpvException | ||
56 | |||
57 | |||
58 | instance ToJSON MpvCommand where | ||
59 | toJSON (MpvSetProperty name val) = Array ["set_property", fromString name, toJSON val] | ||
60 | toJSON (MpvGetProperty name) = Array ["get_property", fromString name] | ||
61 | |||
62 | instance FromJSON MpvResponse where | ||
63 | parseJSON = withObject "response object" $ \obj -> do | ||
64 | mval <- obj .:? "data" | ||
65 | err <- obj .: "error" | ||
66 | |||
67 | let ret | ||
68 | | err == "success" = MpvSuccess mval | ||
69 | | otherwise = MpvError err | ||
70 | |||
71 | return ret | ||
72 | |||
73 | mpvSocket :: FilePath -> (Socket -> IO a) -> IO a | ||
74 | mpvSocket sockPath = withSocketsDo . bracket mkSock close | ||
75 | where | ||
76 | mkSock = do | ||
77 | sock <- socket AF_UNIX Stream defaultProtocol | ||
78 | connect sock $ SockAddrUnix (traceId sockPath) | ||
79 | return sock | ||
80 | |||
81 | mpvResponse :: FromJSON v => MpvResponse -> IO v | ||
82 | mpvResponse (MpvError str) = throwIO $ MpvException str | ||
83 | mpvResponse (MpvSuccess Nothing) = throwIO MpvNoValue | ||
84 | mpvResponse (MpvSuccess (Just v)) = case fromJSON v of | ||
85 | Success v' -> return v' | ||
86 | Error str -> throwIO $ MpvNoParse str | ||
87 | |||
88 | mpv :: FilePath -> MpvCommand -> IO MpvResponse | ||
89 | mpv sockPath cmd = mpvSocket sockPath $ \sock -> do | ||
90 | let message = (`BS.append` "\n") . LBS.toStrict . encode $ Object [("command", toJSON cmd)] | ||
91 | traceIO $ show message | ||
92 | sendAll sock message | ||
93 | let recvAll = do | ||
94 | prefix <- recv sock 4096 | ||
95 | if | ||
96 | | (prefix', rest) <- CBS.break (== '\n') prefix | ||
97 | , not (BS.null rest) -> return prefix' | ||
98 | | BS.null prefix -> return prefix | ||
99 | | otherwise -> BS.append prefix <$> recvAll | ||
100 | response <- recvAll | ||
101 | traceIO $ show response | ||
102 | either (ioError . userError) return . traceShowId $ eitherDecodeStrict' response | ||
103 | |||
104 | mpvDir :: Exception e => FilePath -> (FilePath -> [(FilePath, Either e MpvResponse)] -> Maybe MpvCommand) -> IO [(FilePath, Either e MpvResponse)] | ||
105 | mpvDir dir step = do | ||
106 | socks <- filter (".sock" `isSuffixOf`) <$> getDirectoryContents dir | ||
107 | go [] socks | ||
108 | where | ||
109 | go acc [] = return acc | ||
110 | go acc (sock:socks) | ||
111 | | Just cmd <- step sock acc = do | ||
112 | res <- try $ mpv (dir </> sock) cmd | ||
113 | go ((sock, res) : acc) socks | ||
114 | | otherwise = | ||
115 | go acc socks | ||
116 | |||
117 | mpvAll :: FilePath -> MpvCommand -> IO [MpvResponse] | ||
118 | mpvAll dir cmd = do | ||
119 | results <- map snd <$> (mpvDir dir (\_ _ -> Just cmd) :: IO [(FilePath, Either SomeException MpvResponse)]) | ||
120 | mapM (either throwIO return) results | ||
121 | |||
122 | mpvOne :: FilePath -> MpvCommand -> IO (Maybe MpvResponse) | ||
123 | mpvOne dir cmd = listToMaybe . snd . partitionEithers . map snd <$> (mpvDir dir step :: IO [(FilePath, Either SomeException MpvResponse)]) | ||
124 | where | ||
125 | step _ results | ||
126 | | any (isRight . snd) results = Nothing | ||
127 | | otherwise = Just cmd | ||
diff --git a/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MyPass.hs b/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MyPass.hs deleted file mode 100644 index 1caefae5..00000000 --- a/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MyPass.hs +++ /dev/null | |||
@@ -1,94 +0,0 @@ | |||
1 | module XMonad.Prompt.MyPass | ||
2 | ( | ||
3 | -- * Usages | ||
4 | -- $usages | ||
5 | mkPassPrompt | ||
6 | ) where | ||
7 | |||
8 | import Control.Monad (liftM) | ||
9 | import XMonad.Core | ||
10 | import XMonad.Prompt ( XPrompt | ||
11 | , showXPrompt | ||
12 | , commandToComplete | ||
13 | , nextCompletion | ||
14 | , getNextCompletion | ||
15 | , XPConfig | ||
16 | , mkXPrompt | ||
17 | , searchPredicate) | ||
18 | import System.Directory (getHomeDirectory) | ||
19 | import System.FilePath (takeExtension, dropExtension, combine) | ||
20 | import System.Posix.Env (getEnv) | ||
21 | import XMonad.Util.Run (runProcessWithInput) | ||
22 | |||
23 | -- $usages | ||
24 | -- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: | ||
25 | -- | ||
26 | -- > import XMonad.Prompt.Pass | ||
27 | -- | ||
28 | -- Then add a keybinding for 'passPrompt', 'passGeneratePrompt' or 'passRemovePrompt': | ||
29 | -- | ||
30 | -- > , ((modMask x , xK_p) , passPrompt xpconfig) | ||
31 | -- > , ((modMask x .|. controlMask, xK_p) , passGeneratePrompt xpconfig) | ||
32 | -- > , ((modMask x .|. controlMask .|. shiftMask, xK_p), passRemovePrompt xpconfig) | ||
33 | -- | ||
34 | -- For detailed instructions on: | ||
35 | -- | ||
36 | -- - editing your key bindings, see "XMonad.Doc.Extending#Editing_key_bindings". | ||
37 | -- | ||
38 | -- - how to setup the password storage, see <http://git.zx2c4.com/password-store/about/> | ||
39 | -- | ||
40 | |||
41 | type Predicate = String -> String -> Bool | ||
42 | |||
43 | getPassCompl :: [String] -> Predicate -> String -> IO [String] | ||
44 | getPassCompl compls p s | ||
45 | | length s <= minL | ||
46 | , all ((> minL) . length) compls = return [] | ||
47 | | otherwise = do return $ filter (p s) compls | ||
48 | where | ||
49 | minL = 3 | ||
50 | |||
51 | type PromptLabel = String | ||
52 | |||
53 | data Pass = Pass PromptLabel | ||
54 | |||
55 | instance XPrompt Pass where | ||
56 | showXPrompt (Pass prompt) = prompt ++ ": " | ||
57 | commandToComplete _ c = c | ||
58 | nextCompletion _ = getNextCompletion | ||
59 | |||
60 | -- | Default password store folder in $HOME/.password-store | ||
61 | -- | ||
62 | passwordStoreFolderDefault :: String -> String | ||
63 | passwordStoreFolderDefault home = combine home ".password-store" | ||
64 | |||
65 | -- | Compute the password store's location. | ||
66 | -- Use the PASSWORD_STORE_DIR environment variable to set the password store. | ||
67 | -- If empty, return the password store located in user's home. | ||
68 | -- | ||
69 | passwordStoreFolder :: IO String | ||
70 | passwordStoreFolder = | ||
71 | getEnv "PASSWORD_STORE_DIR" >>= computePasswordStoreDir | ||
72 | where computePasswordStoreDir Nothing = liftM passwordStoreFolderDefault getHomeDirectory | ||
73 | computePasswordStoreDir (Just storeDir) = return storeDir | ||
74 | |||
75 | -- | A pass prompt factory | ||
76 | -- | ||
77 | mkPassPrompt :: PromptLabel -> (String -> X ()) -> XPConfig -> X () | ||
78 | mkPassPrompt promptLabel passwordFunction xpconfig = do | ||
79 | passwords <- io (passwordStoreFolder >>= getPasswords) | ||
80 | mkXPrompt (Pass promptLabel) xpconfig (getPassCompl passwords $ searchPredicate xpconfig) passwordFunction | ||
81 | |||
82 | -- | Retrieve the list of passwords from the password storage 'passwordStoreDir | ||
83 | getPasswords :: FilePath -> IO [String] | ||
84 | getPasswords passwordStoreDir = do | ||
85 | files <- runProcessWithInput "find" [ | ||
86 | passwordStoreDir, | ||
87 | "-type", "f", | ||
88 | "-name", "*.gpg", | ||
89 | "-printf", "%P\n"] [] | ||
90 | return $ map removeGpgExtension $ lines files | ||
91 | |||
92 | removeGpgExtension :: String -> String | ||
93 | removeGpgExtension file | takeExtension file == ".gpg" = dropExtension file | ||
94 | | otherwise = file | ||
diff --git a/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MyShell.hs b/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MyShell.hs deleted file mode 100644 index c268f87d..00000000 --- a/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MyShell.hs +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | module XMonad.Prompt.MyShell | ||
2 | ( Shell (..) | ||
3 | , shellPrompt | ||
4 | , prompt | ||
5 | , safePrompt | ||
6 | , unsafePrompt | ||
7 | , getCommands | ||
8 | , getShellCompl | ||
9 | , split | ||
10 | ) where | ||
11 | |||
12 | import Codec.Binary.UTF8.String (encodeString) | ||
13 | import Control.Exception as E | ||
14 | import Control.Monad (forM) | ||
15 | import Data.List (isPrefixOf) | ||
16 | import System.Directory (doesDirectoryExist, getDirectoryContents) | ||
17 | import System.Environment (getEnv) | ||
18 | import System.Posix.Files (getFileStatus, isDirectory) | ||
19 | |||
20 | import XMonad hiding (config) | ||
21 | import XMonad.Prompt | ||
22 | import XMonad.Util.Run | ||
23 | |||
24 | econst :: Monad m => a -> IOException -> m a | ||
25 | econst = const . return | ||
26 | |||
27 | data Shell = Shell String | ||
28 | |||
29 | instance XPrompt Shell where | ||
30 | showXPrompt (Shell q) = q | ||
31 | completionToCommand _ = escape | ||
32 | |||
33 | shellPrompt :: String -> XPConfig -> X () | ||
34 | shellPrompt q c = do | ||
35 | cmds <- io getCommands | ||
36 | mkXPrompt (Shell q) c (getShellCompl cmds) spawn | ||
37 | |||
38 | {- $spawns | ||
39 | See safe and unsafeSpawn in "XMonad.Util.Run". | ||
40 | prompt is an alias for safePrompt; | ||
41 | safePrompt and unsafePrompt work on the same principles, but will use | ||
42 | XPrompt to interactively query the user for input; the appearance is | ||
43 | set by passing an XPConfig as the second argument. The first argument | ||
44 | is the program to be run with the interactive input. | ||
45 | You would use these like this: | ||
46 | |||
47 | > , ((modm, xK_b), safePrompt "firefox" greenXPConfig) | ||
48 | > , ((modm .|. shiftMask, xK_c), prompt ("xterm" ++ " -e") greenXPConfig) | ||
49 | |||
50 | Note that you want to use safePrompt for Firefox input, as Firefox | ||
51 | wants URLs, and unsafePrompt for the XTerm example because this allows | ||
52 | you to easily start a terminal executing an arbitrary command, like | ||
53 | 'top'. -} | ||
54 | |||
55 | prompt, unsafePrompt, safePrompt :: String -> FilePath -> XPConfig -> X () | ||
56 | prompt = unsafePrompt | ||
57 | safePrompt q c config = mkXPrompt (Shell q) config (getShellCompl [c]) run | ||
58 | where run = safeSpawn c . return | ||
59 | unsafePrompt q c config = mkXPrompt (Shell q) config (getShellCompl [c]) run | ||
60 | where run a = unsafeSpawn $ c ++ " " ++ a | ||
61 | |||
62 | getShellCompl :: [String] -> String -> IO [String] | ||
63 | getShellCompl cmds s | s == "" || last s == ' ' = return [] | ||
64 | | otherwise = do | ||
65 | f <- fmap lines $ runProcessWithInput "bash" [] ("compgen -A file -- " | ||
66 | ++ s ++ "\n") | ||
67 | files <- case f of | ||
68 | [x] -> do fs <- getFileStatus (encodeString x) | ||
69 | if isDirectory fs then return [x ++ "/"] | ||
70 | else return [x] | ||
71 | _ -> return f | ||
72 | return . uniqSort $ files ++ commandCompletionFunction cmds s | ||
73 | |||
74 | commandCompletionFunction :: [String] -> String -> [String] | ||
75 | commandCompletionFunction cmds str | '/' `elem` str = [] | ||
76 | | otherwise = filter (isPrefixOf str) cmds | ||
77 | |||
78 | getCommands :: IO [String] | ||
79 | getCommands = do | ||
80 | p <- getEnv "PATH" `E.catch` econst [] | ||
81 | let ds = filter (/= "") $ split ':' p | ||
82 | es <- forM ds $ \d -> do | ||
83 | exists <- doesDirectoryExist d | ||
84 | if exists | ||
85 | then getDirectoryContents d | ||
86 | else return [] | ||
87 | return . uniqSort . filter ((/= '.') . head) . concat $ es | ||
88 | |||
89 | split :: Eq a => a -> [a] -> [[a]] | ||
90 | split _ [] = [] | ||
91 | split e l = | ||
92 | f : split e (rest ls) | ||
93 | where | ||
94 | (f,ls) = span (/=e) l | ||
95 | rest s | s == [] = [] | ||
96 | | otherwise = tail s | ||
97 | |||
98 | escape :: String -> String | ||
99 | escape [] = "" | ||
100 | escape (x:xs) | ||
101 | | isSpecialChar x = '\\' : x : escape xs | ||
102 | | otherwise = x : escape xs | ||
103 | |||
104 | isSpecialChar :: Char -> Bool | ||
105 | isSpecialChar = flip elem " &\\@\"'#?$*()[]{};" | ||
diff --git a/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MySsh.hs b/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MySsh.hs deleted file mode 100644 index 998c533e..00000000 --- a/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MySsh.hs +++ /dev/null | |||
@@ -1,246 +0,0 @@ | |||
1 | module XMonad.Prompt.MySsh | ||
2 | ( -- * Usage | ||
3 | -- $usage | ||
4 | sshPrompt, | ||
5 | Ssh, | ||
6 | Override (..), | ||
7 | mkOverride, | ||
8 | Conn (..), | ||
9 | moshCmd, | ||
10 | moshCmd', | ||
11 | sshCmd, | ||
12 | inTmux, | ||
13 | withEnv | ||
14 | ) where | ||
15 | |||
16 | import XMonad | ||
17 | import XMonad.Util.Run | ||
18 | import XMonad.Prompt | ||
19 | |||
20 | import System.Directory | ||
21 | import System.Environment | ||
22 | import qualified Control.Exception as E | ||
23 | |||
24 | import Control.Monad | ||
25 | import Data.Maybe | ||
26 | |||
27 | import Text.Parsec.String | ||
28 | import Text.Parsec | ||
29 | import Data.Char (isSpace) | ||
30 | |||
31 | econst :: Monad m => a -> E.IOException -> m a | ||
32 | econst = const . return | ||
33 | |||
34 | -- $usage | ||
35 | -- 1. In your @~\/.xmonad\/xmonad.hs@: | ||
36 | -- | ||
37 | -- > import XMonad.Prompt | ||
38 | -- > import XMonad.Prompt.Ssh | ||
39 | -- | ||
40 | -- 2. In your keybindings add something like: | ||
41 | -- | ||
42 | -- > , ((modm .|. controlMask, xK_s), sshPrompt defaultXPConfig) | ||
43 | -- | ||
44 | -- Keep in mind, that if you want to use the completion you have to | ||
45 | -- disable the "HashKnownHosts" option in your ssh_config | ||
46 | -- | ||
47 | -- For detailed instruction on editing the key binding see | ||
48 | -- "XMonad.Doc.Extending#Editing_key_bindings". | ||
49 | |||
50 | data Override = Override | ||
51 | { oUser :: Maybe String | ||
52 | , oHost :: String | ||
53 | , oPort :: Maybe Int | ||
54 | , oCommand :: Conn -> String | ||
55 | } | ||
56 | |||
57 | mkOverride = Override { oUser = Nothing, oHost = "", oPort = Nothing, oCommand = sshCmd } | ||
58 | sshCmd c = concat | ||
59 | [ "ssh -t " | ||
60 | , if isJust $ cUser c then (fromJust $ cUser c) ++ "@" else "" | ||
61 | , cHost c | ||
62 | , if isJust $ cPort c then " -p " ++ (show $ fromJust $ cPort c) else "" | ||
63 | , " -- " | ||
64 | , cCommand c | ||
65 | ] | ||
66 | moshCmd c = concat | ||
67 | [ "mosh " | ||
68 | , if isJust $ cUser c then (fromJust $ cUser c) ++ "@" else "" | ||
69 | , cHost c | ||
70 | , if isJust $ cPort c then " --ssh=\"ssh -p " ++ (show $ fromJust $ cPort c) ++ "\"" else "" | ||
71 | , " -- " | ||
72 | , cCommand c | ||
73 | ] | ||
74 | moshCmd' p c = concat | ||
75 | [ "mosh " | ||
76 | , "--server=" ++ p ++ " " | ||
77 | , if isJust $ cUser c then (fromJust $ cUser c) ++ "@" else "" | ||
78 | , cHost c | ||
79 | , if isJust $ cPort c then " --ssh=\"ssh -p " ++ (show $ fromJust $ cPort c) ++ "\"" else "" | ||
80 | , " -- " | ||
81 | , cCommand c | ||
82 | ] | ||
83 | inTmux Nothing c | ||
84 | | null $ cCommand c = c { cCommand = "tmux new-session" } | ||
85 | | otherwise = c { cCommand = "tmux new-session \"" ++ (cCommand c) ++ "\"" } | ||
86 | inTmux (Just h) c | ||
87 | | null $ cCommand c = c { cCommand = "tmux new-session -As " <> h } | ||
88 | | otherwise = c { cCommand = "tmux new-session \"" ++ (cCommand c) ++ "\"" } | ||
89 | withEnv :: [(String, String)] -> Conn -> Conn | ||
90 | withEnv envs c = c { cCommand = "env" ++ (concat $ map (\(n, v) -> ' ' : (n ++ "=" ++ v)) envs) ++ " " ++ (cCommand c) } | ||
91 | |||
92 | data Conn = Conn | ||
93 | { cUser :: Maybe String | ||
94 | , cHost :: String | ||
95 | , cPort :: Maybe Int | ||
96 | , cCommand :: String | ||
97 | } deriving (Eq, Show, Read) | ||
98 | |||
99 | data Ssh = Ssh | ||
100 | |||
101 | instance XPrompt Ssh where | ||
102 | showXPrompt Ssh = "SSH to: " | ||
103 | commandToComplete _ c = c | ||
104 | nextCompletion _ = getNextCompletion | ||
105 | |||
106 | toConn :: String -> Maybe Conn | ||
107 | toConn = toConn' . parse connParser "(unknown)" | ||
108 | toConn' :: Either ParseError Conn -> Maybe Conn | ||
109 | toConn' (Left _) = Nothing | ||
110 | toConn' (Right a) = Just a | ||
111 | |||
112 | connParser :: Parser Conn | ||
113 | connParser = do | ||
114 | spaces | ||
115 | user' <- optionMaybe $ try $ do | ||
116 | str <- many1 $ satisfy (\c -> (not $ isSpace c) && (c /= '@')) | ||
117 | char '@' | ||
118 | return str | ||
119 | host' <- many1 $ satisfy (not . isSpace) | ||
120 | port' <- optionMaybe $ try $ do | ||
121 | space | ||
122 | string "-p" | ||
123 | spaces | ||
124 | int <- many1 digit | ||
125 | (space >> return ()) <|> eof | ||
126 | return $ (read int :: Int) | ||
127 | spaces | ||
128 | command' <- many anyChar | ||
129 | eof | ||
130 | return $ Conn | ||
131 | { cHost = host' | ||
132 | , cUser = user' | ||
133 | , cPort = port' | ||
134 | , cCommand = command' | ||
135 | } | ||
136 | |||
137 | sshPrompt :: [Override] -> XPConfig -> X () | ||
138 | sshPrompt o c = do | ||
139 | sc <- io sshComplList | ||
140 | mkXPrompt Ssh c (mkComplFunFromList c sc) $ ssh o | ||
141 | |||
142 | ssh :: [Override] -> String -> X () | ||
143 | ssh overrides str = do | ||
144 | let cmd = applyOverrides overrides str | ||
145 | liftIO $ putStr "SSH Command: " | ||
146 | liftIO $ putStrLn cmd | ||
147 | runInTerm "" cmd | ||
148 | |||
149 | applyOverrides :: [Override] -> String -> String | ||
150 | applyOverrides [] str = "ssh " ++ str | ||
151 | applyOverrides (o:os) str = case (applyOverride o str) of | ||
152 | Just str -> str | ||
153 | Nothing -> applyOverrides os str | ||
154 | |||
155 | applyOverride :: Override -> String -> Maybe String | ||
156 | applyOverride o str = let | ||
157 | conn = toConn str | ||
158 | in | ||
159 | if isNothing conn then Nothing else | ||
160 | case (fromJust conn) `matches` o of | ||
161 | True -> Just $ (oCommand o) (fromJust conn) | ||
162 | False -> Nothing | ||
163 | |||
164 | matches :: Conn -> Override -> Bool | ||
165 | a `matches` b = and | ||
166 | [ justBool (cUser a) (oUser b) (==) | ||
167 | , (cHost a) == (oHost b) | ||
168 | , justBool (cPort a) (oPort b) (==) | ||
169 | ] | ||
170 | |||
171 | justBool :: Eq a => Maybe a -> Maybe a -> (a -> a -> Bool) -> Bool | ||
172 | justBool Nothing _ _ = True | ||
173 | justBool _ Nothing _ = True | ||
174 | justBool (Just a) (Just b) match = a `match` b | ||
175 | |||
176 | sshComplList :: IO [String] | ||
177 | sshComplList = uniqSort `fmap` liftM2 (++) sshComplListLocal sshComplListGlobal | ||
178 | |||
179 | sshComplListLocal :: IO [String] | ||
180 | sshComplListLocal = do | ||
181 | h <- getEnv "HOME" | ||
182 | s1 <- sshComplListFile $ h ++ "/.ssh/known_hosts" | ||
183 | s2 <- sshComplListConf $ h ++ "/.ssh/config" | ||
184 | return $ s1 ++ s2 | ||
185 | |||
186 | sshComplListGlobal :: IO [String] | ||
187 | sshComplListGlobal = do | ||
188 | env <- getEnv "SSH_KNOWN_HOSTS" `E.catch` econst "/nonexistent" | ||
189 | fs <- mapM fileExists [ env | ||
190 | , "/usr/local/etc/ssh/ssh_known_hosts" | ||
191 | , "/usr/local/etc/ssh_known_hosts" | ||
192 | , "/etc/ssh/ssh_known_hosts" | ||
193 | , "/etc/ssh_known_hosts" | ||
194 | ] | ||
195 | case catMaybes fs of | ||
196 | [] -> return [] | ||
197 | (f:_) -> sshComplListFile' f | ||
198 | |||
199 | sshComplListFile :: String -> IO [String] | ||
200 | sshComplListFile kh = do | ||
201 | f <- doesFileExist kh | ||
202 | if f then sshComplListFile' kh | ||
203 | else return [] | ||
204 | |||
205 | sshComplListFile' :: String -> IO [String] | ||
206 | sshComplListFile' kh = do | ||
207 | l <- readFile kh | ||
208 | return $ map (getWithPort . takeWhile (/= ',') . concat . take 1 . words) | ||
209 | $ filter nonComment | ||
210 | $ lines l | ||
211 | |||
212 | sshComplListConf :: String -> IO [String] | ||
213 | sshComplListConf kh = do | ||
214 | f <- doesFileExist kh | ||
215 | if f then sshComplListConf' kh | ||
216 | else return [] | ||
217 | |||
218 | sshComplListConf' :: String -> IO [String] | ||
219 | sshComplListConf' kh = do | ||
220 | l <- readFile kh | ||
221 | return $ map (!!1) | ||
222 | $ filter isHost | ||
223 | $ map words | ||
224 | $ lines l | ||
225 | where | ||
226 | isHost ws = take 1 ws == ["Host"] && length ws > 1 | ||
227 | |||
228 | fileExists :: String -> IO (Maybe String) | ||
229 | fileExists kh = do | ||
230 | f <- doesFileExist kh | ||
231 | if f then return $ Just kh | ||
232 | else return Nothing | ||
233 | |||
234 | nonComment :: String -> Bool | ||
235 | nonComment [] = False | ||
236 | nonComment ('#':_) = False | ||
237 | nonComment ('|':_) = False -- hashed, undecodeable | ||
238 | nonComment _ = True | ||
239 | |||
240 | getWithPort :: String -> String | ||
241 | getWithPort ('[':str) = host ++ " -p " ++ port | ||
242 | where (host,p) = break (==']') str | ||
243 | port = case p of | ||
244 | ']':':':x -> x | ||
245 | _ -> "22" | ||
246 | getWithPort str = str | ||
diff --git a/accounts/gkleen@sif/xmonad/package.yaml b/accounts/gkleen@sif/xmonad/package.yaml deleted file mode 100644 index f65137af..00000000 --- a/accounts/gkleen@sif/xmonad/package.yaml +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | name: xmonad-yggdrasil | ||
2 | |||
3 | executables: | ||
4 | xmonad: | ||
5 | dependencies: | ||
6 | - base | ||
7 | - xmonad | ||
8 | - xmonad-contrib | ||
9 | - aeson | ||
10 | - bytestring | ||
11 | - text | ||
12 | - temporary | ||
13 | - filepath | ||
14 | - directory | ||
15 | - network | ||
16 | - unix | ||
17 | - utf8-string | ||
18 | - parsec | ||
19 | - process | ||
20 | - mtl | ||
21 | - X11 | ||
22 | - transformers | ||
23 | - containers | ||
24 | - hostname | ||
25 | - libnotify | ||
26 | - taffybar | ||
27 | |||
28 | main: xmonad.hs | ||
29 | source-dirs: | ||
30 | - . | ||
31 | - lib | ||
diff --git a/accounts/gkleen@sif/xmonad/stack.nix b/accounts/gkleen@sif/xmonad/stack.nix deleted file mode 100644 index 17a49e04..00000000 --- a/accounts/gkleen@sif/xmonad/stack.nix +++ /dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | { ghc, nixpkgs ? import ./nixpkgs.nix {} }: | ||
2 | |||
3 | let | ||
4 | haskellPackages = import ./stackage.nix { inherit nixpkgs; }; | ||
5 | inherit (nixpkgs {}) pkgs; | ||
6 | in pkgs.haskell.lib.buildStackProject { | ||
7 | inherit ghc; | ||
8 | inherit (haskellPackages) stack; | ||
9 | name = "stackenv"; | ||
10 | buildInputs = (with pkgs; | ||
11 | [ xorg.libX11 xorg.libXrandr xorg.libXinerama xorg.libXScrnSaver xorg.libXext xorg.libXft | ||
12 | cairo | ||
13 | glib | ||
14 | ]) ++ (with haskellPackages; | ||
15 | [ | ||
16 | ]); | ||
17 | } | ||
diff --git a/accounts/gkleen@sif/xmonad/stack.yaml b/accounts/gkleen@sif/xmonad/stack.yaml deleted file mode 100644 index b8ed1147..00000000 --- a/accounts/gkleen@sif/xmonad/stack.yaml +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | nix: | ||
2 | enable: true | ||
3 | shell-file: stack.nix | ||
4 | |||
5 | resolver: lts-13.21 | ||
6 | |||
7 | packages: | ||
8 | - . | ||
9 | |||
10 | extra-deps: [] | ||
diff --git a/accounts/gkleen@sif/xmonad/xmonad-yggdrasil.nix b/accounts/gkleen@sif/xmonad/xmonad-yggdrasil.nix deleted file mode 100644 index 7c853619..00000000 --- a/accounts/gkleen@sif/xmonad/xmonad-yggdrasil.nix +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | { mkDerivation, aeson, base, bytestring, containers, directory | ||
2 | , filepath, hostname, hpack, mtl, network, parsec, process, lib | ||
3 | , temporary, transformers, unix, utf8-string, X11, xmonad | ||
4 | , xmonad-contrib, libnotify, taffybar | ||
5 | }: | ||
6 | mkDerivation { | ||
7 | pname = "xmonad-yggdrasil"; | ||
8 | version = "0.0.0"; | ||
9 | src = ./.; | ||
10 | isLibrary = false; | ||
11 | isExecutable = true; | ||
12 | libraryToolDepends = [ hpack ]; | ||
13 | executableHaskellDepends = [ | ||
14 | aeson base bytestring containers directory filepath hostname mtl | ||
15 | network parsec process temporary transformers unix utf8-string X11 | ||
16 | xmonad xmonad-contrib libnotify taffybar | ||
17 | ]; | ||
18 | preConfigure = "hpack"; | ||
19 | license = "unknown"; | ||
20 | hydraPlatforms = lib.platforms.none; | ||
21 | } | ||
diff --git a/accounts/gkleen@sif/xmonad/xmonad.hs b/accounts/gkleen@sif/xmonad/xmonad.hs deleted file mode 100644 index a44d3bb7..00000000 --- a/accounts/gkleen@sif/xmonad/xmonad.hs +++ /dev/null | |||
@@ -1,939 +0,0 @@ | |||
1 | {-# LANGUAGE TupleSections, ViewPatterns, OverloadedStrings, FlexibleInstances, UndecidableInstances, MultiWayIf, NumDecimals #-} | ||
2 | |||
3 | import XMonad | ||
4 | import XMonad.Hooks.DynamicLog | ||
5 | import XMonad.Hooks.ManageDocks | ||
6 | import XMonad.Util.Run hiding (proc) | ||
7 | import XMonad.Util.Loggers | ||
8 | import XMonad.Util.EZConfig(additionalKeys) | ||
9 | import System.IO | ||
10 | import System.IO.Error | ||
11 | import System.Environment | ||
12 | import Data.Map (Map) | ||
13 | import qualified Data.Map as Map | ||
14 | import qualified XMonad.StackSet as W | ||
15 | import System.Exit | ||
16 | import Control.Monad.State (get) | ||
17 | -- import XMonad.Layout.Spiral | ||
18 | import Data.Ratio | ||
19 | import Data.List | ||
20 | import Data.Char | ||
21 | import Data.Maybe (fromMaybe, listToMaybe, maybeToList, catMaybes, isJust) | ||
22 | import XMonad.Layout.Tabbed | ||
23 | import XMonad.Prompt | ||
24 | import XMonad.Prompt.Input | ||
25 | import XMonad.Util.Scratchpad | ||
26 | import XMonad.Util.NamedScratchpad | ||
27 | import XMonad.Util.Ungrab | ||
28 | import Control.Monad (sequence, liftM, liftM2, join, void) | ||
29 | import XMonad.Util.WorkspaceCompare | ||
30 | import XMonad.Layout.NoBorders | ||
31 | import XMonad.Layout.PerWorkspace | ||
32 | import XMonad.Layout.SimplestFloat | ||
33 | import XMonad.Layout.Renamed | ||
34 | import XMonad.Layout.Reflect | ||
35 | import XMonad.Layout.OnHost | ||
36 | import XMonad.Layout.Combo | ||
37 | import XMonad.Layout.ComboP | ||
38 | import XMonad.Layout.Column | ||
39 | import XMonad.Layout.TwoPane | ||
40 | import XMonad.Layout.IfMax | ||
41 | import XMonad.Layout.LayoutBuilder | ||
42 | import XMonad.Layout.WindowNavigation | ||
43 | import XMonad.Layout.Dwindle | ||
44 | import XMonad.Layout.TrackFloating | ||
45 | import System.Process | ||
46 | import System.Directory (removeFile) | ||
47 | import System.Posix.Files | ||
48 | import System.FilePath ((</>)) | ||
49 | import Control.Concurrent | ||
50 | import System.Posix.Process (getProcessID) | ||
51 | import System.IO.Error | ||
52 | import System.IO | ||
53 | import XMonad.Hooks.ManageHelpers hiding (CW) | ||
54 | import XMonad.Hooks.UrgencyHook as U | ||
55 | import XMonad.Hooks.EwmhDesktops | ||
56 | import XMonad.StackSet (RationalRect (..)) | ||
57 | import Control.Monad (when, filterM, (<=<)) | ||
58 | import Graphics.X11.ExtraTypes.XF86 | ||
59 | import XMonad.Util.Cursor | ||
60 | import XMonad.Actions.Warp | ||
61 | import XMonad.Actions.FloatKeys | ||
62 | import XMonad.Util.SpawnOnce | ||
63 | import System.Directory | ||
64 | import System.FilePath | ||
65 | import XMonad.Actions.CopyWindow | ||
66 | import XMonad.Hooks.ServerMode | ||
67 | import XMonad.Actions.Commands | ||
68 | import XMonad.Actions.CycleWS | ||
69 | import XMonad.Actions.RotSlaves | ||
70 | import XMonad.Actions.UpdatePointer | ||
71 | import XMonad.Prompt.Window | ||
72 | import Data.IORef | ||
73 | import Data.Monoid | ||
74 | import Data.String | ||
75 | import qualified XMonad.Actions.PhysicalScreens as P | ||
76 | |||
77 | import XMonad.Layout.IM | ||
78 | |||
79 | import System.Taffybar.Support.PagerHints (pagerHints) | ||
80 | |||
81 | import XMonad.Prompt.MyShell | ||
82 | import XMonad.Prompt.MyPass | ||
83 | import XMonad.Prompt.MySsh | ||
84 | |||
85 | import XMonad.Mpv | ||
86 | |||
87 | import Network.HostName | ||
88 | |||
89 | import Control.Applicative ((<$>)) | ||
90 | |||
91 | import Libnotify as Notify hiding (appName) | ||
92 | import qualified Libnotify as Notify (appName) | ||
93 | import Libnotify (Notification) | ||
94 | -- import System.Information.Battery | ||
95 | |||
96 | import Data.Int (Int32) | ||
97 | |||
98 | import System.Posix.Process | ||
99 | import System.Posix.Signals | ||
100 | import System.Posix.IO as Posix | ||
101 | import Control.Exception | ||
102 | |||
103 | import System.IO.Unsafe | ||
104 | |||
105 | import Control.Monad.Trans.Class | ||
106 | import Control.Monad.Trans.Maybe | ||
107 | |||
108 | import Data.Fixed (Micro) | ||
109 | |||
110 | import qualified Data.Text as Text | ||
111 | import Data.Ord (comparing) | ||
112 | import Debug.Trace | ||
113 | |||
114 | instance MonadIO m => IsString (m ()) where | ||
115 | fromString = spawn | ||
116 | |||
117 | type KeyMap = Map (ButtonMask, KeySym) (X ()) | ||
118 | |||
119 | data Host = Host | ||
120 | { hName :: HostName | ||
121 | , hManageHook :: ManageHook | ||
122 | , hWsp :: Integer -> WorkspaceId | ||
123 | , hCoWsp :: String -> Maybe WorkspaceId | ||
124 | , hKeysMod :: XConfig Layout -> (KeyMap -> KeyMap) | ||
125 | , hScreens :: [P.PhysicalScreen] | ||
126 | , hKbLayouts :: [(String, Maybe String)] | ||
127 | , hCmds :: X [(String, X ())] | ||
128 | , hKeyUpKeys :: XConfig Layout -> KeyMap | ||
129 | } | ||
130 | |||
131 | defaultHost = Host { hName = "unkown" | ||
132 | , hManageHook = composeOne [manageScratchTerm] | ||
133 | , hWsp = show | ||
134 | , hCoWsp = const Nothing | ||
135 | , hKeysMod = const id | ||
136 | , hScreens = [0,1..] | ||
137 | , hKbLayouts = [ ("us", Just "dvp") | ||
138 | , ("us", Nothing) | ||
139 | , ("de", Nothing) | ||
140 | ] | ||
141 | , hCmds = return [] | ||
142 | , hKeyUpKeys = const Map.empty | ||
143 | } | ||
144 | |||
145 | browser :: String | ||
146 | browser = "env MOZ_USE_XINPUT2=1 firefox" | ||
147 | |||
148 | gray, darkGray, red, green :: String | ||
149 | gray = "#808080" | ||
150 | darkGray = "#202020" | ||
151 | red = "#800000" | ||
152 | green = "#008000" | ||
153 | |||
154 | hostFromName :: HostName -> Host | ||
155 | hostFromName h@("vali") = defaultHost { hName = h | ||
156 | , hManageHook = composeOne $ catMaybes [ Just manageScratchTerm | ||
157 | , assign "web" $ className =? ".dwb-wrapped" | ||
158 | , assign "web" $ className =? "Chromium" | ||
159 | , assign "work" $ className =? "Emacs" | ||
160 | , assign "media" $ className =? "mpv" | ||
161 | ] | ||
162 | , hWsp = hWsp | ||
163 | , hCoWsp = hCoWsp | ||
164 | , hKeysMod = \conf -> Map.union $ (Map.fromList $ join $ map (spawnBindings conf) [ (xK_d, ["chromium", "chromium $(xclip -o)"]) | ||
165 | , (xK_e, ["emacsclient -c"]) | ||
166 | ]) | ||
167 | `Map.union` | ||
168 | ( Map.fromList [ ((XMonad.modMask conf .|. controlMask, xK_Return), scratchpadSpawnActionCustom $ (XMonad.terminal conf) ++ " -name scratchpad -title scratchpad -e tmux new-session -D -s scratch") | ||
169 | ] ) | ||
170 | , hScreens = hScreens defaultHost | ||
171 | } | ||
172 | where | ||
173 | workspaceNames = Map.fromList [ (2, "web") | ||
174 | , (3, "work") | ||
175 | , (10, "media") | ||
176 | ] | ||
177 | hWsp = wspFromMap workspaceNames | ||
178 | hCoWsp = coWspFromMap workspaceNames | ||
179 | assign wsp test = (\wsp -> test -?> doShift wsp) <$> hCoWsp wsp | ||
180 | hostFromName h | ||
181 | | h `elem` ["hel", "sif"] = defaultHost { hName = h | ||
182 | , hManageHook = namedScratchpadManageHook scratchpads <+> composeOne (catMaybes | ||
183 | [ assign "mpv" $ className =? "mpv" | ||
184 | , assign "mpv" $ stringProperty "WM_WINDOW_ROLE" =? "presentation" | ||
185 | , assign "read" $ stringProperty "WM_WINDOW_ROLE" =? "presenter" | ||
186 | , assign "mpv" $ className =? "factorio" | ||
187 | , assign "mpv" $ resource =? "twitch" | ||
188 | , assign "web" $ className =? "chromium-browser" | ||
189 | , assign "web" $ className =? "Google-chrome" | ||
190 | , assign "work" $ (appName =? "Devtools" <&&> className =? "firefox") | ||
191 | , assign "work" $ className =? "Postman" | ||
192 | , assign "web" $ (appName =? "Navigator" <&&> className =? "firefox") | ||
193 | , assign "comm" $ (className =? "Emacs" <&&> title =? "Mail") | ||
194 | , assign "comm" $ className =? "Zulip" | ||
195 | , assign "comm" $ className =? "Element" | ||
196 | , assign "comm" $ className =? "Rocket.Chat" | ||
197 | , assign "comm" $ className =? "Discord" | ||
198 | , assign "comm" $ className =? "Rainbow" | ||
199 | , assign "media" $ resource =? "media" | ||
200 | , assign "monitor" $ className =? "Grafana" | ||
201 | , assign "monitor" $ className =? "Virt-viewer" | ||
202 | , assign "monitor" $ resource =? "htop" | ||
203 | , assign "monitor" $ resource =? "monitor" | ||
204 | , assign "monitor" $ className =? "xfreerdp" | ||
205 | , assign "monitor" $ className =? "org.remmina.Remmina" | ||
206 | , Just $ resource =? "htop" -?> centerFloat | ||
207 | , Just $ (className =? "Scp-dbus-service.py") -?> centerFloat | ||
208 | , Just $ resource =? "log" -?> centerFloat | ||
209 | , assign "work" $ className =? "Alacritty" | ||
210 | , Just $ (appName =? "Edit with Emacs FRAME") -?> centerFloat | ||
211 | , assign' ["work", "uni"] $ (className =? "Emacs" <&&> appName /=? "Edit with Emacs FRAME") | ||
212 | , assign' ["work", "uni"] $ className =? "jetbrains-idea-ce" | ||
213 | , assign "read" $ className =? "llpp" | ||
214 | , assign "read" $ className =? "Evince" | ||
215 | , assign "read" $ className =? "Zathura" | ||
216 | , assign "read" $ className =? "MuPDF" | ||
217 | , assign "read" $ className =? "Xournal" | ||
218 | , assign "read" $ appName =? "libreoffice" | ||
219 | , assign "read" $ appName =? "com-trollworks-gcs-app-GCS" | ||
220 | , assign "read" $ appName =? "Tux.py" | ||
221 | , assign "read" $ className =? "Gnucash" | ||
222 | , assign "comm" $ className =? "Skype" | ||
223 | , assign "comm" $ className =? "Daily" | ||
224 | , assign "comm" $ className =? "Pidgin" | ||
225 | , assign "comm" $ className =? "Thunderbird" | ||
226 | , assign "comm" $ className =? "Slack" | ||
227 | , Just $ (resource =? "xvkbd") -?> doRectFloat $ RationalRect (1 % 8) (3 % 8) (6 % 8) (4 % 8) | ||
228 | , Just $ (stringProperty "_NET_WM_WINDOW_TYPE" =? "_NET_WM_WINDOW_TYPE_DIALOG") -?> doFloat | ||
229 | , Just $ (className =? "Dunst") -?> doFloat | ||
230 | , Just $ (className =? "Xmessage") -?> doCenterFloat | ||
231 | , Just $ (className =? "Nm-openconnect-auth-dialog") -?> centerFloat | ||
232 | , Just $ (className =? "Pinentry") -?> doCenterFloat | ||
233 | , Just $ (className =? "pinentry") -?> doCenterFloat | ||
234 | , Just $ (stringProperty "WM_WINDOW_ROLE" =? "GtkFileChooseDialog") -?> centerFloatSmall | ||
235 | , Just $ (className =? "Nvidia-settings") -?> doCenterFloat | ||
236 | , Just $ fmap ("Minetest" `isInfixOf`) title -?> doIgnore | ||
237 | , Just $ fmap ("Automachef" `isInfixOf`) title -?> doIgnore | ||
238 | , assign "call" $ className =? "zoom" | ||
239 | ]) | ||
240 | , hWsp = hWsp | ||
241 | , hCoWsp = hCoWsp | ||
242 | , hKeysMod = \conf -> Map.union $ (Map.fromList $ join $ map (spawnBindings conf) [ (xK_e, ["emacsclient -c"]) | ||
243 | , (xK_d, [fromString browser, "google-chrome" {- , "notmuch-links" -}]) | ||
244 | , (xK_c, [ inputPrompt xPConfigMonospace "dc" ?+ dc ]) | ||
245 | , (xK_g, ["pidgin"]) | ||
246 | , (xK_s, ["skype"]) | ||
247 | -- , (xK_p, [mkPassPrompt "Type password" pwType xPConfig, mkPassPrompt "Show password" pwShow xPConfig, mkPassPrompt "Copy password" pwClip xPConfig]) | ||
248 | , (xK_w, ["sudo rewacom"]) | ||
249 | , (xK_y, [ "tmux new-window -dt media /var/media/link.hs $(xclip -o)" | ||
250 | , "tmux new-window -dt media /var/media/download.hs $(xclip -o)" | ||
251 | , "tmux new-window -dt media /var/media/download.hs $(xclip -o -selection clipboard)" | ||
252 | ]) | ||
253 | , (xK_l, [ "tmux new-window -dt media mpv $(xclip -o)" | ||
254 | , "tmux new-window -dt media mpv $(xclip -o -selection clipboard)" | ||
255 | , "alacritty --class media -e tmuxp load /var/media" | ||
256 | ]) | ||
257 | {- , (xK_m, [ "emacsclient -c -F \"'(title . \\\"Mail\\\")\" -e '(notmuch)'" | ||
258 | , "emacsclient -c -F \"'(title . \\\"Mail\\\")\" -e '(notmuch-mua-new-mail)'" | ||
259 | , "emacsclient -c -F \"'(title . \\\"Mail\\\")\" -e \"(browse-url-mail \"$(xclip -o)\")\"" | ||
260 | ]) -} | ||
261 | , (xK_Return, ["keynav start,windowzoom", "keynav start"]) | ||
262 | , (xK_t, [inputPrompt xPConfigMonospace "fuzzytime timer" ?+ fuzzytime, fuzzytime "unset", work_fuzzytime]) | ||
263 | , (xK_a, [inputPrompt xPConfigMonospace "adjmix" ?+ adjmix]) | ||
264 | , (xK_s, [ inputPromptWithCompl xPConfigMonospace "start synergy" synergyCompl ?+ synergyStart | ||
265 | , inputPromptWithCompl xPConfigMonospace "stop synergy" synergyCompl ?+ synergyStop | ||
266 | ]) | ||
267 | , (xK_h, [ "alacritty --class htop -e htop" | ||
268 | , "alacritty --class log -e journalctl -xef" | ||
269 | ]) | ||
270 | , (xK_x, [ "autorandr -c" | ||
271 | , "autorandr -fl def" | ||
272 | ]) | ||
273 | , (xK_z, [ "zulip -- --force-device-scale-factor=2" | ||
274 | ]) | ||
275 | ]) | ||
276 | `Map.union` | ||
277 | ( Map.fromList [ ((XMonad.modMask conf .|. controlMask, xK_Return), namedScratchpadAction scratchpads "term") | ||
278 | , ((XMonad.modMask conf .|. controlMask, xK_a), namedScratchpadAction scratchpads "pavucontrol") | ||
279 | , ((XMonad.modMask conf .|. controlMask, xK_o), namedScratchpadAction scratchpads "easyeffects") | ||
280 | , ((XMonad.modMask conf .|. controlMask .|. shiftMask, xK_o), namedScratchpadAction scratchpads "helvum") | ||
281 | , ((XMonad.modMask conf .|. controlMask, xK_w), namedScratchpadAction scratchpads "alarms") | ||
282 | , ((XMonad.modMask conf .|. controlMask, xK_b), namedScratchpadAction scratchpads "blueman") | ||
283 | , ((XMonad.modMask conf .|. controlMask, xK_p), namedScratchpadAction scratchpads "keepassxc") | ||
284 | , ((XMonad.modMask conf .|. controlMask, xK_t), namedScratchpadAction scratchpads "toggl") | ||
285 | , ((XMonad.modMask conf .|. controlMask, xK_e), namedScratchpadAction scratchpads "emacs") | ||
286 | , ((XMonad.modMask conf .|. controlMask, xK_m), namedScratchpadAction scratchpads "calendar") | ||
287 | , ((XMonad.modMask conf .|. controlMask, xK_f), namedScratchpadAction scratchpads "music") | ||
288 | , ((XMonad.modMask conf .|. mod1Mask, xK_Up), rotate U) | ||
289 | , ((XMonad.modMask conf .|. mod1Mask, xK_Down), rotate D) | ||
290 | , ((XMonad.modMask conf .|. mod1Mask, xK_Left), rotate L) | ||
291 | , ((XMonad.modMask conf .|. mod1Mask, xK_Right), rotate R) | ||
292 | , ((controlMask, xK_space ), "dunstctl close" ) | ||
293 | , ((controlMask .|. shiftMask, xK_space ), "dunstctl close-all" ) | ||
294 | , ((controlMask, xK_period), "dunstctl context" ) | ||
295 | , ((controlMask, xK_comma ), "dunstctl history-pop") | ||
296 | -- , ((XMonad.modMask conf .|. shiftMask, xK_a), startMute "hel") | ||
297 | ] ) | ||
298 | , hKeyUpKeys = \conf -> Map.fromList [ -- ((XMonad.modMask conf .|. shiftMask, xK_a), stopMute "hel") | ||
299 | ] | ||
300 | , hScreens = hScreens defaultHost | ||
301 | , hCmds = return [ ("prev-workspace", prevWS) | ||
302 | , ("next-workspace", nextWS) | ||
303 | , ("prev-window", rotAllDown) | ||
304 | , ("next-window", rotAllUp) | ||
305 | , ("banish", banishScreen LowerRight) | ||
306 | , ("update-gpg-tty", safeSpawn "gpg-connect-agent" ["UPDATESTARTUPTTY", "/bye"]) | ||
307 | , ("rescreen", rescreen) | ||
308 | , ("repanel", do | ||
309 | spawn "nm-applet" | ||
310 | spawn "blueman-applet" | ||
311 | spawn "pasystray" | ||
312 | spawn "kdeconnect-indicator" | ||
313 | spawn "dunst -print" | ||
314 | spawn "udiskie" | ||
315 | spawn "autocutsel -s PRIMARY" | ||
316 | spawn "autocutsel -s CLIPBOARD" | ||
317 | ) | ||
318 | , ("pause", mediaMpv $ MpvSetProperty "pause" True) | ||
319 | , ("unpause", mediaMpv $ MpvSetProperty "pause" False) | ||
320 | , ("exit", io $ exitWith ExitSuccess) | ||
321 | ] | ||
322 | } | ||
323 | where | ||
324 | withGdkScale act = void . xfork $ setEnv "GDK_SCALE" "2" >> act | ||
325 | workspaceNames = Map.fromList [ (1, "comm") | ||
326 | , (2, "web") | ||
327 | , (3, "work") | ||
328 | , (4, "read") | ||
329 | , (5, "monitor") | ||
330 | , (6, "uni") | ||
331 | , (8, "call") | ||
332 | , (9, "media") | ||
333 | , (10, "mpv") | ||
334 | ] | ||
335 | scratchpads = [ NS "term" "alacritty --class scratchpad --title scratchpad -e tmux new-session -AD -s scratch" (resource =? "scratchpad") centerFloat | ||
336 | , NS "pavucontrol" "pavucontrol" (resource =? "pavucontrol") centerFloat | ||
337 | , NS "helvum" "helvum" (resource =? "helvum") centerFloat | ||
338 | , NS "easyeffects" "easyeffects" (resource =? "easyeffects") centerFloat | ||
339 | , NS "alarms" "alarm-clock-applet" (className =? "Alarm-clock-applet" <&&> title =? "Alarms") centerFloat | ||
340 | , NS "blueman" "blueman-manager" (className =? ".blueman-manager-wrapped") centerFloat | ||
341 | , NS "keepassxc" "keepassxc" (className =? "KeePassXC") centerFloat | ||
342 | , NS "toggl" "toggldesktop" (className =? "Toggl Desktop") centerFloat | ||
343 | , NS "calendar" "minetime -- --force-device-scale-factor=1.6" (className =? "MineTime") centerFloat | ||
344 | , NS "emacs" "emacsclient -c -F \"'(title . \\\"Scratchpad\\\")\"" (className =? "Emacs" <&&> title =? "Scratchpad") centerFloat | ||
345 | , NS "music" "ytmdesktop" (className =? "youtube-music-desktop-app") centerFloat | ||
346 | ] | ||
347 | centerFloat = customFloating $ RationalRect (1 % 16) (1 % 16) (7 % 8) (7 % 8) | ||
348 | centerFloatSmall = customFloating $ RationalRect (1 % 4) (1 % 4) (1 % 2) (1 % 2) | ||
349 | hWsp = wspFromMap workspaceNames | ||
350 | hCoWsp = coWspFromMap workspaceNames | ||
351 | assign wsp test = (\wsp -> test -?> doShift wsp) <$> hCoWsp wsp | ||
352 | assign' :: [String] -> Query Bool -> Maybe MaybeManageHook | ||
353 | assign' wsps test = do | ||
354 | wsIds <- mapM hCoWsp wsps | ||
355 | return $ test -?> go wsIds | ||
356 | where | ||
357 | go :: [WorkspaceId] -> ManageHook | ||
358 | go wsps = do | ||
359 | visWsps <- liftX $ (\wset -> W.tag . W.workspace <$> W.current wset : W.visible wset) <$> gets windowset | ||
360 | case (filter (`elem` visWsps) wsps, wsps) of | ||
361 | (wsp : _, _) -> doShift wsp | ||
362 | (_, wsp : _) -> doShift wsp | ||
363 | ([], []) -> return mempty | ||
364 | rotate rot = do | ||
365 | safeSpawn "xrandr" ["--output", "eDP-1", "--rotate", xrandrDir] | ||
366 | mapM_ rotTouch touchscreens | ||
367 | where | ||
368 | xrandrDir = case rot of | ||
369 | U -> "normal" | ||
370 | L -> "left" | ||
371 | R -> "right" | ||
372 | D -> "inverted" | ||
373 | matrix = case rot of | ||
374 | U -> [ [ 1, 0, 0] | ||
375 | , [ 0, 1, 0] | ||
376 | , [ 0, 0, 1] | ||
377 | ] | ||
378 | L -> [ [ 0, -1, 1] | ||
379 | , [ 1, 0, 0] | ||
380 | , [ 0, 0, 1] | ||
381 | ] | ||
382 | R -> [ [ 0, 1, 0] | ||
383 | , [-1, 0, 1] | ||
384 | , [ 0, 0, 1] | ||
385 | ] | ||
386 | D -> [ [-1, 0, 1] | ||
387 | , [ 0, -1, 1] | ||
388 | , [ 0, 0, 1] | ||
389 | ] | ||
390 | touchscreens = [ "Wacom Co.,Ltd. Pen and multitouch sensor Finger touch" | ||
391 | , "Wacom Co.,Ltd. Pen and multitouch sensor Pen stylus" | ||
392 | , "Wacom Co.,Ltd. Pen and multitouch sensor Pen eraser" | ||
393 | ] | ||
394 | rotTouch screen = do | ||
395 | safeSpawn "xinput" $ ["set-prop", screen, "Coordinate Transformation Matrix"] ++ map (\n -> show n ++ ",") (concat matrix) | ||
396 | safeSpawn "xinput" ["map-to-output", screen, "eDP-1"] | ||
397 | withPw f label = io . void . forkProcess $ do | ||
398 | uninstallSignalHandlers | ||
399 | void $ createSession | ||
400 | (dropWhileEnd isSpace -> pw) <- readCreateProcess (proc "pass" ["show", label]) "" | ||
401 | void $ f pw | ||
402 | pwType :: String -> X () | ||
403 | pwType = withPw $ readCreateProcess (proc "xdotool" ["type", "--clearmodifiers", "--file", "-"]) | ||
404 | pwClip label = safeSpawn "pass" ["show", "--clip", label] | ||
405 | pwShow :: String -> X () | ||
406 | pwShow = withPw $ \pw -> do | ||
407 | xmessage <- fromMaybe "xmessage" <$> liftIO (lookupEnv "XMONAD_XMESSAGE") | ||
408 | readCreateProcess (proc xmessage ["-file", "-"]) pw | ||
409 | fuzzytime str = safeSpawn "fuzzytime" $ "timer" : words str | ||
410 | work_fuzzytime = io . void . forkProcess $ do | ||
411 | readCreateProcess (proc "worktime" []) "" >>= safeSpawn "fuzzytime" . ("timer" : ) . pure | ||
412 | adjmix str = safeSpawn "adjmix" $ words str | ||
413 | dc expr = void . xfork $ do | ||
414 | result <- readProcess "dc" [] $ expr ++ "f" | ||
415 | let | ||
416 | (first : rest) = filter (not . null) $ lines result | ||
417 | notification = Notify.summary first <> Notify.body (unlines rest) <> Notify.timeout Infinite <> Notify.urgency Normal <> Notify.appName "dc" | ||
418 | void $ Notify.display notification | ||
419 | synergyCompl = mkComplFunFromList' xPConfigMonospace ["mathw86"] | ||
420 | synergyStart host = safeSpawn "systemctl" ["--user", "start", "synergy-rtunnel@" ++ host ++ ".service"] | ||
421 | synergyStop host = safeSpawn "systemctl" ["--user", "stop", "synergy-rtunnel@" ++ host ++ ".service"] | ||
422 | |||
423 | hostFromName _ = defaultHost | ||
424 | |||
425 | -- muteRef :: IORef (Maybe (String, Notification)) | ||
426 | -- {-# NOINLINE muteRef #-} | ||
427 | -- muteRef = unsafePerformIO $ newIORef Nothing | ||
428 | |||
429 | -- startMute, stopMute :: String -> X () | ||
430 | -- startMute sink = liftIO $ do | ||
431 | -- muted <- isJust <$> readIORef muteRef | ||
432 | -- when (not muted) $ do | ||
433 | -- let | ||
434 | -- notification = Notify.summary "Muted" <> Notify.timeout Infinite <> Notify.urgency Normal | ||
435 | -- level = "0.0dB" | ||
436 | -- -- level <- runProcessWithInput "ssh" ["bragi", "cat", "/dev/shm/mix/" ++ sink ++ "/level"] "" | ||
437 | -- -- callProcess "ssh" ["bragi", "adjmix", "-t", sink, "-o", "0"] | ||
438 | -- hPutStrLn stderr "Mute" | ||
439 | -- writeIORef muteRef . Just . (level, ) =<< Notify.display notification | ||
440 | -- stopMute sink = liftIO $ do | ||
441 | -- let | ||
442 | -- unmute (Just (level, notification)) = do | ||
443 | -- hPutStrLn stderr "Unmute" | ||
444 | -- -- callProcess "ssh" ["bragi", "adjmix", "-t", sink, "-o", level] | ||
445 | -- Notify.close notification | ||
446 | -- unmute Nothing = return () | ||
447 | -- muted <- isJust <$> readIORef muteRef | ||
448 | -- when muted . join . atomicModifyIORef muteRef $ (Nothing, ) . unmute | ||
449 | |||
450 | wspFromMap workspaceNames = \i -> case Map.lookup i workspaceNames of | ||
451 | Just str -> show i ++ " " ++ str | ||
452 | Nothing -> show i | ||
453 | |||
454 | coWspFromMap workspaceNames = \str -> case filter ((== str) . snd) $ Map.toList workspaceNames of | ||
455 | [] -> Nothing | ||
456 | [(i, _)] -> Just $ wspFromMap workspaceNames i | ||
457 | _ -> Nothing | ||
458 | |||
459 | spawnModifiers = [0, controlMask, shiftMask .|. controlMask] | ||
460 | spawnBindings :: XConfig layout -> (KeySym, [X ()]) -> [((KeyMask, KeySym), X ())] | ||
461 | spawnBindings conf (k, cmds) = zipWith (\m cmd -> ((modm .|. mod1Mask .|. m, k), cmd)) spawnModifiers cmds | ||
462 | where | ||
463 | modm = XMonad.modMask conf | ||
464 | |||
465 | manageScratchTerm = (resource =? "scratchpad" <||> resource =? "keysetup") -?> doRectFloat $ RationalRect (1 % 16) (1 % 16) (7 % 8) (7 % 8) | ||
466 | |||
467 | tabbedLayout t = renamed [Replace "Tabbed"] $ reflectHoriz $ t CustomShrink $ tabbedTheme | ||
468 | tabbedLayoutHoriz t = renamed [Replace "Tabbed Horiz"] $ reflectVert $ t CustomShrink $ tabbedTheme | ||
469 | tabbedTheme = def | ||
470 | { activeColor = "black" | ||
471 | , inactiveColor = "black" | ||
472 | , urgentColor = "black" | ||
473 | , activeBorderColor = gray | ||
474 | , inactiveBorderColor = darkGray | ||
475 | , urgentBorderColor = red | ||
476 | , activeTextColor = gray | ||
477 | , inactiveTextColor = gray | ||
478 | , urgentTextColor = gray | ||
479 | , decoHeight = 32 | ||
480 | , fontName = "xft:Fira Sans:pixelsize=21" | ||
481 | } | ||
482 | |||
483 | main :: IO () | ||
484 | main = do | ||
485 | arguments <- either (const []) id <$> tryIOError getArgs | ||
486 | case arguments of | ||
487 | ["--command", s] -> do | ||
488 | d <- openDisplay "" | ||
489 | rw <- rootWindow d $ defaultScreen d | ||
490 | a <- internAtom d "XMONAD_COMMAND" False | ||
491 | m <- internAtom d s False | ||
492 | allocaXEvent $ \e -> do | ||
493 | setEventType e clientMessage | ||
494 | setClientMessageEvent e rw a 32 m currentTime | ||
495 | sendEvent d rw False structureNotifyMask e | ||
496 | sync d False | ||
497 | _ -> do | ||
498 | -- batteryMon <- xfork $ monitorBattery Nothing Nothing | ||
499 | hostname <- getHostName | ||
500 | let | ||
501 | host = hostFromName hostname | ||
502 | setEnv "HOST" hostname | ||
503 | let myConfig = withHostUrgency . ewmhFullscreen . ewmh . pagerHints $ docks def | ||
504 | { manageHook = hManageHook host | ||
505 | , terminal = "alacritty" | ||
506 | , layoutHook = smartBorders . avoidStruts $ windowNavigation layout' | ||
507 | , logHook = do | ||
508 | dynamicLogString xmobarPP' >>= writeProps | ||
509 | updatePointer (99 % 100, 98 % 100) (0, 0) | ||
510 | , modMask = mod4Mask | ||
511 | , keys = \conf -> hKeysMod host conf $ myKeys' conf host | ||
512 | , workspaces = take (length numKeys) $ map wsp [1..] | ||
513 | , startupHook = setDefaultCursor xC_left_ptr | ||
514 | , normalBorderColor = darkGray | ||
515 | , focusedBorderColor = gray | ||
516 | , handleEventHook = serverModeEventHookCmd' (hCmds host) <+> keyUpEventHook | ||
517 | } | ||
518 | writeProps str = do | ||
519 | let encodeCChar = map $ fromIntegral . fromEnum | ||
520 | atoms = [ "_XMONAD_WORKSPACES" | ||
521 | , "_XMONAD_LAYOUT" | ||
522 | , "_XMONAD_TITLE" | ||
523 | ] | ||
524 | (flip mapM_) (zip atoms (lines str)) $ \(atom', content) -> do | ||
525 | ustring <- getAtom "UTF8_STRING" | ||
526 | atom <- getAtom atom' | ||
527 | withDisplay $ \dpy -> io $ do | ||
528 | root <- rootWindow dpy $ defaultScreen dpy | ||
529 | changeProperty8 dpy root atom ustring propModeReplace $ encodeCChar content | ||
530 | sync dpy True | ||
531 | wsp = hWsp host | ||
532 | -- We can´t define per-host layout modifiers because we lack dependent types | ||
533 | layout' = onHost "skadhi" ( onWorkspace (wsp 1) (Full ||| withIM (1%5) (Title "Buddy List") tabbedLayout') $ | ||
534 | onWorkspace (wsp 10) Full $ | ||
535 | onWorkspace (wsp 2) (Full ||| tabbedLayout') $ | ||
536 | onWorkspace (wsp 5) tabbedLayout' $ | ||
537 | onWorkspace (wsp 8) (withIM (1%5) (Title "Friends") tabbedLayout') $ | ||
538 | defaultLayouts | ||
539 | ) $ | ||
540 | onHost "vali" ( onWorkspace (wsp 2) (Full ||| tabbedLayout' ||| combineTwo (TwoPane 0.01 0.57) Full tabbedLayout') $ | ||
541 | onWorkspace (wsp 3) workLayouts $ | ||
542 | defaultLayouts | ||
543 | ) $ | ||
544 | onHost "hel" ( onWorkspace (wsp 1) (withIM (1 % 8) (Title "Buddy List") $ trackFloating tabbedLayout') $ | ||
545 | onWorkspace (wsp 2) (tabbedLayout''' ||| Dwindle R CW 1 (5 % 100)) $ | ||
546 | onWorkspace (wsp 3) workLayouts $ | ||
547 | onWorkspace (wsp 6) workLayouts $ | ||
548 | onWorkspace (wsp 4) (tabbedLayout' ||| tabbedLayoutHoriz' ||| Dwindle R CW 1 (5 % 100)) $ | ||
549 | onWorkspace (wsp 5) (tabbedLayout''' ||| Dwindle R CW 1 (5 % 100)) $ | ||
550 | onWorkspace (wsp 10) (tabbedLayout''' ||| combineTwoP (TwoPane (1 % 100) (3 % 4)) tabbedLayout''' tabbedLayout''' (ClassName "mpv") ||| Dwindle R CW 1 (5 % 100)) $ | ||
551 | defaultLayouts | ||
552 | ) $ | ||
553 | onHost "sif" ( onWorkspace (wsp 1) (withIM (1 % 8) (Title "Buddy List") $ trackFloating tabbedLayout') $ | ||
554 | onWorkspace (wsp 2) (tabbedLayout''' ||| Dwindle R CW 1 (5 % 100)) $ | ||
555 | onWorkspace (wsp 3) workLayouts $ | ||
556 | onWorkspace (wsp 6) workLayouts $ | ||
557 | onWorkspace (wsp 4) (tabbedLayout' ||| tabbedLayoutHoriz' ||| Dwindle R CW 1 (5 % 100)) $ | ||
558 | onWorkspace (wsp 5) (tabbedLayout''' ||| Dwindle R CW 1 (5 % 100)) $ | ||
559 | onWorkspace (wsp 8) tabbedLayout''' $ | ||
560 | onWorkspace (wsp 10) (tabbedLayout''' ||| combineTwoP (TwoPane (1 % 100) (3 % 4)) tabbedLayout''' tabbedLayout''' (ClassName "mpv") ||| Dwindle R CW 1 (5 % 100)) $ | ||
561 | defaultLayouts | ||
562 | ) $ | ||
563 | defaultLayouts | ||
564 | -- tabbedLayout''' = renamed [Replace "Tabbed'"] $ IfMax 1 (noBorders Full) (tabbedLayout tabbedBottomAlways) | ||
565 | tabbedLayout''' = tabbedLayout tabbedBottom | ||
566 | tabbedLayout' = tabbedLayout tabbedBottomAlways | ||
567 | tabbedLayoutHoriz' = tabbedLayoutHoriz tabbedLeftAlways | ||
568 | defaultLayouts = {- spiralWithDir East CW (1 % 2) -} Dwindle R CW 1 (5 % 100) ||| tabbedLayout' ||| Full | ||
569 | -- workLayouts = {- spiralWithDir East CW (1 % 2) -} Dwindle R CW (2 % 1) (5 % 100) ||| tabbedLayout' ||| Full | ||
570 | workLayouts = tabbedLayout' ||| (renamed [Replace "Combined"] $ combineTwoP (TwoPane (1 % 100) (1891 % 2560)) tabbedLayout''' (Column 1.6) (ClassName "Postman" `Or` ClassName "Emacs" `Or` ClassName "jetbrains-idea-ce" `Or` (Resource "Devtools" `And` ClassName "Firefox"))) ||| Full ||| Dwindle R CW 1 (5 % 100) | ||
571 | sqrtTwo = approxRational (sqrt 2) (1 / 2560) | ||
572 | xmobarPP' = xmobarPP { ppTitle = shorten 80 | ||
573 | , ppSort = (liftM2 (.)) getSortByIndex $ return scratchpadFilterOutWorkspace | ||
574 | , ppUrgent = wrap "(" ")" . xmobarColor "#800000" "" | ||
575 | , ppHiddenNoWindows = xmobarColor "#202020" "" . wrap "(" ")" | ||
576 | , ppVisible = wrap "(" ")" . xmobarColor "#808000" "" | ||
577 | , ppCurrent = wrap "(" ")" . xmobarColor "#008000" "" | ||
578 | , ppHidden = wrap "(" ")" | ||
579 | , ppWsSep = " " | ||
580 | , ppSep = "\n" | ||
581 | } | ||
582 | withHostUrgency = case hostname of | ||
583 | "sif" -> withUrgencyHookC urgencyHook' $ def { suppressWhen = U.Never, remindWhen = Every 2 } | ||
584 | _ -> id | ||
585 | urgencyHook' window = do | ||
586 | let blinkLight = (lightHigh >> threadDelay 0.5e6) `finally` lightLow | ||
587 | where | ||
588 | lightHigh = | ||
589 | writeFile "/sys/class/leds/input0::capslock/brightness" =<< readFile "/sys/class/leds/input0::capslock/max_brightness" | ||
590 | lightLow = writeFile "/sys/class/leds/input0::capslock/brightness" "0" | ||
591 | runQuery ((resource =? "comm" <||> resource =? "Pidgin" <||> className =? "Gajim" <||> className =? "Skype" <||> className =? "Thunderbird") --> void (xfork blinkLight)) window | ||
592 | urgencyHook (BorderUrgencyHook { urgencyBorderColor = red }) window | ||
593 | shutdown :: SomeException -> IO a | ||
594 | shutdown e = do | ||
595 | let pids = [ -- batteryMon | ||
596 | ] | ||
597 | mapM_ (signalProcess sigTERM) pids | ||
598 | mapM_ (getProcessStatus False False) pids | ||
599 | throw e | ||
600 | keyUpEventHook :: Event -> X All | ||
601 | keyUpEventHook event = handle event >> return (All True) | ||
602 | where | ||
603 | handle (KeyEvent { ev_event_type = t, ev_state = m, ev_keycode = code }) | ||
604 | | t == keyRelease = withDisplay $ \dpy -> do | ||
605 | s <- io $ keycodeToKeysym dpy code 0 | ||
606 | mClean <- cleanMask m | ||
607 | ks <- asks $ hKeyUpKeys host . config | ||
608 | userCodeDef () $ whenJust (Map.lookup (mClean, s) ks) id | ||
609 | | otherwise = return () | ||
610 | handle _ = return () | ||
611 | handle shutdown $ launch myConfig =<< getDirectories | ||
612 | |||
613 | secs :: Int -> Int | ||
614 | secs = (* 1000000) | ||
615 | |||
616 | -- monitorBattery :: Maybe BatteryContext -> Maybe Notification -> IO () | ||
617 | -- monitorBattery Nothing n = do | ||
618 | -- ctx <- batteryContextNew | ||
619 | -- case ctx of | ||
620 | -- Nothing -> threadDelay (secs 10) >> monitorBattery Nothing n | ||
621 | -- Just _ -> monitorBattery ctx n | ||
622 | -- monitorBattery ctx@(Just ctx') n = do | ||
623 | -- batInfo <- getBatteryInfo ctx' | ||
624 | -- case batInfo of | ||
625 | -- Nothing -> threadDelay (secs 1) >> monitorBattery ctx n | ||
626 | -- Just batInfo -> do | ||
627 | -- let n' | ||
628 | -- | batteryState batInfo == BatteryStateDischarging | ||
629 | -- , timeLeft <= 1200 | ||
630 | -- , timeLeft > 0 = Just $ summary "Discharging" <> hint "value" percentage <> urgency u <> body (duz timeLeft ++ "left") | ||
631 | -- | otherwise = Nothing | ||
632 | -- u | ||
633 | -- | timeLeft <= 600 = Critical | ||
634 | -- | timeLeft <= 1800 = Normal | ||
635 | -- | otherwise = Low | ||
636 | -- timeLeft = batteryTimeToEmpty batInfo | ||
637 | -- percentage :: Int32 | ||
638 | -- percentage = round $ batteryPercentage batInfo | ||
639 | -- ts = [("s", 60), ("m", 60), ("h", 24), ("d", 365), ("y", 1)] | ||
640 | -- duz ms = ss | ||
641 | -- where (ss, _) = foldl (\(ss, x) (s, y) -> ((if rem x y > 0 then show (rem x y) ++ s ++ " " else "") ++ ss , quot x y)) ("", ms) ts | ||
642 | -- case n' of | ||
643 | -- Just n' -> Notify.display (maybe mempty reuse n <> Notify.appName "monitorBattery" <> n') >>= (\n -> threadDelay (secs 2) >> monitorBattery ctx (Just n)) | ||
644 | -- Nothing -> threadDelay (secs 30) >> monitorBattery ctx n | ||
645 | |||
646 | disableTouchpad, disableTrackpoint, enableTrackpoint, enableTouchpad :: X () | ||
647 | enableTouchpad = safeSpawn "xinput" ["enable", "SynPS/2 Synaptics TouchPad"] | ||
648 | disableTouchpad = safeSpawn "xinput" ["disable", "SynPS/2 Synaptics TouchPad"] | ||
649 | enableTrackpoint = safeSpawn "xinput" ["enable", "TPPS/2 IBM TrackPoint"] | ||
650 | disableTrackpoint = safeSpawn "xinput" ["disable", "TPPS/2 IBM TrackPoint"] | ||
651 | |||
652 | isDisabled :: String -> X Bool | ||
653 | isDisabled str = do | ||
654 | out <- runProcessWithInput "xinput" ["list", str] "" | ||
655 | return $ "disabled" `isInfixOf` out | ||
656 | |||
657 | |||
658 | spawnKeychain :: X () | ||
659 | spawnKeychain = do | ||
660 | home <- liftIO getHomeDirectory | ||
661 | let keys = (map ((home </>) . (".ssh/" ++)) ["id", "id-rsa"]) ++ ["6B13AA67"] | ||
662 | liftIO (maybe (return ()) (setEnv "SSH_ASKPASS") =<< findAskpass) | ||
663 | safeSpawn "keychain" . (["--agents", "gpg,ssh"] ++)=<< liftIO (filterM doesFileExist keys) | ||
664 | where | ||
665 | findAskpass = filter `liftM` readFile "/etc/zshrc" | ||
666 | filter = listToMaybe . catMaybes . map (stripPrefix "export SSH_ASKPASS=") . lines | ||
667 | |||
668 | assimilateKeychain :: X () | ||
669 | assimilateKeychain = liftIO $ assimilateKeychain' >> return () | ||
670 | assimilateKeychain' = tryIOError $ do | ||
671 | -- pid <- getProcessID | ||
672 | -- tmpDir <- lookupEnv "TMPDIR" | ||
673 | -- let tmpDir' = fromMaybe "/tmp" tmpDir | ||
674 | -- tmpFile = tmpDir' </> "xmonad-keychain" ++ (show pid) ++ ".env" | ||
675 | env <- runProcessWithInput "sh" ["-c", "eval $(keychain --eval --noask --agents gpg,ssh); env"] "" -- > " ++ tmpFile] "" | ||
676 | -- env <- readFile tmpFile | ||
677 | let envVars = Map.fromList $ map (\(k, v) -> (k, tail' v)) $ map (span (/= '=')) $ envLines | ||
678 | envVars' = Map.filterWithKey (\k _ -> k `elem` transfer) envVars | ||
679 | transfer = ["SSH_AUTH_SOCK", "SSH_AGENT_PID", "GPG_AGENT_INFO"] | ||
680 | envLines = filter (elem '=') $ lines env :: [String] | ||
681 | sequence $ map (\(k, c) -> setEnv k c) $ Map.toList envVars' | ||
682 | -- removeFile tmpFile | ||
683 | where | ||
684 | tail' [] = [] | ||
685 | tail' (x:xs) = xs | ||
686 | |||
687 | |||
688 | numKeys = [xK_parenleft, xK_parenright, xK_braceright, xK_plus, xK_braceleft, xK_bracketright, xK_bracketleft, xK_exclam, xK_equal, xK_asterisk] | ||
689 | |||
690 | instance Shrinker CustomShrink where | ||
691 | shrinkIt _ "" = [""] | ||
692 | shrinkIt s cs | ||
693 | | length cs >= 4 = cs : shrinkIt s ((reverse . drop 4 . reverse $ cs) ++ "...") | ||
694 | | otherwise = cs : shrinkIt s (init cs) | ||
695 | |||
696 | xPConfig, xPConfigMonospace :: XPConfig | ||
697 | xPConfig = def | ||
698 | { font = "xft:Fira Sans:pixelsize=21" | ||
699 | , height = 32 | ||
700 | , bgColor = "black" | ||
701 | , fgColor = gray | ||
702 | , fgHLight = green | ||
703 | , bgHLight = "black" | ||
704 | , borderColor = gray | ||
705 | , searchPredicate = (\needle haystack -> all (`isInfixOf` map toLower haystack) . map (map toLower) $ words needle) | ||
706 | , position = Top | ||
707 | } | ||
708 | xPConfigMonospace = xPConfig { font = "xft:Fira Code:pixelsize=21" } | ||
709 | |||
710 | sshOverrides host = map (\h -> mkOverride { oHost = h, oCommand = moshCmd . inTmux host} ) | ||
711 | [ "odin" | ||
712 | , "ymir" | ||
713 | , "surtr" | ||
714 | , "vidhar" | ||
715 | , "srv02.uniworx.de" | ||
716 | ] | ||
717 | ++ | ||
718 | map (\h -> mkOverride { oHost = h, oCommand = moshCmd' "/run/current-system/sw/bin/mosh-server" . withEnv [("TERM", "xterm")] . inTmux host} ) | ||
719 | [ "bragi", "bragi.asgard.yggdrasil" | ||
720 | ] | ||
721 | ++ | ||
722 | map (\h -> mkOverride { oHost = h, oCommand = sshCmd . inTmux host } ) | ||
723 | [ "uni2work-dev1", "srv01.uniworx.de" | ||
724 | ] | ||
725 | ++ | ||
726 | map (\h -> mkOverride { oHost = h, oCommand = sshCmd . withEnv [("TERM", "xterm")] . inTmux host } ) | ||
727 | [ "remote.cip.ifi.lmu.de" | ||
728 | , "uniworx3", "uniworx4", "uniworx5", "uniworxdb2" | ||
729 | , "testworx" | ||
730 | ] | ||
731 | |||
732 | backlight :: (Rational -> Rational) -> X () | ||
733 | backlight f = void . xfork . liftIO $ do | ||
734 | [ _device | ||
735 | , _class | ||
736 | , read . Text.unpack -> currentBright | ||
737 | , _currentPercentage | ||
738 | , read . Text.unpack -> maximumBright | ||
739 | ] <- Text.splitOn "," . Text.pack <$> readProcess "brightnessctl" ["-m"] "" | ||
740 | let current = currentBright % maximumBright | ||
741 | new' = f current * fromIntegral maximumBright | ||
742 | new :: Integer | ||
743 | new | floor new' < 0 = 0 | ||
744 | | ceiling new' > maximumBright = maximumBright | ||
745 | | new' >= maximumBright % 2 = ceiling new' | ||
746 | | otherwise = floor new' | ||
747 | callProcess "brightnessctl" ["-m", "s", show new] | ||
748 | |||
749 | cycleThrough :: [Rational] -> (Rational -> Rational) | ||
750 | cycleThrough opts current = fromMaybe currentOpt $ listToMaybe next' | ||
751 | where currentOpt = minimumBy (comparing $ abs . subtract current) opts | ||
752 | (_, _ : next') = break (== currentOpt) opts | ||
753 | |||
754 | cycleKbLayout :: [(String, Maybe String)] -> X () | ||
755 | cycleKbLayout [] = return () | ||
756 | cycleKbLayout layouts = liftIO $ do | ||
757 | next <- (getNext . extract) `liftM` runProcessWithInput "setxkbmap" ["-query"] "" | ||
758 | let | ||
759 | args = case next of | ||
760 | (l, Just v) -> [l, v] | ||
761 | (l, Nothing) -> [l] | ||
762 | safeSpawn "setxkbmap" args | ||
763 | where | ||
764 | extract :: String -> Maybe (String, Maybe String) | ||
765 | extract str = listToMaybe $ do | ||
766 | ["layout:", l] <- str' | ||
767 | [(l, Just v) | ["variant:", v] <- str'] ++ pure (l, Nothing) | ||
768 | where | ||
769 | str' = map words $ lines str | ||
770 | getNext :: Maybe (String, Maybe String) -> (String, Maybe String) | ||
771 | getNext = maybe (head layouts) getNext' | ||
772 | getNext' x = case elemIndex x layouts of | ||
773 | Nothing -> getNext Nothing | ||
774 | Just i -> layouts !! ((i + 1) `mod` length layouts) | ||
775 | |||
776 | mpvAll' :: MpvCommand -> IO [MpvResponse] | ||
777 | mpvAll' = mpvAll "/var/media/.mpv-ipc" | ||
778 | |||
779 | mpvOne' :: MpvCommand -> IO (Maybe MpvResponse) | ||
780 | mpvOne' = mpvOne "/var/media/.mpv-ipc" | ||
781 | |||
782 | mediaMpv :: MpvCommand -> X () | ||
783 | mediaMpv cmd = void . xfork $ print =<< mpvAll' cmd | ||
784 | |||
785 | mediaMpvTogglePause :: X () | ||
786 | mediaMpvTogglePause = void . xfork $ do | ||
787 | paused <- mapM mpvResponse <=< mpvAll' $ MpvGetProperty "pause" | ||
788 | if | ||
789 | | and paused -> print <=< mpvAll' $ MpvSetProperty "pause" False | ||
790 | | otherwise -> print <=< mpvOne' $ MpvSetProperty "pause" True | ||
791 | |||
792 | myKeys' conf host = Map.fromList $ | ||
793 | -- launch a terminal | ||
794 | [ ((modm, xK_Return), spawn $ (XMonad.terminal conf) ++ " -e tmux") | ||
795 | , ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) | ||
796 | |||
797 | -- launch dmenu | ||
798 | --, ((modm, xK_d ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"") | ||
799 | , ((modm, xK_d ), shellPrompt "Run: " xPConfigMonospace) | ||
800 | , ((modm .|. shiftMask, xK_d ), prompt "Run in Terminal: " ("alacritty" ++ " -e") xPConfigMonospace) | ||
801 | , ((modm, xK_at ), sshPrompt (sshOverrides . Just $ hName host) xPConfigMonospace) | ||
802 | |||
803 | -- close focused window | ||
804 | , ((modm .|. shiftMask, xK_q ), kill) | ||
805 | , ((modm .|. controlMask .|. shiftMask, xK_q ), spawn "xkill") | ||
806 | |||
807 | -- Rotate through the available layout algorithms | ||
808 | , ((modm, xK_space ), sendMessage NextLayout) | ||
809 | |||
810 | -- Reset the layouts on the current workspace to default | ||
811 | , ((modm .|. controlMask, xK_r ), (setLayout $ XMonad.layoutHook conf) >> refresh) | ||
812 | |||
813 | -- Resize viewed windows to the correct size | ||
814 | , ((modm, xK_r ), refresh) | ||
815 | |||
816 | -- Move focus to the next window | ||
817 | , ((modm, xK_t ), windows W.focusDown) | ||
818 | |||
819 | -- Move focus to the previous window | ||
820 | , ((modm, xK_n ), windows W.focusUp ) | ||
821 | |||
822 | -- Move focus to the master window | ||
823 | , ((modm, xK_m ), windows W.focusMaster ) | ||
824 | |||
825 | -- Swap the focused window and the master window | ||
826 | , ((modm .|. shiftMask, xK_m ), windows W.swapMaster) | ||
827 | |||
828 | -- Swap the focused window with the next window | ||
829 | , ((modm .|. shiftMask, xK_t ), windows W.swapDown ) | ||
830 | |||
831 | -- Swap the focused window with the previous window | ||
832 | , ((modm .|. shiftMask, xK_n ), windows W.swapUp ) | ||
833 | |||
834 | -- Swap the focused window with the previous window | ||
835 | , ((modm .|. shiftMask .|. controlMask, xK_m), sendMessage SwapWindow) | ||
836 | |||
837 | , ((modm, xK_Right), sendMessage $ Go R) | ||
838 | , ((modm, xK_Left ), sendMessage $ Go L) | ||
839 | , ((modm, xK_Up ), sendMessage $ Go U) | ||
840 | , ((modm, xK_Down ), sendMessage $ Go D) | ||
841 | , ((modm .|. shiftMask , xK_Right), sendMessage $ Move R) | ||
842 | , ((modm .|. shiftMask , xK_Left ), sendMessage $ Move L) | ||
843 | , ((modm .|. shiftMask , xK_Up ), sendMessage $ Move U) | ||
844 | , ((modm .|. shiftMask , xK_Down ), sendMessage $ Move D) | ||
845 | -- , ((modm .|. controlMask, xK_Right), withFocused $ keysMoveWindow (10, 0)) | ||
846 | -- , ((modm .|. controlMask, xK_Left ), withFocused $ keysMoveWindow (-10, 0)) | ||
847 | -- , ((modm .|. controlMask, xK_Up ), withFocused $ keysMoveWindow (0, -10)) | ||
848 | -- , ((modm .|. controlMask, xK_Down ), withFocused $ keysMoveWindow (0, 10)) | ||
849 | -- Shrink the master area | ||
850 | , ((modm, xK_h ), sendMessage Shrink) | ||
851 | |||
852 | -- Expand the master area | ||
853 | , ((modm, xK_s ), sendMessage Expand) | ||
854 | |||
855 | -- Push window back into tiling | ||
856 | , ((modm .|. shiftMask, xK_space ), withFocused $ windows . W.sink) | ||
857 | , ((modm, xK_BackSpace), focusUrgent) | ||
858 | , ((modm .|. shiftMask, xK_BackSpace), clearUrgents) | ||
859 | |||
860 | -- Increment the number of windows in the master area | ||
861 | , ((modm , xK_comma ), sendMessage (IncMasterN 1)) | ||
862 | |||
863 | -- Deincrement the number of windows in the master area | ||
864 | , ((modm , xK_period), sendMessage (IncMasterN (-1))) | ||
865 | |||
866 | , ((0, xF86XK_AudioRaiseVolume), safeSpawn "pamixer" ["-i", "2"]) | ||
867 | , ((0, xF86XK_AudioLowerVolume), safeSpawn "pamixer" ["-d", "2"]) | ||
868 | , ((0, xF86XK_AudioMute), safeSpawn "pamixer" ["-t"]) | ||
869 | , ((0, xF86XK_AudioPause), mediaMpv $ MpvSetProperty "pause" False) | ||
870 | , ((0, {-xF86XK_AudioMicMute-} 269025202), safeSpawn "pulseaudio-ctl" ["mute-input"]) | ||
871 | , ((0, xF86XK_AudioPlay), mediaMpvTogglePause) | ||
872 | , ((0, xK_Print), do | ||
873 | home <- liftIO getHomeDirectory | ||
874 | unGrab | ||
875 | safeSpawn "scrot" ["-s", "-F", home </> "screenshots" </> "%Y-%m-%dT%H:%M:%S.png", "-e", "xclip -selection clipboard -t image/png -i $f"] | ||
876 | ) | ||
877 | , ((modm .|. mod1Mask, xK_space), mediaMpvTogglePause) | ||
878 | |||
879 | -- , ((0, xF86XK_MonBrightnessDown), backlight . cycleThrough $ reverse brCycle) | ||
880 | -- , ((0, xF86XK_MonBrightnessUp ), backlight $ cycleThrough brCycle) | ||
881 | , ((modm .|. shiftMask , xK_b), backlight . cycleThrough $ reverse brCycle) | ||
882 | , ((modm .|. shiftMask .|. controlMask, xK_b), backlight $ cycleThrough brCycle) | ||
883 | |||
884 | , ((modm , xK_Escape), cycleKbLayout (hKbLayouts host)) | ||
885 | , ((modm .|. controlMask, xK_Escape), safeSpawn "setxkbmap" $ fst (head $ hKbLayouts host) : maybeToList (snd . head $ hKbLayouts host)) | ||
886 | |||
887 | -- Toggle the status bar gap | ||
888 | -- Use this binding with avoidStruts from Hooks.ManageDocks. | ||
889 | -- See also the statusBar function from Hooks.DynamicLog. | ||
890 | -- | ||
891 | , ((modm , xK_b ), sendMessage ToggleStruts) | ||
892 | |||
893 | , ((modm .|. shiftMask, xK_p ), safeSpawn "playerctl" ["-a", "pause"]) | ||
894 | |||
895 | -- Quit xmonad | ||
896 | , ((modm .|. shiftMask, xK_e ), io (exitWith ExitSuccess)) | ||
897 | |||
898 | -- Restart xmonad | ||
899 | -- , ((modm .|. shiftMask .|. controlMask, xK_r ), void . xfork $ recompile False >>= flip when (safeSpawn "xmonad" ["--restart"])) | ||
900 | , ((modm .|. shiftMask, xK_r ), void . liftIO $ executeFile "xmonad" True [] Nothing) | ||
901 | , ((modm .|. shiftMask, xK_l ), void . xfork $ do | ||
902 | sessId <- getEnv "XDG_SESSION_ID" | ||
903 | safeSpawn "loginctl" ["lock-session", sessId] | ||
904 | ) | ||
905 | , ((modm .|. shiftMask, xK_s ), safeSpawn "systemctl" ["suspend"]) | ||
906 | , ((modm .|. shiftMask, xK_h ), inputPromptWithCompl xPConfigMonospace "systemctl" powerActCompl ?+ powerAct) | ||
907 | , ((modm, xK_v ), windows copyToAll) -- @@ Make focused window always visible | ||
908 | , ((modm .|. shiftMask, xK_v ), killAllOtherCopies) -- @@ Toggle window state back | ||
909 | , ((modm .|. shiftMask, xK_g ), windowPrompt xPConfig Goto wsWindows) | ||
910 | , ((modm , xK_g ), windowPrompt xPConfig Bring allWindows) | ||
911 | ] | ||
912 | ++ | ||
913 | |||
914 | -- | ||
915 | -- mod-[1..9], Switch to workspace N | ||
916 | -- | ||
917 | -- mod-[1..9], Switch to workspace N | ||
918 | -- mod-shift-[1..9], Move client to workspace N | ||
919 | -- | ||
920 | [((m .|. modm, k), windows $ f i) | ||
921 | | (i, k) <- zip (XMonad.workspaces conf) $ numKeys | ||
922 | , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)] | ||
923 | ] | ||
924 | ++ | ||
925 | [((m .|. modm .|. controlMask, k), void . runMaybeT $ | ||
926 | MaybeT (P.getScreen def i) >>= MaybeT . screenWorkspace >>= lift . windows . f | ||
927 | ) | ||
928 | | (i, k) <- zip (hScreens host) [xK_g, xK_c, xK_r, xK_l] | ||
929 | , (f, m) <- [(W.view, 0), (W.shift, shiftMask)] | ||
930 | ] | ||
931 | where | ||
932 | modm = XMonad.modMask conf | ||
933 | |||
934 | brCycle = [0, 1 % 500, 1 % 250, 1 % 100, 1 % 10, 1 % 4, 1 % 2, 3 % 4, 1] | ||
935 | |||
936 | powerActWords = ["poweroff", "reboot", "hibernate", "suspend"] | ||
937 | powerActCompl = mkComplFunFromList' xPConfigMonospace powerActWords | ||
938 | powerAct act | act `elem` powerActWords = safeSpawn "systemctl" $ pure act | ||
939 | | otherwise = return () | ||
@@ -322,11 +322,11 @@ | |||
322 | ] | 322 | ] |
323 | }, | 323 | }, |
324 | "locked": { | 324 | "locked": { |
325 | "lastModified": 1736014120, | 325 | "lastModified": 1738691953, |
326 | "narHash": "sha256-ZrI+mcuQfal5IfT4HsxVEiiFNAgV4qYh+B4/NyXxpAs=", | 326 | "narHash": "sha256-JY/w2Xyrj3mhUhLJkSgk8t7MSf3LGZjewPTQ7QtCbHE=", |
327 | "owner": "gkleen", | 327 | "owner": "gkleen", |
328 | "repo": "home-manager", | 328 | "repo": "home-manager", |
329 | "rev": "99e8412a18eb7e0731aa2b77abeed00d6d1863ad", | 329 | "rev": "c077fc8684289ab1b1c2231bab1566879e099c97", |
330 | "type": "github" | 330 | "type": "github" |
331 | }, | 331 | }, |
332 | "original": { | 332 | "original": { |
@@ -359,11 +359,11 @@ | |||
359 | }, | 359 | }, |
360 | "impermanence": { | 360 | "impermanence": { |
361 | "locked": { | 361 | "locked": { |
362 | "lastModified": 1734945620, | 362 | "lastModified": 1737831083, |
363 | "narHash": "sha256-olIfsfJK4/GFmPH8mXMmBDAkzVQ1TWJmeGT3wBGfQPY=", | 363 | "narHash": "sha256-LJggUHbpyeDvNagTUrdhe/pRVp4pnS6wVKALS782gRI=", |
364 | "owner": "nix-community", | 364 | "owner": "nix-community", |
365 | "repo": "impermanence", | 365 | "repo": "impermanence", |
366 | "rev": "d000479f4f41390ff7cf9204979660ad5dd16176", | 366 | "rev": "4b3e914cdf97a5b536a889e939fb2fd2b043a170", |
367 | "type": "github" | 367 | "type": "github" |
368 | }, | 368 | }, |
369 | "original": { | 369 | "original": { |
@@ -385,6 +385,65 @@ | |||
385 | "url": "https://data.iana.org/time-zones/tzdb/leap-seconds.list" | 385 | "url": "https://data.iana.org/time-zones/tzdb/leap-seconds.list" |
386 | } | 386 | } |
387 | }, | 387 | }, |
388 | "niri-flake": { | ||
389 | "inputs": { | ||
390 | "niri-stable": "niri-stable", | ||
391 | "niri-unstable": "niri-unstable", | ||
392 | "nixpkgs": [ | ||
393 | "nixpkgs" | ||
394 | ], | ||
395 | "nixpkgs-stable": "nixpkgs-stable_2", | ||
396 | "xwayland-satellite-stable": "xwayland-satellite-stable", | ||
397 | "xwayland-satellite-unstable": "xwayland-satellite-unstable" | ||
398 | }, | ||
399 | "locked": { | ||
400 | "lastModified": 1739339370, | ||
401 | "narHash": "sha256-kvuVhsaVa8j0P9Genf96CLX2cNjForojX5aB1BN+Bwk=", | ||
402 | "owner": "sodiboo", | ||
403 | "repo": "niri-flake", | ||
404 | "rev": "498e8bbc149b38fd14d4ff7fbf31c49fdaa23282", | ||
405 | "type": "github" | ||
406 | }, | ||
407 | "original": { | ||
408 | "owner": "sodiboo", | ||
409 | "ref": "main", | ||
410 | "repo": "niri-flake", | ||
411 | "type": "github" | ||
412 | } | ||
413 | }, | ||
414 | "niri-stable": { | ||
415 | "flake": false, | ||
416 | "locked": { | ||
417 | "lastModified": 1736614405, | ||
418 | "narHash": "sha256-AJ1rlgNOPb3/+DbS5hkhm21t6Oz8IgqLllwmZt0lyzk=", | ||
419 | "owner": "YaLTeR", | ||
420 | "repo": "niri", | ||
421 | "rev": "e05bc269e678ecf828b96ae79c991c13b00b38a5", | ||
422 | "type": "github" | ||
423 | }, | ||
424 | "original": { | ||
425 | "owner": "YaLTeR", | ||
426 | "ref": "v25.01", | ||
427 | "repo": "niri", | ||
428 | "type": "github" | ||
429 | } | ||
430 | }, | ||
431 | "niri-unstable": { | ||
432 | "flake": false, | ||
433 | "locked": { | ||
434 | "lastModified": 1739336386, | ||
435 | "narHash": "sha256-H9E3lfJibzWwqV9C1pI81uhav1RLWRA8JbH3ADv3X/4=", | ||
436 | "owner": "YaLTeR", | ||
437 | "repo": "niri", | ||
438 | "rev": "7e552333a993e83a2dba52392109617e486f5f60", | ||
439 | "type": "github" | ||
440 | }, | ||
441 | "original": { | ||
442 | "owner": "YaLTeR", | ||
443 | "repo": "niri", | ||
444 | "type": "github" | ||
445 | } | ||
446 | }, | ||
388 | "nix-github-actions": { | 447 | "nix-github-actions": { |
389 | "inputs": { | 448 | "inputs": { |
390 | "nixpkgs": [ | 449 | "nixpkgs": [ |
@@ -413,11 +472,11 @@ | |||
413 | ] | 472 | ] |
414 | }, | 473 | }, |
415 | "locked": { | 474 | "locked": { |
416 | "lastModified": 1735443188, | 475 | "lastModified": 1739071773, |
417 | "narHash": "sha256-AydPpRBh8+NOkrLylG7vTsHrGO2b5L7XkMEL5HlzcA8=", | 476 | "narHash": "sha256-/Ak+Quinhmdxa9m3shjm4lwwwqmzG8zzGhhhhgR1k9I=", |
418 | "owner": "Mic92", | 477 | "owner": "Mic92", |
419 | "repo": "nix-index-database", | 478 | "repo": "nix-index-database", |
420 | "rev": "55ab1e1df5daf2476e6b826b69a82862dcbd7544", | 479 | "rev": "895d81b6228bbd50a6ef22f5a58a504ca99763ea", |
421 | "type": "github" | 480 | "type": "github" |
422 | }, | 481 | }, |
423 | "original": { | 482 | "original": { |
@@ -434,11 +493,11 @@ | |||
434 | ] | 493 | ] |
435 | }, | 494 | }, |
436 | "locked": { | 495 | "locked": { |
437 | "lastModified": 1735412232, | 496 | "lastModified": 1739078428, |
438 | "narHash": "sha256-W9wRlNvQLfV21359gTr3DglRBA6Q7NPUSU4RzgAAGsk=", | 497 | "narHash": "sha256-9Q8lxL99vaTtK/myj+I6vQvzt3uJiCpazq0jovQswGs=", |
439 | "owner": "AshleyYakeley", | 498 | "owner": "AshleyYakeley", |
440 | "repo": "NixVirt", | 499 | "repo": "NixVirt", |
441 | "rev": "55367360c00bd304042e5ad90841fd399330b77a", | 500 | "rev": "f2e4e9ad0b02bbd80c509b63d27a2f11359c16a8", |
442 | "type": "github" | 501 | "type": "github" |
443 | }, | 502 | }, |
444 | "original": { | 503 | "original": { |
@@ -449,11 +508,11 @@ | |||
449 | }, | 508 | }, |
450 | "nixos-hardware": { | 509 | "nixos-hardware": { |
451 | "locked": { | 510 | "locked": { |
452 | "lastModified": 1735388221, | 511 | "lastModified": 1738816619, |
453 | "narHash": "sha256-e5IOgjQf0SZcFCEV/gMGrsI0gCJyqOKShBQU0iiM3Kg=", | 512 | "narHash": "sha256-5yRlg48XmpcX5b5HesdGMOte+YuCy9rzQkJz+imcu6I=", |
454 | "owner": "NixOS", | 513 | "owner": "NixOS", |
455 | "repo": "nixos-hardware", | 514 | "repo": "nixos-hardware", |
456 | "rev": "7c674c6734f61157e321db595dbfcd8523e04e19", | 515 | "rev": "2eccff41bab80839b1d25b303b53d339fbb07087", |
457 | "type": "github" | 516 | "type": "github" |
458 | }, | 517 | }, |
459 | "original": { | 518 | "original": { |
@@ -571,6 +630,22 @@ | |||
571 | }, | 630 | }, |
572 | "nixpkgs-stable_2": { | 631 | "nixpkgs-stable_2": { |
573 | "locked": { | 632 | "locked": { |
633 | "lastModified": 1739206421, | ||
634 | "narHash": "sha256-PwQASeL2cGVmrtQYlrBur0U20Xy07uSWVnFup2PHnDs=", | ||
635 | "owner": "NixOS", | ||
636 | "repo": "nixpkgs", | ||
637 | "rev": "44534bc021b85c8d78e465021e21f33b856e2540", | ||
638 | "type": "github" | ||
639 | }, | ||
640 | "original": { | ||
641 | "owner": "NixOS", | ||
642 | "ref": "nixos-24.11", | ||
643 | "repo": "nixpkgs", | ||
644 | "type": "github" | ||
645 | } | ||
646 | }, | ||
647 | "nixpkgs-stable_3": { | ||
648 | "locked": { | ||
574 | "lastModified": 1717179513, | 649 | "lastModified": 1717179513, |
575 | "narHash": "sha256-vboIEwIQojofItm2xGCdZCzW96U85l9nDW3ifMuAIdM=", | 650 | "narHash": "sha256-vboIEwIQojofItm2xGCdZCzW96U85l9nDW3ifMuAIdM=", |
576 | "owner": "NixOS", | 651 | "owner": "NixOS", |
@@ -585,7 +660,7 @@ | |||
585 | "type": "github" | 660 | "type": "github" |
586 | } | 661 | } |
587 | }, | 662 | }, |
588 | "nixpkgs-stable_3": { | 663 | "nixpkgs-stable_4": { |
589 | "locked": { | 664 | "locked": { |
590 | "lastModified": 1678872516, | 665 | "lastModified": 1678872516, |
591 | "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", | 666 | "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", |
@@ -603,16 +678,16 @@ | |||
603 | }, | 678 | }, |
604 | "nixpkgs_2": { | 679 | "nixpkgs_2": { |
605 | "locked": { | 680 | "locked": { |
606 | "lastModified": 1736167739, | 681 | "lastModified": 1739214665, |
607 | "narHash": "sha256-IWir2Srf07xHsdf9WnLtaqPgL+CfS6tiZ9N/I+qbneE=", | 682 | "narHash": "sha256-26L8VAu3/1YRxS8MHgBOyOM8xALdo6N0I04PgorE7UM=", |
608 | "owner": "gkleen", | 683 | "owner": "NixOS", |
609 | "repo": "nixpkgs", | 684 | "repo": "nixpkgs", |
610 | "rev": "a89c52fb11e656bbef04452a29eb0cd6cb6272c0", | 685 | "rev": "64e75cd44acf21c7933d61d7721e812eac1b5a0a", |
611 | "type": "github" | 686 | "type": "github" |
612 | }, | 687 | }, |
613 | "original": { | 688 | "original": { |
614 | "owner": "gkleen", | 689 | "owner": "NixOS", |
615 | "ref": "fix/matrix-synapse", | 690 | "ref": "nixos-unstable", |
616 | "repo": "nixpkgs", | 691 | "repo": "nixpkgs", |
617 | "type": "github" | 692 | "type": "github" |
618 | } | 693 | } |
@@ -673,11 +748,11 @@ | |||
673 | "treefmt-nix": "treefmt-nix" | 748 | "treefmt-nix": "treefmt-nix" |
674 | }, | 749 | }, |
675 | "locked": { | 750 | "locked": { |
676 | "lastModified": 1735852239, | 751 | "lastModified": 1738741221, |
677 | "narHash": "sha256-Xrg/HahR9SW1UzT5pwtpQR6D12ZIwwHjxav9YzB1q4U=", | 752 | "narHash": "sha256-UiTOA89yQV5YNlO1ZAp4IqJUGWOnTyBC83netvt8rQE=", |
678 | "owner": "nix-community", | 753 | "owner": "nix-community", |
679 | "repo": "poetry2nix", | 754 | "repo": "poetry2nix", |
680 | "rev": "bb182fd661f5f8a7d6c50dd44cf9a6ddca7ccc1a", | 755 | "rev": "be1fe795035d3d36359ca9135b26dcc5321b31fb", |
681 | "type": "github" | 756 | "type": "github" |
682 | }, | 757 | }, |
683 | "original": { | 758 | "original": { |
@@ -741,7 +816,7 @@ | |||
741 | "flake-utils": "flake-utils_2", | 816 | "flake-utils": "flake-utils_2", |
742 | "gitignore": "gitignore_3", | 817 | "gitignore": "gitignore_3", |
743 | "nixpkgs": "nixpkgs_3", | 818 | "nixpkgs": "nixpkgs_3", |
744 | "nixpkgs-stable": "nixpkgs-stable_3" | 819 | "nixpkgs-stable": "nixpkgs-stable_4" |
745 | }, | 820 | }, |
746 | "locked": { | 821 | "locked": { |
747 | "lastModified": 1685361114, | 822 | "lastModified": 1685361114, |
@@ -794,13 +869,14 @@ | |||
794 | "home-manager": "home-manager", | 869 | "home-manager": "home-manager", |
795 | "home-manager-eostre": "home-manager-eostre", | 870 | "home-manager-eostre": "home-manager-eostre", |
796 | "impermanence": "impermanence", | 871 | "impermanence": "impermanence", |
872 | "niri-flake": "niri-flake", | ||
797 | "nix-index-database": "nix-index-database", | 873 | "nix-index-database": "nix-index-database", |
798 | "nixVirt": "nixVirt", | 874 | "nixVirt": "nixVirt", |
799 | "nixos-hardware": "nixos-hardware", | 875 | "nixos-hardware": "nixos-hardware", |
800 | "nixpkgs": "nixpkgs_2", | 876 | "nixpkgs": "nixpkgs_2", |
801 | "nixpkgs-eostre": "nixpkgs-eostre", | 877 | "nixpkgs-eostre": "nixpkgs-eostre", |
802 | "nixpkgs-pgbackrest": "nixpkgs-pgbackrest", | 878 | "nixpkgs-pgbackrest": "nixpkgs-pgbackrest", |
803 | "nixpkgs-stable": "nixpkgs-stable_2", | 879 | "nixpkgs-stable": "nixpkgs-stable_3", |
804 | "nvfetcher": "nvfetcher", | 880 | "nvfetcher": "nvfetcher", |
805 | "poetry2nix": "poetry2nix", | 881 | "poetry2nix": "poetry2nix", |
806 | "prometheus-borg-exporter": "prometheus-borg-exporter", | 882 | "prometheus-borg-exporter": "prometheus-borg-exporter", |
@@ -815,11 +891,11 @@ | |||
815 | ] | 891 | ] |
816 | }, | 892 | }, |
817 | "locked": { | 893 | "locked": { |
818 | "lastModified": 1735844895, | 894 | "lastModified": 1739262228, |
819 | "narHash": "sha256-CIRlqX9tBK2awJkmVu2cKuap/0QziDXStQZ/u/+e8Z4=", | 895 | "narHash": "sha256-7JAGezJ0Dn5qIyA2+T4Dt/xQgAbhCglh6lzCekTVMeU=", |
820 | "owner": "Mic92", | 896 | "owner": "Mic92", |
821 | "repo": "sops-nix", | 897 | "repo": "sops-nix", |
822 | "rev": "24d89184adf76d7ccc99e659dc5f3838efb5ee32", | 898 | "rev": "07af005bb7d60c7f118d9d9f5530485da5d1e975", |
823 | "type": "github" | 899 | "type": "github" |
824 | }, | 900 | }, |
825 | "original": { | 901 | "original": { |
@@ -854,8 +930,9 @@ | |||
854 | "type": "github" | 930 | "type": "github" |
855 | }, | 931 | }, |
856 | "original": { | 932 | "original": { |
857 | "id": "systems", | 933 | "owner": "nix-systems", |
858 | "type": "indirect" | 934 | "repo": "default", |
935 | "type": "github" | ||
859 | } | 936 | } |
860 | }, | 937 | }, |
861 | "treefmt-nix": { | 938 | "treefmt-nix": { |
@@ -889,19 +966,52 @@ | |||
889 | ] | 966 | ] |
890 | }, | 967 | }, |
891 | "locked": { | 968 | "locked": { |
892 | "lastModified": 1734278650, | 969 | "lastModified": 1737014022, |
893 | "narHash": "sha256-z9FiyHDbKC2nwfd/qsHCxLBEogzQj73zo85lW3zIlzY=", | 970 | "narHash": "sha256-5cG3lbjvrqvotI3oEPham3jGq8Fd96NfrqCGvC1e6Qw=", |
894 | "owner": "gkleen", | 971 | "owner": "gkleen", |
895 | "repo": "Waybar", | 972 | "repo": "Waybar", |
896 | "rev": "5432f9c1697a8d2d3e1264a5ce820d7eac26e2c6", | 973 | "rev": "83765e0f8e99a7d344eae511a4090a76a27e5791", |
897 | "type": "github" | 974 | "type": "github" |
898 | }, | 975 | }, |
899 | "original": { | 976 | "original": { |
900 | "owner": "gkleen", | 977 | "owner": "gkleen", |
901 | "ref": "feat/privacy-ignore", | 978 | "ref": "feat/niri-workspaces-hide", |
902 | "repo": "Waybar", | 979 | "repo": "Waybar", |
903 | "type": "github" | 980 | "type": "github" |
904 | } | 981 | } |
982 | }, | ||
983 | "xwayland-satellite-stable": { | ||
984 | "flake": false, | ||
985 | "locked": { | ||
986 | "lastModified": 1730166465, | ||
987 | "narHash": "sha256-nq7bouXQXaaPPo/E+Jbq+wNHnatD4dY8OxSrRqzvy6s=", | ||
988 | "owner": "Supreeeme", | ||
989 | "repo": "xwayland-satellite", | ||
990 | "rev": "a713cf46cb7db84a0d1b57c3a397c610cad3cf98", | ||
991 | "type": "github" | ||
992 | }, | ||
993 | "original": { | ||
994 | "owner": "Supreeeme", | ||
995 | "ref": "v0.5", | ||
996 | "repo": "xwayland-satellite", | ||
997 | "type": "github" | ||
998 | } | ||
999 | }, | ||
1000 | "xwayland-satellite-unstable": { | ||
1001 | "flake": false, | ||
1002 | "locked": { | ||
1003 | "lastModified": 1739246919, | ||
1004 | "narHash": "sha256-/hBM43/Gd0/tW+egrhlWgOIISeJxEs2uAOIYVpfDKeU=", | ||
1005 | "owner": "Supreeeme", | ||
1006 | "repo": "xwayland-satellite", | ||
1007 | "rev": "44590a416d4a3e8220e19e29e0b6efe64a80315d", | ||
1008 | "type": "github" | ||
1009 | }, | ||
1010 | "original": { | ||
1011 | "owner": "Supreeeme", | ||
1012 | "repo": "xwayland-satellite", | ||
1013 | "type": "github" | ||
1014 | } | ||
905 | } | 1015 | } |
906 | }, | 1016 | }, |
907 | "root": "root", | 1017 | "root": "root", |
@@ -4,20 +4,20 @@ | |||
4 | nixConfig = { | 4 | nixConfig = { |
5 | extra-substituters = [ | 5 | extra-substituters = [ |
6 | "https://nix-community.cachix.org" | 6 | "https://nix-community.cachix.org" |
7 | "https://niri.cachix.org" | ||
7 | ]; | 8 | ]; |
8 | extra-trusted-public-keys = [ | 9 | extra-trusted-public-keys = [ |
9 | "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" | 10 | "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" |
11 | "niri.cachix.org-1:Wv0OmO7PsuocRKzfDoJ3mulSl7Z6oezYhGhR+3W2964=" | ||
10 | ]; | 12 | ]; |
11 | }; | 13 | }; |
12 | 14 | ||
13 | inputs = { | 15 | inputs = { |
14 | nixpkgs = { | 16 | nixpkgs = { |
15 | type = "github"; | 17 | type = "github"; |
16 | # owner = "NixOS"; | 18 | owner = "NixOS"; |
17 | repo = "nixpkgs"; | 19 | repo = "nixpkgs"; |
18 | # ref = "nixos-unstable"; | 20 | ref = "nixos-unstable"; |
19 | owner = "gkleen"; | ||
20 | ref = "fix/matrix-synapse"; | ||
21 | }; | 21 | }; |
22 | nixpkgs-pgbackrest = { | 22 | nixpkgs-pgbackrest = { |
23 | type = "github"; | 23 | type = "github"; |
@@ -172,7 +172,7 @@ | |||
172 | type = "github"; | 172 | type = "github"; |
173 | owner = "gkleen"; | 173 | owner = "gkleen"; |
174 | repo = "Waybar"; | 174 | repo = "Waybar"; |
175 | ref = "feat/privacy-ignore"; | 175 | ref = "feat/niri-workspaces-hide"; |
176 | inputs = { | 176 | inputs = { |
177 | nixpkgs.follows = "nixpkgs"; | 177 | nixpkgs.follows = "nixpkgs"; |
178 | flake-compat.follows = "flake-compat"; | 178 | flake-compat.follows = "flake-compat"; |
@@ -184,9 +184,19 @@ | |||
184 | repo = "NixVirt"; | 184 | repo = "NixVirt"; |
185 | inputs.nixpkgs.follows = "nixpkgs"; | 185 | inputs.nixpkgs.follows = "nixpkgs"; |
186 | }; | 186 | }; |
187 | niri-flake = { | ||
188 | type = "github"; | ||
189 | owner = "sodiboo"; | ||
190 | repo = "niri-flake"; | ||
191 | ref = "main"; | ||
192 | inputs = { | ||
193 | nixpkgs.follows = "nixpkgs"; | ||
194 | # niri-unstable.url = "github:gkleen/niri"; | ||
195 | }; | ||
196 | }; | ||
187 | }; | 197 | }; |
188 | 198 | ||
189 | outputs = { self, nixpkgs, home-manager, sops-nix, deploy-rs, nvfetcher, ... }@inputs: | 199 | outputs = { self, nixpkgs, home-manager, sops-nix, deploy-rs, nvfetcher, niri-flake, ... }@inputs: |
190 | let | 200 | let |
191 | inherit (builtins) attrNames attrValues elemAt toJSON isNull pathExists; | 201 | inherit (builtins) attrNames attrValues elemAt toJSON isNull pathExists; |
192 | inherit (nixpkgs) lib; | 202 | inherit (nixpkgs) lib; |
@@ -269,9 +279,10 @@ | |||
269 | mkAccountModule = dir: path: accountName: | 279 | mkAccountModule = dir: path: accountName: |
270 | let | 280 | let |
271 | userName = accountUserName accountName; | 281 | userName = accountUserName accountName; |
282 | hostName = accountHostName accountName; | ||
272 | in overrideModule | 283 | in overrideModule |
273 | (import (dir + "/${path}")) | 284 | (import (dir + "/${path}")) |
274 | (inputs: inputs // { inherit userName; }) | 285 | (inputs: inputs // { inherit userName hostName; }) |
275 | (outputs: { _file = dir + "/${path}"; } | 286 | (outputs: { _file = dir + "/${path}"; } |
276 | // outputs | 287 | // outputs |
277 | // { imports = [self.nixosModules.users.${userName} or ({...}: { imports = defaultUserProfiles userName; })] ++ (outputs.imports or []); }); | 288 | // { imports = [self.nixosModules.users.${userName} or ({...}: { imports = defaultUserProfiles userName; })] ++ (outputs.imports or []); }); |
@@ -324,7 +335,7 @@ | |||
324 | nixosConfigurations = installerNixosConfigurations // nixImport rec { dir = ./hosts; _import = mkNixosConfiguration [] dir; }; | 335 | nixosConfigurations = installerNixosConfigurations // nixImport rec { dir = ./hosts; _import = mkNixosConfiguration [] dir; }; |
325 | 336 | ||
326 | homeModules = nixImport rec { dir = ./home-modules; }; | 337 | homeModules = nixImport rec { dir = ./home-modules; }; |
327 | homeConfigurations = listToAttrs (concatLists (mapAttrsToList (hostname: nixosConfig: mapAttrsToList (username: configuration: nameValuePair "${username}@${hostname}" { inherit (configuration.home) activationPackage; }) nixosConfig.config.home-manager.users) self.nixosConfigurations)); | 338 | homeConfigurations = listToAttrs (concatLists (mapAttrsToList (hostname: nixosConfig: mapAttrsToList (username: nameValuePair "${username}@${hostname}") nixosConfig.config.home-manager.users) self.nixosConfigurations)); |
328 | 339 | ||
329 | overlays = mapAttrs (_name: path: mkOverlay path) overlayPaths; | 340 | overlays = mapAttrs (_name: path: mkOverlay path) overlayPaths; |
330 | 341 | ||
diff --git a/hosts/sif/default.nix b/hosts/sif/default.nix index 088e1022..2a3a6be9 100644 --- a/hosts/sif/default.nix +++ b/hosts/sif/default.nix | |||
@@ -12,9 +12,8 @@ let | |||
12 | in { | 12 | in { |
13 | imports = with flake.nixosModules.systemProfiles; [ | 13 | imports = with flake.nixosModules.systemProfiles; [ |
14 | ./hw.nix | 14 | ./hw.nix |
15 | ./mail ./libvirt | 15 | ./mail ./libvirt ./greetd |
16 | tmpfs-root bcachefs initrd-all-crypto-modules default-locale openssh rebuild-machines | 16 | tmpfs-root bcachefs initrd-all-crypto-modules default-locale openssh rebuild-machines niri-unstable networkmanager |
17 | networkmanager | ||
18 | flakeInputs.nixos-hardware.nixosModules.lenovo-thinkpad-p1 | 17 | flakeInputs.nixos-hardware.nixosModules.lenovo-thinkpad-p1 |
19 | flakeInputs.impermanence.nixosModules.impermanence | 18 | flakeInputs.impermanence.nixosModules.impermanence |
20 | flakeInputs.nixVirt.nixosModules.default | 19 | flakeInputs.nixVirt.nixosModules.default |
@@ -27,6 +26,9 @@ in { | |||
27 | allowUnfree = true; | 26 | allowUnfree = true; |
28 | pulseaudio = true; | 27 | pulseaudio = true; |
29 | }; | 28 | }; |
29 | extraOverlays = [ | ||
30 | flakeInputs.niri-flake.overlays.niri | ||
31 | ]; | ||
30 | }; | 32 | }; |
31 | 33 | ||
32 | time.timeZone = null; | 34 | time.timeZone = null; |
@@ -61,15 +63,20 @@ in { | |||
61 | plymouth.enable = true; | 63 | plymouth.enable = true; |
62 | 64 | ||
63 | kernelPackages = pkgs.linuxPackages_latest; | 65 | kernelPackages = pkgs.linuxPackages_latest; |
64 | extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ]; | ||
65 | kernelModules = ["v4l2loopback"]; | ||
66 | kernelPatches = [ | 66 | kernelPatches = [ |
67 | { name = "edac-config"; | 67 | { name = "edac-config"; |
68 | patch = null; | 68 | patch = null; |
69 | extraConfig = '' | 69 | extraStructuredConfig = with lib.kernel; { |
70 | EDAC y | 70 | EDAC = yes; |
71 | EDAC_IE31200 y | 71 | EDAC_IE31200 = yes; |
72 | ''; | 72 | }; |
73 | } | ||
74 | { name = "zswap-default"; | ||
75 | patch = null; | ||
76 | extraStructuredConfig = with lib.kernel; { | ||
77 | ZSWAP_DEFAULT_ON = yes; | ||
78 | ZSWAP_SHRINKER_DEFAULT_ON = yes; | ||
79 | }; | ||
73 | } | 80 | } |
74 | ]; | 81 | ]; |
75 | 82 | ||
@@ -438,7 +445,7 @@ in { | |||
438 | }; | 445 | }; |
439 | 446 | ||
440 | xserver = { | 447 | xserver = { |
441 | enable = true; | 448 | enable = false; |
442 | 449 | ||
443 | xkb = { | 450 | xkb = { |
444 | layout = "us"; | 451 | layout = "us"; |
@@ -464,47 +471,16 @@ in { | |||
464 | }; | 471 | }; |
465 | libinput.enable = true; | 472 | libinput.enable = true; |
466 | 473 | ||
467 | greetd = { | 474 | envfs.enable = false; |
468 | enable = true; | ||
469 | # settings.default_session.command = let | ||
470 | # cfg = config.programs.regreet; | ||
471 | # in pkgs.writeShellScript "greeter" '' | ||
472 | # modprobe -r nvidia_drm | ||
473 | |||
474 | # exec ${pkgs.dbus}/bin/dbus-run-session ${lib.getExe pkgs.cage} ${lib.escapeShellArgs cfg.cageArgs} -- ${lib.getExe cfg.package} | ||
475 | # ''; | ||
476 | }; | ||
477 | }; | ||
478 | |||
479 | programs.regreet = { | ||
480 | enable = true; | ||
481 | theme = { | ||
482 | package = pkgs.equilux-theme; | ||
483 | name = "Equilux-compact"; | ||
484 | }; | ||
485 | iconTheme = { | ||
486 | package = pkgs.paper-icon-theme; | ||
487 | name = "Paper-Mono-Dark"; | ||
488 | }; | ||
489 | font = { | ||
490 | package = pkgs.fira; | ||
491 | name = "Fira Sans"; | ||
492 | # size = 6; | ||
493 | }; | ||
494 | cageArgs = [ "-s" "-m" "last" ]; | ||
495 | settings = { | ||
496 | GTK.application_prefer_dark_theme = true; | ||
497 | }; | ||
498 | }; | 475 | }; |
499 | programs.hyprland.enable = true; | ||
500 | 476 | ||
501 | systemd.tmpfiles.settings = { | 477 | systemd.tmpfiles.settings = { |
502 | "10-localtime"."/etc/localtime".L.argument = "/.bcachefs/etc/localtime"; | 478 | "10-localtime"."/etc/localtime".L.argument = "/.bcachefs/etc/localtime"; |
503 | 479 | ||
504 | "10-regreet"."/var/cache/regreet/cache.toml".C.argument = toString ((pkgs.formats.toml {}).generate "cache.toml" { | 480 | # "10-regreet"."/var/cache/regreet/cache.toml".C.argument = toString ((pkgs.formats.toml {}).generate "cache.toml" { |
505 | last_user = "gkleen"; | 481 | # last_user = "gkleen"; |
506 | user_to_last_sess.gkleen = "Hyprland"; | 482 | # user_to_last_sess.gkleen = "Niri"; |
507 | }); | 483 | # }); |
508 | }; | 484 | }; |
509 | 485 | ||
510 | users = { | 486 | users = { |
@@ -613,15 +589,15 @@ in { | |||
613 | }; | 589 | }; |
614 | 590 | ||
615 | nvidia = { | 591 | nvidia = { |
616 | open = true; | 592 | open = false; |
617 | modesetting.enable = true; | 593 | modesetting.enable = true; |
618 | powerManagement.enable = true; | 594 | powerManagement.enable = true; |
619 | prime = { | 595 | # prime = { |
620 | nvidiaBusId = "PCI:1:0:0"; | 596 | # nvidiaBusId = "PCI:1:0:0"; |
621 | intelBusId = "PCI:0:2:0"; | 597 | # intelBusId = "PCI:0:2:0"; |
622 | reverseSync.enable = true; | 598 | # reverseSync.enable = true; |
623 | offload.enableOffloadCmd = true; | 599 | # offload.enableOffloadCmd = true; |
624 | }; | 600 | # }; |
625 | }; | 601 | }; |
626 | 602 | ||
627 | graphics = { | 603 | graphics = { |
@@ -695,6 +671,7 @@ in { | |||
695 | 671 | ||
696 | services.dbus.packages = with pkgs; | 672 | services.dbus.packages = with pkgs; |
697 | [ dbus dconf | 673 | [ dbus dconf |
674 | xdg-desktop-portal-gtk | ||
698 | ]; | 675 | ]; |
699 | 676 | ||
700 | services.udisks2.enable = true; | 677 | services.udisks2.enable = true; |
@@ -703,12 +680,8 @@ in { | |||
703 | light.enable = true; | 680 | light.enable = true; |
704 | wireshark.enable = true; | 681 | wireshark.enable = true; |
705 | dconf.enable = true; | 682 | dconf.enable = true; |
706 | }; | 683 | niri.enable = true; |
707 | 684 | fuse.userAllowOther = true; | |
708 | zramSwap = { | ||
709 | enable = true; | ||
710 | algorithm = "zstd"; | ||
711 | writebackDevice = "/dev/disk/by-label/swap"; | ||
712 | }; | 685 | }; |
713 | 686 | ||
714 | services.pcscd.enable = true; | 687 | services.pcscd.enable = true; |
@@ -728,6 +701,16 @@ in { | |||
728 | environment.sessionVariables."GTK_USE_PORTAL" = "1"; | 701 | environment.sessionVariables."GTK_USE_PORTAL" = "1"; |
729 | xdg.portal = { | 702 | xdg.portal = { |
730 | enable = true; | 703 | enable = true; |
704 | extraPortals = with pkgs; [ xdg-desktop-portal-gtk ]; | ||
705 | config.niri = { | ||
706 | default = ["gnome" "gtk"]; | ||
707 | "org.freedesktop.impl.portal.FileChooser" = ["gtk"]; | ||
708 | "org.freedesktop.impl.portal.OpenFile" = ["gtk"]; | ||
709 | "org.freedesktop.impl.portal.Access" = ["gtk"]; | ||
710 | "org.freedesktop.impl.portal.Notification" = ["gtk"]; | ||
711 | "org.freedesktop.impl.portal.Secret" = ["gnome-keyring"]; | ||
712 | "org.freedesktop.impl.portal.Inhibit" = ["none"]; | ||
713 | }; | ||
731 | }; | 714 | }; |
732 | 715 | ||
733 | environment.persistence."/.bcachefs" = { | 716 | environment.persistence."/.bcachefs" = { |
@@ -735,11 +718,11 @@ in { | |||
735 | directories = [ | 718 | directories = [ |
736 | "/nix" | 719 | "/nix" |
737 | "/root" | 720 | "/root" |
721 | "/home" | ||
738 | "/var/log" | 722 | "/var/log" |
739 | "/var/lib/sops-nix" | 723 | "/var/lib/sops-nix" |
740 | "/var/lib/nixos" | 724 | "/var/lib/nixos" |
741 | "/var/lib/systemd" | 725 | "/var/lib/systemd" |
742 | "/home" | ||
743 | "/var/lib/chrony" | 726 | "/var/lib/chrony" |
744 | "/var/lib/fprint" | 727 | "/var/lib/fprint" |
745 | "/var/lib/bluetooth" | 728 | "/var/lib/bluetooth" |
@@ -768,6 +751,10 @@ in { | |||
768 | 751 | ||
769 | home-manager.sharedModules = [ flakeInputs.nixVirt.homeModules.default ]; | 752 | home-manager.sharedModules = [ flakeInputs.nixVirt.homeModules.default ]; |
770 | 753 | ||
754 | environment.pathsToLink = [ | ||
755 | "share/zsh" | ||
756 | ]; | ||
757 | |||
771 | system.stateVersion = "24.11"; | 758 | system.stateVersion = "24.11"; |
772 | }; | 759 | }; |
773 | } | 760 | } |
diff --git a/hosts/sif/greetd/default.nix b/hosts/sif/greetd/default.nix new file mode 100644 index 00000000..37ca13c5 --- /dev/null +++ b/hosts/sif/greetd/default.nix | |||
@@ -0,0 +1,49 @@ | |||
1 | { pkgs, ... }: | ||
2 | { | ||
3 | config = { | ||
4 | services.greetd = { | ||
5 | enable = true; | ||
6 | # settings.default_session.command = let | ||
7 | # cfg = config.programs.regreet; | ||
8 | # in pkgs.writeShellScript "greeter" '' | ||
9 | # modprobe -r nvidia_drm | ||
10 | |||
11 | # exec ${pkgs.dbus}/bin/dbus-run-session ${lib.getExe pkgs.cage} ${lib.escapeShellArgs cfg.cageArgs} -- ${lib.getExe cfg.package} | ||
12 | # ''; | ||
13 | }; | ||
14 | systemd.services.greetd.environment = { | ||
15 | XKB_DEFAULT_LAYOUT = "us,us"; | ||
16 | XKB_DEFAULT_VARIANT = "dvp,"; | ||
17 | XKB_DEFAULT_OPTIONS = "compose:caps,grp:win_space_toggle"; | ||
18 | }; | ||
19 | programs.regreet = { | ||
20 | enable = true; | ||
21 | theme = { | ||
22 | package = pkgs.equilux-theme; | ||
23 | name = "Equilux-compact"; | ||
24 | }; | ||
25 | iconTheme = { | ||
26 | package = pkgs.paper-icon-theme; | ||
27 | name = "Paper-Mono-Dark"; | ||
28 | }; | ||
29 | font = { | ||
30 | package = pkgs.fira; | ||
31 | name = "Fira Sans"; | ||
32 | # size = 6; | ||
33 | }; | ||
34 | cageArgs = [ "-s" "-m" "last" ]; | ||
35 | settings = { | ||
36 | GTK.application_prefer_dark_theme = true; | ||
37 | widget.clock.format = "%F %H:%M:%S%:z"; | ||
38 | background = { | ||
39 | path = pkgs.runCommand "wallpaper.png" { | ||
40 | buildInputs = with pkgs; [ imagemagick ]; | ||
41 | } '' | ||
42 | magick ${./wallpaper.png} -filter Gaussian -resize 6.25% -define filter:sigma=2.5 -resize 1600% "$out" | ||
43 | ''; | ||
44 | fit = "Cover"; | ||
45 | }; | ||
46 | }; | ||
47 | }; | ||
48 | }; | ||
49 | } | ||
diff --git a/hosts/sif/greetd/wallpaper.png b/hosts/sif/greetd/wallpaper.png new file mode 100644 index 00000000..20fc761a --- /dev/null +++ b/hosts/sif/greetd/wallpaper.png | |||
Binary files differ | |||
diff --git a/hosts/sif/hw.nix b/hosts/sif/hw.nix index d1fb2934..1bcf0261 100644 --- a/hosts/sif/hw.nix +++ b/hosts/sif/hw.nix | |||
@@ -19,6 +19,9 @@ | |||
19 | "/var/lib/sops-nix".neededForBoot = true; | 19 | "/var/lib/sops-nix".neededForBoot = true; |
20 | "/var/lib/systemd".neededForBoot = true; | 20 | "/var/lib/systemd".neededForBoot = true; |
21 | }; | 21 | }; |
22 | swapDevices = [ | ||
23 | { label = "swap"; } | ||
24 | ]; | ||
22 | # system.etc.overlay.enable = false; | 25 | # system.etc.overlay.enable = false; |
23 | 26 | ||
24 | boot.initrd.systemd.packages = [ | 27 | boot.initrd.systemd.packages = [ |
diff --git a/hosts/sif/libvirt/default.nix b/hosts/sif/libvirt/default.nix index d0be7dff..9712d0d9 100644 --- a/hosts/sif/libvirt/default.nix +++ b/hosts/sif/libvirt/default.nix | |||
@@ -8,6 +8,7 @@ with flakeInputs.nixVirt.lib; | |||
8 | qemu.swtpm.enable = true; | 8 | qemu.swtpm.enable = true; |
9 | allowedBridges = ["virbr0" "rz-0971" "rz-2403"]; | 9 | allowedBridges = ["virbr0" "rz-0971" "rz-2403"]; |
10 | }; | 10 | }; |
11 | virtualisation.spiceUSBRedirection.enable = true; | ||
11 | virtualisation.libvirt = { | 12 | virtualisation.libvirt = { |
12 | enable = true; | 13 | enable = true; |
13 | swtpm.enable = true; | 14 | swtpm.enable = true; |
diff --git a/hosts/sif/mail/default.nix b/hosts/sif/mail/default.nix index f36cd599..8d6cd705 100644 --- a/hosts/sif/mail/default.nix +++ b/hosts/sif/mail/default.nix | |||
@@ -1,4 +1,4 @@ | |||
1 | { config, pkgs, ... }: | 1 | { config, lib, pkgs, ... }: |
2 | { | 2 | { |
3 | services.postfix = { | 3 | services.postfix = { |
4 | enable = true; | 4 | enable = true; |
diff --git a/hosts/surtr/default.nix b/hosts/surtr/default.nix index b8a639d5..3bbd51a4 100644 --- a/hosts/surtr/default.nix +++ b/hosts/surtr/default.nix | |||
@@ -7,6 +7,7 @@ with lib; | |||
7 | tmpfs-root qemu-guest openssh rebuild-machines zfs | 7 | tmpfs-root qemu-guest openssh rebuild-machines zfs |
8 | ./zfs.nix ./dns ./tls ./http ./bifrost ./matrix ./postgresql | 8 | ./zfs.nix ./dns ./tls ./http ./bifrost ./matrix ./postgresql |
9 | ./prometheus ./email ./vpn ./borg.nix ./etebase ./immich.nix | 9 | ./prometheus ./email ./vpn ./borg.nix ./etebase ./immich.nix |
10 | ./paperless.nix ./hledger.nix | ||
10 | ]; | 11 | ]; |
11 | 12 | ||
12 | config = { | 13 | config = { |
diff --git a/hosts/surtr/dns/Gupfile b/hosts/surtr/dns/Gupfile index ac96f620..70674cce 100644 --- a/hosts/surtr/dns/Gupfile +++ b/hosts/surtr/dns/Gupfile | |||
@@ -1,2 +1,2 @@ | |||
1 | key.gup: | 1 | key.gup: |
2 | keys/*.yaml \ No newline at end of file | 2 | keys/* \ No newline at end of file |
diff --git a/hosts/surtr/dns/default.nix b/hosts/surtr/dns/default.nix index ee1d089d..5dd60190 100644 --- a/hosts/surtr/dns/default.nix +++ b/hosts/surtr/dns/default.nix | |||
@@ -157,7 +157,7 @@ in { | |||
157 | ${concatMapStringsSep "\n" mkZone [ | 157 | ${concatMapStringsSep "\n" mkZone [ |
158 | { domain = "yggdrasil.li"; | 158 | { domain = "yggdrasil.li"; |
159 | addACLs = { "yggdrasil.li" = ["ymir_acme_acl"]; }; | 159 | addACLs = { "yggdrasil.li" = ["ymir_acme_acl"]; }; |
160 | acmeDomains = ["surtr.yggdrasil.li" "yggdrasil.li" "etesync.yggdrasil.li" "immich.yggdrasil.li" "app.etesync.yggdrasil.li"]; | 160 | acmeDomains = ["surtr.yggdrasil.li" "yggdrasil.li" "etesync.yggdrasil.li" "immich.yggdrasil.li" "app.etesync.yggdrasil.li" "paperless.yggdrasil.li" "hledger.yggdrasil.li"]; |
161 | } | 161 | } |
162 | { domain = "nights.email"; | 162 | { domain = "nights.email"; |
163 | addACLs = { "nights.email" = ["ymir_acme_acl"]; }; | 163 | addACLs = { "nights.email" = ["ymir_acme_acl"]; }; |
diff --git a/hosts/surtr/dns/key.gup b/hosts/surtr/dns/key.gup index 32d4f7d6..5b5058b3 100644 --- a/hosts/surtr/dns/key.gup +++ b/hosts/surtr/dns/key.gup | |||
@@ -3,4 +3,4 @@ | |||
3 | keyName=${${2:t}%.yaml}_key | 3 | keyName=${${2:t}%.yaml}_key |
4 | 4 | ||
5 | keymgr -t ${keyName} > $1 | 5 | keymgr -t ${keyName} > $1 |
6 | sops -p '7ED22F4AA7BB55728B643DC5471B7D88E4EF66F8,30D3453B8CD02FE2A3E7C78C0FB536FB87AE8F51' --input-type=binary --output-type=binary -e -i $1 \ No newline at end of file | 6 | sops --input-type=binary --output-type=binary -e -i $1 |
diff --git a/hosts/surtr/dns/keys/hledger.yggdrasil.li_acme b/hosts/surtr/dns/keys/hledger.yggdrasil.li_acme new file mode 100644 index 00000000..b3f4cfb6 --- /dev/null +++ b/hosts/surtr/dns/keys/hledger.yggdrasil.li_acme | |||
@@ -0,0 +1,24 @@ | |||
1 | { | ||
2 | "data": "ENC[AES256_GCM,data:lCj8VYJL9z29FJ154XQtxKQLwwitCRGy4krJ6u8yw2FMzoHprEpFgm33+mFspxSKk/It2G8cfTGMZSeVkYJEHb66HNKHl0A2Fz3hwjpRjh1MZAw0wiZJlnS/LNqoGstQ2PJmTQTW3aJRMoT1GS7q/gSp/3rqySA5EOm0GgUiA3Vi7nGpkBenKDEbQbcIBXRdMOk66BCdiz5XGm/1VLQQLO9oVwY2KBnLaZSISohyGVhbIy7GT2ygoWHHxHn0c5CRVNvGNwesM1gO1NnTFrISLMWSrsDPaAtQ,iv:fa8LFjzqsf2ccfbEe5MOmerb7FzXb4xr24y1GWIMT1Q=,tag:7oQ54DKBb76Pbw1lmEHt+Q==,type:str]", | ||
3 | "sops": { | ||
4 | "kms": null, | ||
5 | "gcp_kms": null, | ||
6 | "azure_kv": null, | ||
7 | "hc_vault": null, | ||
8 | "age": [ | ||
9 | { | ||
10 | "recipient": "age1rmmhetcmllq0ahl5qznlr0eya2zdxwl9h6y5wnl97d2wtyx5t99sm2u866", | ||
11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBzcHJLRHh0VkpDNDU3cGZS\nMWFlVWpFemZ2RnpnSllDWU1EWGoyWUxyejNzClBGandzaFI5NXY1bG51Y3VxRk9r\nc29NbXBOaEZDblBuaVowemQydkxBdjgKLS0tICtVb2xkMmh4T0Q0cU4xQnBzZExI\namFRUnRYTWIyQ3RHNUVHWTFrUzhhK1UKqmATNmxlhkxM5PP1U6w7fSYVA8AgIRAt\nJ9WZrTffQfXMdw4RmjWcoVHFH39Fe4SteedxliCCcqjkjgSEB4Rgow==\n-----END AGE ENCRYPTED FILE-----\n" | ||
12 | }, | ||
13 | { | ||
14 | "recipient": "age19a7j77w267z04zls7m28a8hj4a0g5af6ltye2d5wypg33c3l89csd4r9zq", | ||
15 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBjWlhpQWI4c0x0ZXRGYVE2\nR1dHZzZud0ZxQWsrREhJWUowWE1zem5FVFI0CkJBUnIwY1FGS3N2VnpuSkZjRllZ\ncVgyeVg4cTVjRitzL0RKb0ZQb3BsOEkKLS0tIGs3SDBkamVBNDhQUlh5dmVVZXJs\nM3VKdlFKc21GcFY0UUtiaHFvYWI4V0kKKuWYEncxe9NT2ZS3X3+l/gT4BQOrdCg8\nj2jGL+Yzy/356GO3PFTn2HHLam6KWDKaYB5TlK/zSohfUt5giQH2Lw==\n-----END AGE ENCRYPTED FILE-----\n" | ||
16 | } | ||
17 | ], | ||
18 | "lastmodified": "2025-02-19T17:13:51Z", | ||
19 | "mac": "ENC[AES256_GCM,data:XsBdMCBjB+YuBMZQrjJ5uZtaYKSqsdWVvm+IEoJflCKPIhPk2rBZ3nY8KngXFbq2fWgsYyTM83kb2trEGIEHUPuERt+mgfCI3bSlylriwgsDWihCjyBecNE+BbdXE0+YcNl8pIwBU4M+3f2StQMH22YamToLJ9i9kfKcBrirDuU=,iv:VTIdBVY3kVBMYWhYUmrP2vZ9rpH90DzF68y1aDf2EAs=,tag:YkL+nw6LNXAceZtx9vgf6A==,type:str]", | ||
20 | "pgp": null, | ||
21 | "unencrypted_suffix": "_unencrypted", | ||
22 | "version": "3.9.4" | ||
23 | } | ||
24 | } \ No newline at end of file | ||
diff --git a/hosts/surtr/dns/keys/paperless.yggdrasil.li_acme b/hosts/surtr/dns/keys/paperless.yggdrasil.li_acme new file mode 100644 index 00000000..bc4640db --- /dev/null +++ b/hosts/surtr/dns/keys/paperless.yggdrasil.li_acme | |||
@@ -0,0 +1,24 @@ | |||
1 | { | ||
2 | "data": "ENC[AES256_GCM,data:wOl8KLHD0H+btq0A3UreyVF9bOXZsiTwWJkVH8GubyIQDyiDC8vQm+dfv0rz8TwcBWYpC4aMIPPflG2HsdYO4rKGQ/nBmWmxhNXjpnyRo8iKM1BGb5bxNe4eVcUVhI60NuRJDRLmtDp+0rYGT/MVYp0/mHBINsQCXWBPDoaN2PI2GSnRag/x0wcL27xgH6NDd8glcdCN5nCAPDvazA3LialkXXv7/cceA5Q/Ee6HGzPP0w212/UvBm07Z5tXnHiy5cTbAGTUBfIqC8n501jtaQhpMh/yzA1R8KwUrw==,iv:bLzsthCaanNikNS2Es4J1++E5lijEbjyW5hU4zzNBcg=,tag:eWfZ3AtcSAGv8jWXzqlAwQ==,type:str]", | ||
3 | "sops": { | ||
4 | "kms": null, | ||
5 | "gcp_kms": null, | ||
6 | "azure_kv": null, | ||
7 | "hc_vault": null, | ||
8 | "age": [ | ||
9 | { | ||
10 | "recipient": "age1rmmhetcmllq0ahl5qznlr0eya2zdxwl9h6y5wnl97d2wtyx5t99sm2u866", | ||
11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBNYWZKOHd2UmxWYVlIamk4\nZ04zQnAwcDdsSDBDWUZnekNva3BzRERyWXljCmNvUU1Fczc2aUN6VGl6NEJ6MGIx\nWHVpeVluWnRnbjNadGxkSmYyNE1rZzQKLS0tIGpkYVZQRDJGS21ZZHdlRk1MMm02\nQ09aanNXSWltNi9QeUNtUVQ2UEZybmMK6/qcNYLMcyKTmtROX+ZsRqDxMXwkXiAV\ndsdsWJ5+zSJuK5SEIh0fqEZ/t4pxnMcr1WieETgLSd+w0sNQS7EKPQ==\n-----END AGE ENCRYPTED FILE-----\n" | ||
12 | }, | ||
13 | { | ||
14 | "recipient": "age19a7j77w267z04zls7m28a8hj4a0g5af6ltye2d5wypg33c3l89csd4r9zq", | ||
15 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSByRjdJOHdjamRHVjlZOTNV\nbTBuam5vNERIWTB6T0JkR2pLUnlQN1BGbUJNClhrZ2hPRWZtT3BERFNwdmNEMmVu\nT0dxcjNkNGIvMVJQWENoUmRhTGd6SXcKLS0tIDV6WDd1bks4K1VuVkgybjdMd0w0\nMHBsT3FmOWU0WnJsM2diQm1sTU1ON2MKtf5HZ0S1cLMx98vDKRKamS7aHIJZ0OnA\nzH4VoeVm+PKsOeqVfY+gMHLdaMEWLKYsz3B8bxIoL5pvnCdT1QAN2A==\n-----END AGE ENCRYPTED FILE-----\n" | ||
16 | } | ||
17 | ], | ||
18 | "lastmodified": "2025-02-13T19:23:42Z", | ||
19 | "mac": "ENC[AES256_GCM,data:o7zNTjkohzAouYpJUGqf8DUfYf4/g3GZgc+4cf+PjI0OF8uc1WDCPvliBFe6pf/8QMhV5DFWd2SfszWnpnQhtiIVG/2BEk5sw3P6r/SUbSErakFYHueVQKp+9rdxK6uKcHUYhO46E332AwIxTuvNeHtSBMxx0kAwQPuuD/u3L4A=,iv:aiM0sGyGMk5lfBOpB2bDFCY+UfWwyUNixieww6eOSLs=,tag:MI7xJ7RsyZgQfF1SBVVmcQ==,type:str]", | ||
20 | "pgp": null, | ||
21 | "unencrypted_suffix": "_unencrypted", | ||
22 | "version": "3.9.4" | ||
23 | } | ||
24 | } \ No newline at end of file | ||
diff --git a/hosts/surtr/dns/zones/li.141.soa b/hosts/surtr/dns/zones/li.141.soa index d42b4719..ab117f09 100644 --- a/hosts/surtr/dns/zones/li.141.soa +++ b/hosts/surtr/dns/zones/li.141.soa | |||
@@ -1,7 +1,7 @@ | |||
1 | $ORIGIN 141.li. | 1 | $ORIGIN 141.li. |
2 | $TTL 3600 | 2 | $TTL 3600 |
3 | @ IN SOA ns.yggdrasil.li. hostmaster.yggdrasil.li ( | 3 | @ IN SOA ns.yggdrasil.li. hostmaster.yggdrasil.li ( |
4 | 2024102100 ; serial | 4 | 2025020900 ; serial |
5 | 10800 ; refresh | 5 | 10800 ; refresh |
6 | 3600 ; retry | 6 | 3600 ; retry |
7 | 604800 ; expire | 7 | 604800 ; expire |
@@ -59,5 +59,3 @@ _infinoted._tcp IN SRV 5 0 6523 ymir.yggdrasil.li. | |||
59 | _submission._tcp IN SRV 5 0 25 ymir.yggdrasil.li. | 59 | _submission._tcp IN SRV 5 0 25 ymir.yggdrasil.li. |
60 | _imap._tcp IN SRV 5 0 143 ymir.yggdrasil.li. | 60 | _imap._tcp IN SRV 5 0 143 ymir.yggdrasil.li. |
61 | _imaps._tcp IN SRV 5 0 993 ymir.yggdrasil.li. | 61 | _imaps._tcp IN SRV 5 0 993 ymir.yggdrasil.li. |
62 | |||
63 | _factorio._udp IN SRV 5 0 34197 game01.yggdrasil.li. | ||
diff --git a/hosts/surtr/dns/zones/li.yggdrasil.soa b/hosts/surtr/dns/zones/li.yggdrasil.soa index 9af6232f..2ef120e6 100644 --- a/hosts/surtr/dns/zones/li.yggdrasil.soa +++ b/hosts/surtr/dns/zones/li.yggdrasil.soa | |||
@@ -1,7 +1,7 @@ | |||
1 | $ORIGIN yggdrasil.li. | 1 | $ORIGIN yggdrasil.li. |
2 | $TTL 3600 | 2 | $TTL 3600 |
3 | @ IN SOA ns.yggdrasil.li. hostmaster.yggdrasil.li ( | 3 | @ IN SOA ns.yggdrasil.li. hostmaster.yggdrasil.li ( |
4 | 2025010300 ; serial | 4 | 2025021901 ; serial |
5 | 10800 ; refresh | 5 | 10800 ; refresh |
6 | 3600 ; retry | 6 | 3600 ; retry |
7 | 604800 ; expire | 7 | 604800 ; expire |
@@ -77,6 +77,22 @@ _acme-challenge.immich IN NS ns.yggdrasil.li. | |||
77 | 77 | ||
78 | immich IN HTTPS 1 . alpn="h2,h3" ipv4hint="202.61.241.61" ipv6hint="2a03:4000:52:ada::" | 78 | immich IN HTTPS 1 . alpn="h2,h3" ipv4hint="202.61.241.61" ipv6hint="2a03:4000:52:ada::" |
79 | 79 | ||
80 | paperless IN A 202.61.241.61 | ||
81 | paperless IN AAAA 2a03:4000:52:ada:: | ||
82 | paperless IN MX 0 surtr.yggdrasil.li | ||
83 | paperless IN TXT "v=spf1 redirect=surtr.yggdrasil.li" | ||
84 | _acme-challenge.paperless IN NS ns.yggdrasil.li. | ||
85 | |||
86 | paperless IN HTTPS 1 . alpn="h2,h3" ipv4hint="202.61.241.61" ipv6hint="2a03:4000:52:ada::" | ||
87 | |||
88 | hledger IN A 202.61.241.61 | ||
89 | hledger IN AAAA 2a03:4000:52:ada:: | ||
90 | hledger IN MX 0 surtr.yggdrasil.li | ||
91 | hledger IN TXT "v=spf1 redirect=surtr.yggdrasil.li" | ||
92 | _acme-challenge.hledger IN NS ns.yggdrasil.li. | ||
93 | |||
94 | hledger IN HTTPS 1 . alpn="h2,h3" ipv4hint="202.61.241.61" ipv6hint="2a03:4000:52:ada::" | ||
95 | |||
80 | vidhar IN AAAA 2a03:4000:52:ada:4:1:: | 96 | vidhar IN AAAA 2a03:4000:52:ada:4:1:: |
81 | vidhar IN MX 0 ymir.yggdrasil.li | 97 | vidhar IN MX 0 ymir.yggdrasil.li |
82 | vidhar IN TXT "v=spf1 redirect=yggdrasil.li" | 98 | vidhar IN TXT "v=spf1 redirect=yggdrasil.li" |
@@ -104,6 +120,3 @@ _infinoted._tcp IN SRV 5 0 6523 ymir.yggdrasil.li. | |||
104 | _submission._tcp IN SRV 5 0 25 ymir.yggdrasil.li. | 120 | _submission._tcp IN SRV 5 0 25 ymir.yggdrasil.li. |
105 | _imap._tcp IN SRV 5 0 143 ymir.yggdrasil.li. | 121 | _imap._tcp IN SRV 5 0 143 ymir.yggdrasil.li. |
106 | _imaps._tcp IN SRV 5 0 993 ymir.yggdrasil.li. | 122 | _imaps._tcp IN SRV 5 0 993 ymir.yggdrasil.li. |
107 | |||
108 | game01 IN A 94.16.107.151 | ||
109 | game01 IN AAAA 2a03:4000:50:13d:34ee:a2ff:fed0:328f | ||
diff --git a/hosts/surtr/hledger.nix b/hosts/surtr/hledger.nix new file mode 100644 index 00000000..e44933c3 --- /dev/null +++ b/hosts/surtr/hledger.nix | |||
@@ -0,0 +1,66 @@ | |||
1 | { config, ... }: | ||
2 | |||
3 | { | ||
4 | config = { | ||
5 | security.acme.rfc2136Domains = { | ||
6 | "hledger.yggdrasil.li" = { | ||
7 | restartUnits = ["nginx.service"]; | ||
8 | }; | ||
9 | }; | ||
10 | |||
11 | services.nginx = { | ||
12 | upstreams."hledger" = { | ||
13 | servers = { | ||
14 | "[2a03:4000:52:ada:4:1::]:5000" = {}; | ||
15 | }; | ||
16 | extraConfig = '' | ||
17 | keepalive 8; | ||
18 | ''; | ||
19 | }; | ||
20 | virtualHosts = { | ||
21 | "hledger.yggdrasil.li" = { | ||
22 | kTLS = true; | ||
23 | http3 = true; | ||
24 | forceSSL = true; | ||
25 | sslCertificate = "/run/credentials/nginx.service/hledger.yggdrasil.li.pem"; | ||
26 | sslCertificateKey = "/run/credentials/nginx.service/hledger.yggdrasil.li.key.pem"; | ||
27 | sslTrustedCertificate = "/run/credentials/nginx.service/hledger.yggdrasil.li.chain.pem"; | ||
28 | extraConfig = '' | ||
29 | charset utf-8; | ||
30 | ''; | ||
31 | |||
32 | locations = { | ||
33 | "/".extraConfig = '' | ||
34 | proxy_pass http://hledger; | ||
35 | |||
36 | proxy_http_version 1.1; | ||
37 | proxy_set_header Upgrade $http_upgrade; | ||
38 | proxy_set_header Connection "upgrade"; | ||
39 | |||
40 | proxy_redirect off; | ||
41 | proxy_set_header Host $host; | ||
42 | proxy_set_header X-Real-IP $remote_addr; | ||
43 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
44 | proxy_set_header X-Forwarded-Host $server_name; | ||
45 | proxy_set_header X-Forwarded-Proto $scheme; | ||
46 | |||
47 | client_max_body_size 0; | ||
48 | proxy_request_buffering off; | ||
49 | proxy_buffering off; | ||
50 | ''; | ||
51 | }; | ||
52 | }; | ||
53 | }; | ||
54 | }; | ||
55 | |||
56 | systemd.services.nginx = { | ||
57 | serviceConfig = { | ||
58 | LoadCredential = [ | ||
59 | "hledger.yggdrasil.li.key.pem:${config.security.acme.certs."hledger.yggdrasil.li".directory}/key.pem" | ||
60 | "hledger.yggdrasil.li.pem:${config.security.acme.certs."hledger.yggdrasil.li".directory}/fullchain.pem" | ||
61 | "hledger.yggdrasil.li.chain.pem:${config.security.acme.certs."hledger.yggdrasil.li".directory}/chain.pem" | ||
62 | ]; | ||
63 | }; | ||
64 | }; | ||
65 | }; | ||
66 | } | ||
diff --git a/hosts/surtr/paperless.nix b/hosts/surtr/paperless.nix new file mode 100644 index 00000000..7bc4397c --- /dev/null +++ b/hosts/surtr/paperless.nix | |||
@@ -0,0 +1,66 @@ | |||
1 | { config, ... }: | ||
2 | |||
3 | { | ||
4 | config = { | ||
5 | security.acme.rfc2136Domains = { | ||
6 | "paperless.yggdrasil.li" = { | ||
7 | restartUnits = ["nginx.service"]; | ||
8 | }; | ||
9 | }; | ||
10 | |||
11 | services.nginx = { | ||
12 | upstreams."paperless" = { | ||
13 | servers = { | ||
14 | "[2a03:4000:52:ada:4:1::]:28981" = {}; | ||
15 | }; | ||
16 | extraConfig = '' | ||
17 | keepalive 8; | ||
18 | ''; | ||
19 | }; | ||
20 | virtualHosts = { | ||
21 | "paperless.yggdrasil.li" = { | ||
22 | kTLS = true; | ||
23 | http3 = true; | ||
24 | forceSSL = true; | ||
25 | sslCertificate = "/run/credentials/nginx.service/paperless.yggdrasil.li.pem"; | ||
26 | sslCertificateKey = "/run/credentials/nginx.service/paperless.yggdrasil.li.key.pem"; | ||
27 | sslTrustedCertificate = "/run/credentials/nginx.service/paperless.yggdrasil.li.chain.pem"; | ||
28 | extraConfig = '' | ||
29 | charset utf-8; | ||
30 | ''; | ||
31 | |||
32 | locations = { | ||
33 | "/".extraConfig = '' | ||
34 | proxy_pass http://paperless; | ||
35 | |||
36 | proxy_http_version 1.1; | ||
37 | proxy_set_header Upgrade $http_upgrade; | ||
38 | proxy_set_header Connection "upgrade"; | ||
39 | |||
40 | proxy_redirect off; | ||
41 | proxy_set_header Host $host; | ||
42 | proxy_set_header X-Real-IP $remote_addr; | ||
43 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
44 | proxy_set_header X-Forwarded-Host $server_name; | ||
45 | proxy_set_header X-Forwarded-Proto $scheme; | ||
46 | |||
47 | client_max_body_size 0; | ||
48 | proxy_request_buffering off; | ||
49 | proxy_buffering off; | ||
50 | ''; | ||
51 | }; | ||
52 | }; | ||
53 | }; | ||
54 | }; | ||
55 | |||
56 | systemd.services.nginx = { | ||
57 | serviceConfig = { | ||
58 | LoadCredential = [ | ||
59 | "paperless.yggdrasil.li.key.pem:${config.security.acme.certs."paperless.yggdrasil.li".directory}/key.pem" | ||
60 | "paperless.yggdrasil.li.pem:${config.security.acme.certs."paperless.yggdrasil.li".directory}/fullchain.pem" | ||
61 | "paperless.yggdrasil.li.chain.pem:${config.security.acme.certs."paperless.yggdrasil.li".directory}/chain.pem" | ||
62 | ]; | ||
63 | }; | ||
64 | }; | ||
65 | }; | ||
66 | } | ||
diff --git a/hosts/surtr/tls/tsig_key.gup b/hosts/surtr/tls/tsig_key.gup index 825479e5..46a3789e 100644 --- a/hosts/surtr/tls/tsig_key.gup +++ b/hosts/surtr/tls/tsig_key.gup | |||
@@ -3,4 +3,4 @@ | |||
3 | keyFile=../dns/keys/${2:t}_acme | 3 | keyFile=../dns/keys/${2:t}_acme |
4 | gup -u $keyFile | 4 | gup -u $keyFile |
5 | sops -d --input-type=binary --output-type=binary ${keyFile} | yq -r '.key[0].secret' > $1 | 5 | sops -d --input-type=binary --output-type=binary ${keyFile} | yq -r '.key[0].secret' > $1 |
6 | sops -p '7ED22F4AA7BB55728B643DC5471B7D88E4EF66F8,30D3453B8CD02FE2A3E7C78C0FB536FB87AE8F51' --input-type=binary -e -i $1 | 6 | sops --input-type=binary -e -i $1 |
diff --git a/hosts/surtr/tls/tsig_keys/hledger.yggdrasil.li b/hosts/surtr/tls/tsig_keys/hledger.yggdrasil.li new file mode 100644 index 00000000..ab6cdd68 --- /dev/null +++ b/hosts/surtr/tls/tsig_keys/hledger.yggdrasil.li | |||
@@ -0,0 +1,24 @@ | |||
1 | { | ||
2 | "data": "ENC[AES256_GCM,data:Yd70QIj9DE6a5IN+Mf2M5p95vkRMHRg9BXaM686W7BRtthOw9m54/5FK6JWr,iv:cIOIKinkqFFPgTZdewWVY0h6kM5hGfVzuA4iYNhwK5c=,tag:Ds/oI+TOERbIdcGbI4WoEg==,type:str]", | ||
3 | "sops": { | ||
4 | "kms": null, | ||
5 | "gcp_kms": null, | ||
6 | "azure_kv": null, | ||
7 | "hc_vault": null, | ||
8 | "age": [ | ||
9 | { | ||
10 | "recipient": "age1rmmhetcmllq0ahl5qznlr0eya2zdxwl9h6y5wnl97d2wtyx5t99sm2u866", | ||
11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA1NnJ4SmsvSlh3ZlliSm9C\nNG45clh3NEZWZ05jaHhVK0xqTVRFL2wxN1ZrCk5hL2p2ZjhtcDBjTEZscXFTNkY5\nemVZSUUwV2V5cFBTdWo4RWxsM2xROVEKLS0tIDBFSFlkUVJ0ajJEUENlelVFKzVk\ndnJhMURMU2o3WVBKZGNVRXBiNytqUFEKHivcSTYy5D770C0h7RsmLBmkIG9+MDoV\ngJHvfkGzXPKwmDTMKdHbIk+ctI+u0/1jMn/K2Q9OFnOIYxP3gHiFag==\n-----END AGE ENCRYPTED FILE-----\n" | ||
12 | }, | ||
13 | { | ||
14 | "recipient": "age19a7j77w267z04zls7m28a8hj4a0g5af6ltye2d5wypg33c3l89csd4r9zq", | ||
15 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSArYUNCQ1U2MXpQdmM4SHR0\nTnJWZlFGTUQ1NjVqZ3Z2MGt5NFpBVFp0b0YwCkdseitkbzI1RkZyL3V5Z1pNMG9R\nVnEzRUxrTDQrS3BiMXB1QUFPeUcxZUkKLS0tIGJFODkwNFY3c0tBLzFBNjFiYjJk\nZW82bTdia2F1NHpNSG1IYmhWb1ZCTHMK9ovFx3+x5PrV4y6+RH5XA5DK2wRPXlAt\ncxxpRZIlmnvhZXIeCYE9yhHFmz3uAn0Oib1RUDblca9FlnF9tyYD6g==\n-----END AGE ENCRYPTED FILE-----\n" | ||
16 | } | ||
17 | ], | ||
18 | "lastmodified": "2025-02-19T17:13:51Z", | ||
19 | "mac": "ENC[AES256_GCM,data:ReRuK9qdZV8AbMzA9Yur0AZW+1RF3aRnfBvsKJkQtXsFdkmJQ4QkRGtL27RmjFdvQ3kXBIyhib7hYA60AJ0amduYrSScY0dtz8AurjyE4f2BGQ9/QeKRBfKXHxLvj4/xWNvS4+PVdGKkKbqIs8isz9n77WQQ3lTHop2K/TjaTuQ=,iv:gUhDK9oeUHdpQ2Fp8mFDIgPFo2JjHE0jjooL7FmvmrE=,tag:2lkwSl3j3oqamdLbM9wbow==,type:str]", | ||
20 | "pgp": null, | ||
21 | "unencrypted_suffix": "_unencrypted", | ||
22 | "version": "3.9.4" | ||
23 | } | ||
24 | } \ No newline at end of file | ||
diff --git a/hosts/surtr/tls/tsig_keys/paperless.yggdrasil.li b/hosts/surtr/tls/tsig_keys/paperless.yggdrasil.li new file mode 100644 index 00000000..b1029931 --- /dev/null +++ b/hosts/surtr/tls/tsig_keys/paperless.yggdrasil.li | |||
@@ -0,0 +1,24 @@ | |||
1 | { | ||
2 | "data": "ENC[AES256_GCM,data:D9l0pklD2KDZ4/TXHtXg00MmCnjCVVBG0AK9j5OxxBCyYseCTckp2P/iPOng,iv:DjvuKWPr/jldfk0eZ5+jWHN0RurdruR4Md7AMAPzRQg=,tag:h0c4m3hpATzzb6a7DVmi9w==,type:str]", | ||
3 | "sops": { | ||
4 | "kms": null, | ||
5 | "gcp_kms": null, | ||
6 | "azure_kv": null, | ||
7 | "hc_vault": null, | ||
8 | "age": [ | ||
9 | { | ||
10 | "recipient": "age1rmmhetcmllq0ahl5qznlr0eya2zdxwl9h6y5wnl97d2wtyx5t99sm2u866", | ||
11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA3S05aS0ZEcVU2T3BIOG13\nSDJLTUp4OG9ZYVluK2gxbUJDSFRaQ0xnS0YwClFkKzByanJGOWFwbTlISndyU0Rx\nN1FJb3FVaUZOVDBsWEdHTVNGaGNtMVkKLS0tIDI1RmxaMlhVd1FPL1dNdlRGK0Nq\nMFpJZTNnWncrbkV5YS82ZnhGRld0UG8KIuf7bC7GVxaGeR7gwC7kGu/wtBppjq4H\nyDT05CYJf9/EE3K5aJpIOlxyqowRs2SINvIVkyd5ggYkkxCctmGXjQ==\n-----END AGE ENCRYPTED FILE-----\n" | ||
12 | }, | ||
13 | { | ||
14 | "recipient": "age19a7j77w267z04zls7m28a8hj4a0g5af6ltye2d5wypg33c3l89csd4r9zq", | ||
15 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBUV3ZqTVJkNWdHeTlKK3Vl\nVTdrdzE2Z3YzVmZxelNFMDNMTUJneHNtNzFRCmQxTU84ekV4bFVLajU0ajB6ZzZK\neEpuQTcyS1o4MW9xTU5nMXVUR0gxTmcKLS0tIGVzZC8xYTc1VkU2RzA2NFQ1K2xz\nLzhPVjBUcytWNGRsdnFob3A4aWljelkKFMlmigcEVzelcEiv6WGya1dsIOJYr7YT\naBHgMttV7zzYHLqvIVJSCz+uw2FqDyqN46twmzFC0HSHeiKbvRrHVw==\n-----END AGE ENCRYPTED FILE-----\n" | ||
16 | } | ||
17 | ], | ||
18 | "lastmodified": "2025-02-13T19:23:42Z", | ||
19 | "mac": "ENC[AES256_GCM,data:0Fcgq0pOZtBBSiK8pUr/jadXMdtbZYFhUbSe+7DQpB8Fo2r8cEoT+Cpcy7tu+l9eXUiDk/tXTBJyMXaW4XWwS/Fe6Zcb95UYaYR1Y6OM9JVPYmwd6QSeC13MwzhYaCDlBiWWq69Zn8grEg7npWo/LS9LK7IEbN7EI8o7QYDI6cw=,iv:C+8ZmVTNWySQ+/6j+YirSwZzoMqXRlgstk47Efxmqps=,tag:Be/6Ve6M/Dcm/6QrbF+JTw==,type:str]", | ||
20 | "pgp": null, | ||
21 | "unencrypted_suffix": "_unencrypted", | ||
22 | "version": "3.9.4" | ||
23 | } | ||
24 | } \ No newline at end of file | ||
diff --git a/hosts/vidhar/default.nix b/hosts/vidhar/default.nix index b0797d8a..90ab40dd 100644 --- a/hosts/vidhar/default.nix +++ b/hosts/vidhar/default.nix | |||
@@ -4,7 +4,7 @@ with lib; | |||
4 | 4 | ||
5 | { | 5 | { |
6 | imports = with flake.nixosModules.systemProfiles; [ | 6 | imports = with flake.nixosModules.systemProfiles; [ |
7 | ./zfs.nix ./network ./samba.nix ./dns ./prometheus ./borg ./pgbackrest ./postgresql.nix ./immich.nix | 7 | ./zfs.nix ./network ./samba.nix ./dns ./prometheus ./borg ./pgbackrest ./postgresql.nix ./immich.nix ./paperless ./hledger |
8 | tmpfs-root zfs | 8 | tmpfs-root zfs |
9 | initrd-all-crypto-modules default-locale openssh rebuild-machines | 9 | initrd-all-crypto-modules default-locale openssh rebuild-machines |
10 | build-server | 10 | build-server |
diff --git a/hosts/vidhar/hledger/default.nix b/hosts/vidhar/hledger/default.nix new file mode 100644 index 00000000..ae080f66 --- /dev/null +++ b/hosts/vidhar/hledger/default.nix | |||
@@ -0,0 +1,83 @@ | |||
1 | { config, lib, pkgs, ... }: | ||
2 | { | ||
3 | config = { | ||
4 | services.hledger-web = { | ||
5 | enable = true; | ||
6 | allow = "view"; | ||
7 | stateDir = "/var/lib/hledger"; | ||
8 | journalFiles = lib.mkForce ["web.journal"]; | ||
9 | baseUrl = "https://hledger.yggdrasil.li"; | ||
10 | extraOptions = [ | ||
11 | "--socket=/run/hledger-web/http.sock" | ||
12 | ]; | ||
13 | }; | ||
14 | users = { | ||
15 | users.hledger.uid = 982; | ||
16 | groups.hledger.gid = 979; | ||
17 | }; | ||
18 | systemd.services.hledger-web = { | ||
19 | serviceConfig = { | ||
20 | UMask = "0002"; | ||
21 | ReadOnlyPaths = [ config.services.hledger-web.stateDir ]; | ||
22 | RuntimeDirectory = [ "hledger-web" ]; | ||
23 | PrivateDevices = true; | ||
24 | StateDirectory = "hledger"; | ||
25 | CapabilityBoundingSet = ""; | ||
26 | AmbientCapabilities = ""; | ||
27 | ProtectSystem = "strict"; | ||
28 | ProtectKernelTunables = true; | ||
29 | ProtectKernelModules = true; | ||
30 | ProtectControlGroups = true; | ||
31 | ProtectClock = true; | ||
32 | ProtectHostname = true; | ||
33 | ProtectHome = "tmpfs"; | ||
34 | ProtectKernelLogs = true; | ||
35 | ProtectProc = "invisible"; | ||
36 | ProcSubset = "pid"; | ||
37 | PrivateNetwork = false; | ||
38 | RestrictAddressFamilies = "AF_INET AF_INET6 AF_UNIX"; | ||
39 | SystemCallArchitectures = "native"; | ||
40 | SystemCallFilter = [ | ||
41 | "@system-service @resources" | ||
42 | "~@obsolete @privileged" | ||
43 | ]; | ||
44 | RestrictSUIDSGID = true; | ||
45 | RemoveIPC = true; | ||
46 | NoNewPrivileges = true; | ||
47 | RestrictRealtime = true; | ||
48 | RestrictNamespaces = true; | ||
49 | LockPersonality = true; | ||
50 | PrivateUsers = true; | ||
51 | TemporaryFileSystem = [ "/var/lib/hledger/.cache:mode=0750,uid=${toString (config.users.users.hledger.uid)},gid=${toString (config.users.groups.hledger.gid)}" ]; | ||
52 | }; | ||
53 | }; | ||
54 | services.nginx = { | ||
55 | upstreams.hledger = { | ||
56 | servers = { "unix:/run/hledger-web/http.sock" = {}; }; | ||
57 | }; | ||
58 | virtualHosts."hledger.yggdrasil.li" = { | ||
59 | listen = [ | ||
60 | { addr = "[2a03:4000:52:ada:4:1::]"; port = 5000; } | ||
61 | ]; | ||
62 | extraConfig = '' | ||
63 | set_real_ip_from 2a03:4000:52:ada:4::; | ||
64 | auth_basic "hledger"; | ||
65 | auth_basic_user_file "/run/credentials/nginx.service/hledger_users"; | ||
66 | ''; | ||
67 | locations."/" = { | ||
68 | proxyPass = "http://hledger/"; | ||
69 | proxyWebsockets = true; | ||
70 | }; | ||
71 | }; | ||
72 | }; | ||
73 | systemd.services.nginx.serviceConfig = { | ||
74 | SupplementaryGroups = [ "hledger" ]; | ||
75 | LoadCredential = [ "hledger_users:${config.sops.secrets."hledger_users".path}" ]; | ||
76 | }; | ||
77 | sops.secrets."hledger_users" = { | ||
78 | format = "binary"; | ||
79 | sopsFile = ./htpasswd; | ||
80 | reloadUnits = [ "nginx.service" ]; | ||
81 | }; | ||
82 | }; | ||
83 | } | ||
diff --git a/hosts/vidhar/hledger/htpasswd b/hosts/vidhar/hledger/htpasswd new file mode 100644 index 00000000..016cb525 --- /dev/null +++ b/hosts/vidhar/hledger/htpasswd | |||
@@ -0,0 +1,24 @@ | |||
1 | { | ||
2 | "data": "ENC[AES256_GCM,data:9MNDIAc7ePYk3xQDorX2pU8ybJkJb33RKiJxc2DYauXFNQYxtGwCYhZwod7p7fPh3KqZxBNMRoZXr+/RnV+trsqjAcOOjnXTWLbX6nubq/xm+q0BxEjOPn7FvJF9XOblBeupldo+byGh2CMH9qQv5Fov,iv:3Tym+Mfr48OJet3qDFZPg0XjYr4sNQdNdiu0vUxmzbY=,tag:E0sxRY/jeMVlqH6uAYvD/Q==,type:str]", | ||
3 | "sops": { | ||
4 | "kms": null, | ||
5 | "gcp_kms": null, | ||
6 | "azure_kv": null, | ||
7 | "hc_vault": null, | ||
8 | "age": [ | ||
9 | { | ||
10 | "recipient": "age1rmmhetcmllq0ahl5qznlr0eya2zdxwl9h6y5wnl97d2wtyx5t99sm2u866", | ||
11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA3eFBsOEM2ZUNVT2V3LytC\nTUJvUDdKc0VzMyt2cDFKYU03djBjZVFpeVY4CjByMXhPVXRJVjhKQWZvQ2xuOTE3\ncXdJV1lZaHR3cVl0Z0hQaG00M2dGbjQKLS0tIEIzenVxb3cwM3pXTUl1YUZlSlk2\nbDc3VmE5NkEyZ2tRd01OUGZibmhtUlEKxdesIdvzm8s0SmXU5R+tSbmS5Dj24jrb\nEiMERYy1g8GyHR3d2/mU5iOIdsBegSZReUVzomaMT9L7/TmubgOP3g==\n-----END AGE ENCRYPTED FILE-----\n" | ||
12 | }, | ||
13 | { | ||
14 | "recipient": "age1qffdqvy9arld9zd5a5cylt0n98xhcns5shxhrhwjq5g4qa844ejselaa4l", | ||
15 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBPa2RDZzR6cEFYTFA1QkND\nbndVeHVrMVJ0MWZvRmw5VXRhOHlRYllIRWxRCjU4dks4R25LS1RZMHFnbmpQRVZz\nNXhubkJvZFc2amRwMDVtQlE0NnBKNzQKLS0tIHRyeDUxTEFPMEMzWUVkZURzODdm\nSHdqbUpvNmFTS1QveFRpRHdnWHpHb28KnvdUkMkKGiBVHQD7Yv7n6WZjihCGJAR2\nMKl2WAn4g4jzgcXPwwIAIjUrMGSIdGpwCTUDcDnlKWAbRYO2B6P17A==\n-----END AGE ENCRYPTED FILE-----\n" | ||
16 | } | ||
17 | ], | ||
18 | "lastmodified": "2025-02-19T17:11:17Z", | ||
19 | "mac": "ENC[AES256_GCM,data:yBIEqHhr4igoMlRcgg2SigKfejqeuNmuleYolsLJo+QOaW4BHITJTvLxRV1JHPpcMVQkF//zx4ZfUUrb8tTN0znGu3Jnpd0JVagbfCVyEuT6d1SB/GzyUVvoQ2GlcA9us+5gjI4oEJTQCfVqnLDBWsw+jXdr3nEIWo6Mvbqo3lI=,iv:I6Swk4wyd+96+tJKRY/FHlS7ZShMDROcbl+l+ZLRxhM=,tag:P1uQvB4NLdkPEKRMI6lLxw==,type:str]", | ||
20 | "pgp": null, | ||
21 | "unencrypted_suffix": "_unencrypted", | ||
22 | "version": "3.9.4" | ||
23 | } | ||
24 | } \ No newline at end of file | ||
diff --git a/hosts/vidhar/network/ruleset.nft b/hosts/vidhar/network/ruleset.nft index 10fd4c51..1edae167 100644 --- a/hosts/vidhar/network/ruleset.nft +++ b/hosts/vidhar/network/ruleset.nft | |||
@@ -92,6 +92,8 @@ table inet filter { | |||
92 | counter tftp-rx {} | 92 | counter tftp-rx {} |
93 | counter pgbackrest-rx {} | 93 | counter pgbackrest-rx {} |
94 | counter immich-rx {} | 94 | counter immich-rx {} |
95 | counter paperless-rx {} | ||
96 | counter hledger-rx {} | ||
95 | 97 | ||
96 | counter established-rx {} | 98 | counter established-rx {} |
97 | 99 | ||
@@ -121,6 +123,8 @@ table inet filter { | |||
121 | counter tftp-tx {} | 123 | counter tftp-tx {} |
122 | counter pgbackrest-tx {} | 124 | counter pgbackrest-tx {} |
123 | counter immich-tx {} | 125 | counter immich-tx {} |
126 | counter paperless-tx {} | ||
127 | counter hledger-tx {} | ||
124 | 128 | ||
125 | counter tx {} | 129 | counter tx {} |
126 | 130 | ||
@@ -197,6 +201,8 @@ table inet filter { | |||
197 | tcp dport 8432 counter name pgbackrest-rx accept | 201 | tcp dport 8432 counter name pgbackrest-rx accept |
198 | 202 | ||
199 | iifname bifrost tcp dport 2283 ip6 saddr $bifrost_surtr counter name immich-rx accept | 203 | iifname bifrost tcp dport 2283 ip6 saddr $bifrost_surtr counter name immich-rx accept |
204 | iifname bifrost tcp dport 28981 ip6 saddr $bifrost_surtr counter name paperless-rx accept | ||
205 | iifname bifrost tcp dport 5000 ip6 saddr $bifrost_surtr counter name hledger-rx accept | ||
200 | 206 | ||
201 | ct state { established, related } counter name established-rx accept | 207 | ct state { established, related } counter name established-rx accept |
202 | 208 | ||
@@ -246,6 +252,8 @@ table inet filter { | |||
246 | tcp sport 8432 counter name pgbackrest-tx accept | 252 | tcp sport 8432 counter name pgbackrest-tx accept |
247 | 253 | ||
248 | iifname bifrost tcp sport 2283 ip6 daddr $bifrost_surtr counter name immich-tx accept | 254 | iifname bifrost tcp sport 2283 ip6 daddr $bifrost_surtr counter name immich-tx accept |
255 | iifname bifrost tcp sport 28981 ip6 daddr $bifrost_surtr counter name paperless-tx accept | ||
256 | iifname bifrost tcp sport 5000 ip6 daddr $bifrost_surtr counter name hledger-tx accept | ||
249 | 257 | ||
250 | 258 | ||
251 | counter name tx | 259 | counter name tx |
diff --git a/hosts/vidhar/paperless/default.nix b/hosts/vidhar/paperless/default.nix new file mode 100644 index 00000000..34cd18c4 --- /dev/null +++ b/hosts/vidhar/paperless/default.nix | |||
@@ -0,0 +1,25 @@ | |||
1 | { config, ... }: | ||
2 | |||
3 | { | ||
4 | config = { | ||
5 | services.paperless = { | ||
6 | enable = true; | ||
7 | address = "[2a03:4000:52:ada:4:1::]"; | ||
8 | passwordFile = config.sops.secrets."paperless-rootpw".path; | ||
9 | settings = { | ||
10 | PAPERLESS_OCR_LANGUAGE = "deu+eng"; | ||
11 | PAPERLESS_URL = "https://paperless.yggdrasil.li"; | ||
12 | PAPERLESS_FILENAME_FORMAT = "{{ created_year }}/{{ document_type }}/{{ correspondent }}/{{ created }}_{{ doc_pk }}_{{ title }}"; | ||
13 | PAPERLESS_FILENAME_FORMAT_REMOVE_NONE = "true"; | ||
14 | PAPERLESS_TASK_WORKERS = "3"; | ||
15 | PAPERLESS_THREADS_PER_WORKER = "4"; | ||
16 | }; | ||
17 | database.createLocally = true; | ||
18 | }; | ||
19 | |||
20 | sops.secrets."paperless-rootpw" = { | ||
21 | format = "binary"; | ||
22 | sopsFile = ./rootpw; | ||
23 | }; | ||
24 | }; | ||
25 | } | ||
diff --git a/hosts/vidhar/paperless/rootpw b/hosts/vidhar/paperless/rootpw new file mode 100644 index 00000000..11f48fcb --- /dev/null +++ b/hosts/vidhar/paperless/rootpw | |||
@@ -0,0 +1,24 @@ | |||
1 | { | ||
2 | "data": "ENC[AES256_GCM,data:Bsns3bLs7aA++eTf2Vh4g2iAXhmrMRTF,iv:zQ6hgXEvgHAloN6UMW54f2nYCvEhHPXQSBVSihHFiC0=,tag:uiGTEs07dpx12PcAjmbr9Q==,type:str]", | ||
3 | "sops": { | ||
4 | "kms": null, | ||
5 | "gcp_kms": null, | ||
6 | "azure_kv": null, | ||
7 | "hc_vault": null, | ||
8 | "age": [ | ||
9 | { | ||
10 | "recipient": "age1rmmhetcmllq0ahl5qznlr0eya2zdxwl9h6y5wnl97d2wtyx5t99sm2u866", | ||
11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBlVUJjdEdIZGd6UDJBRXlL\nODFyWDhHOU9oTEVCVlFiUXVXNm9XZmVuampVCkJ0YkFXTlZXVnRldmtlVkJaR3R2\nMFhpaHB5M3pLeDFkUkkzMUFydGNnOFEKLS0tIEJtNWc0V2JaaWYvQlp6TGxVdVZO\neVpzQzB5Um82TUZOeHBHeE50MGlqNWsKj1P54Fc+c5n35+Og9DwBWkvW947hgFsp\ni/G2QcaLHHJMTexTCZYsr1naSVa/cMBAbrZmtjz0HV4Q1kCJtvlrIg==\n-----END AGE ENCRYPTED FILE-----\n" | ||
12 | }, | ||
13 | { | ||
14 | "recipient": "age1qffdqvy9arld9zd5a5cylt0n98xhcns5shxhrhwjq5g4qa844ejselaa4l", | ||
15 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA1UG1QSWtXcFZoQVRBOC9D\nT2VnTW9pcTRCMForcHdZVld0c1NmNFZpWUNBCkRkMERKUVliYXRqb25saWxyb2JN\nbC9YL2ZQbytRM0ZjNmlQOTlTZTQrV2sKLS0tIFZyUWtRcXNqZUZxMGN5d0tHUng2\nVXNSdFEwMmtIVEdVRVlWeVU1YmJVSkUKRJa42k551QtiC6S0tmMv7eVN7GRqpXWz\nvzNh+BM9TOJNaTMmVesr4vXNDLOSFS3PxYv95xuOBzVg3zOHuai72g==\n-----END AGE ENCRYPTED FILE-----\n" | ||
16 | } | ||
17 | ], | ||
18 | "lastmodified": "2025-02-13T19:20:33Z", | ||
19 | "mac": "ENC[AES256_GCM,data:mG6AC3L8MMeZ0Ajr7zV1mzPcHviQw2adtGjSbrbPRw1xqN7siu6svoybv8xkahP2Grq/xKAiyfXFOFo7Uyc3ub5fSovAEolNazqybZYsyam5vHpeC23dXcEkZUJSPJ9/CSB5uI9nX3NPC64QUjCxHZ7qfH5gcXT9D12H8LSqKlQ=,iv:4Skdj8l9jlTX9Unc2xE2hCKVawHBnHR8L4kZA6H8xNw=,tag:zJsJ3S//faAn7AGwLefNoA==,type:str]", | ||
20 | "pgp": null, | ||
21 | "unencrypted_suffix": "_unencrypted", | ||
22 | "version": "3.9.4" | ||
23 | } | ||
24 | } \ No newline at end of file | ||
diff --git a/installer/default.nix b/installer/default.nix index cd1ee064..ec47832a 100644 --- a/installer/default.nix +++ b/installer/default.nix | |||
@@ -57,6 +57,10 @@ with lib; | |||
57 | 57 | ||
58 | system.disableInstallerTools = false; | 58 | system.disableInstallerTools = false; |
59 | 59 | ||
60 | xdg.autostart.enable = lib.mkForce false; | ||
61 | xdg.icons.enable = lib.mkForce false; | ||
62 | xdg.mime.enable = lib.mkForce false; | ||
63 | |||
60 | systemd.sysusers.enable = false; | 64 | systemd.sysusers.enable = false; |
61 | system.machine-id.generate.enable = false; | 65 | system.machine-id.generate.enable = false; |
62 | system.stateVersion = config.system.nixos.release; # No state in installer | 66 | system.stateVersion = config.system.nixos.release; # No state in installer |
diff --git a/modules/backup-utils.nix b/modules/backup-utils.nix index 82a42ecd..698140da 100644 --- a/modules/backup-utils.nix +++ b/modules/backup-utils.nix | |||
@@ -9,5 +9,8 @@ with lib; | |||
9 | 9 | ||
10 | config = { | 10 | config = { |
11 | services.borgsnap.archive-prefix = mkDefault "yggdrasil.${hostName}."; | 11 | services.borgsnap.archive-prefix = mkDefault "yggdrasil.${hostName}."; |
12 | |||
13 | systemd.services."zfssnap-prune".restartIfChanged = false; | ||
14 | systemd.services."zfssnap".restartIfChanged = false; | ||
12 | }; | 15 | }; |
13 | } | 16 | } |
diff --git a/modules/niri.nix b/modules/niri.nix new file mode 100644 index 00000000..4e2ddf8b --- /dev/null +++ b/modules/niri.nix | |||
@@ -0,0 +1,6 @@ | |||
1 | { flakeInputs, ... }: | ||
2 | { | ||
3 | imports = [ | ||
4 | flakeInputs.niri-flake.nixosModules.niri | ||
5 | ]; | ||
6 | } | ||
diff --git a/modules/nix-access-tokens/default.nix b/modules/nix-access-tokens/default.nix new file mode 100644 index 00000000..a3b7abfa --- /dev/null +++ b/modules/nix-access-tokens/default.nix | |||
@@ -0,0 +1,24 @@ | |||
1 | { lib, config, hostName ,... }: | ||
2 | |||
3 | let | ||
4 | cfg = config.nix.includeAccessTokens; | ||
5 | in { | ||
6 | options = { | ||
7 | nix.includeAccessTokens.enable = lib.mkEnableOption "including access tokens in nix.conf" // { default = lib.elem hostName ["sif" "surtr" "vidhar"]; }; | ||
8 | }; | ||
9 | |||
10 | config = lib.mkIf cfg.enable { | ||
11 | nix = { | ||
12 | extraOptions = '' | ||
13 | !include ${config.sops.secrets.nixAccessTokens.path} | ||
14 | ''; | ||
15 | }; | ||
16 | |||
17 | sops.secrets.nixAccessTokens = { | ||
18 | format = "binary"; | ||
19 | sopsFile = ./nix.conf; | ||
20 | mode = "0440"; | ||
21 | group = "wheel"; | ||
22 | }; | ||
23 | }; | ||
24 | } | ||
diff --git a/modules/nix-access-tokens/nix.conf b/modules/nix-access-tokens/nix.conf new file mode 100644 index 00000000..f0b394ef --- /dev/null +++ b/modules/nix-access-tokens/nix.conf | |||
@@ -0,0 +1,32 @@ | |||
1 | { | ||
2 | "data": "ENC[AES256_GCM,data:/cdBpvCAFpgm0YWhy1WYlA09KlU6PzVfBYVLBD0boqGqvP+8wuyDzj5KWbcKsdGhoiklODiKR0ODXNU+fA35y862PFXvSb4xVyfbdKRndYdIA4W6vyobtoC9h7B1yR9pkq9L+1tqlU30Dgy2Gndg9rWHlIo+1lO/1A==,iv:B1Px2+cxCaopHZThkEG5saOib+PNvurPIS6aeAv2uPo=,tag:K3JqRaX3/iIqD3c//YdqSQ==,type:str]", | ||
3 | "sops": { | ||
4 | "kms": null, | ||
5 | "gcp_kms": null, | ||
6 | "azure_kv": null, | ||
7 | "hc_vault": null, | ||
8 | "age": [ | ||
9 | { | ||
10 | "recipient": "age1rmmhetcmllq0ahl5qznlr0eya2zdxwl9h6y5wnl97d2wtyx5t99sm2u866", | ||
11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB5NkZUUGI3M2pQYWVXeFV6\na2h2czRTeUJFekJCS012YlBkL1FDdTd3ekZ3ClJsTVh0R2JQM0Jua1JjL285RVA1\nRHhlbjlLdmNBUXVLelFGY2NGYWpLejQKLS0tIDBUWUhJNm8zWGoyQ0pBYnV1ZjBh\ndktNRkNPS1lpWXFITC81aEZJbXlONk0Km2c1xVKwSankaVs7O/utGJwRRX395upz\ndPbsOElTnbGmkb0esGtvGSPboTvK+gjn9w/GhaPyTnNDoos7GaIfyg==\n-----END AGE ENCRYPTED FILE-----\n" | ||
12 | }, | ||
13 | { | ||
14 | "recipient": "age1fj65apkhfkrwyv5tx6zcs9nkjg8267fy733qph30sc7zfn7vapjqkd5kne", | ||
15 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB6bS9iY2lua3U4U3lJa1pK\nSlZNMmFZMEU5M1V2bWRjaXIwajZJVDJPMlM4Cmd3TTNFWjVuSGdtbC9iODltTS91\nOE5XOEVEQkh0SFpVVW5jc3IzbzNpTmMKLS0tIEtrSU54QUVPa2tBZDhLYlRFWitR\nc2x6MFlxL0tobDJTek42dEcyZXpoWDgKXzQfU+o6FkbJBwmm6oaHu4sDPi822uUR\n5VY6gY/h3g2kM4cuS03Q4NJmeRxuh7cx0UqGU3j5Mf8muE1LHpYEPw==\n-----END AGE ENCRYPTED FILE-----\n" | ||
16 | }, | ||
17 | { | ||
18 | "recipient": "age19a7j77w267z04zls7m28a8hj4a0g5af6ltye2d5wypg33c3l89csd4r9zq", | ||
19 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBaOVpNZ2lVT0VwbHVZNzFl\nenJsMGpnbkRvU0xOSU5obk5yT2p5ZVNzdXhNCnVlQzZtRjZNVmJLSUpKc3UwVXZs\nWi9EZ3kxZkJNeFJDSjl1L1IweTFNMXcKLS0tIDJUOTBwTldCUmlnU0tWVkZkNzJL\nejM4ajJVbVhvSm1YM2Vxa2JldllYN0UKAzxy2wkzRvCSiTy417AulpCu41z668HG\nto92eGF2ZRFfEG5LGlCKWeDcP3gM8QwKiVlm6wndbOkhMMfc4Sp3wA==\n-----END AGE ENCRYPTED FILE-----\n" | ||
20 | }, | ||
21 | { | ||
22 | "recipient": "age1qffdqvy9arld9zd5a5cylt0n98xhcns5shxhrhwjq5g4qa844ejselaa4l", | ||
23 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB2ejRHcGttNUxYZnFzTU5J\nMTFvY3daQ1VMM2xxYTgvLzZwT1owazVNenhzCktaWFF6K2s5UjI2b20rSHFNSS9E\nMVlJSmZhQm15eUs3U0hGTGpSRndmSDgKLS0tIDVrcjl4eDhwak1pRithbnRWWEZy\nVE9EOEpKdEJoRTFrTXpQVDc1cmsrU1kK/goTdUmpZPeMRbY1QzLXAa6Qpg4YYYYo\n3v3GK1bzdey8szfgIr1dHTtQEzqE2WX1swzZizDXj/RiUWx01Ky3GA==\n-----END AGE ENCRYPTED FILE-----\n" | ||
24 | } | ||
25 | ], | ||
26 | "lastmodified": "2025-01-25T19:58:58Z", | ||
27 | "mac": "ENC[AES256_GCM,data:Oza4XgnTX3vly89nGluLbEytk1dUYAiOhIYewQyDLLLSSlUIpXmWhV+X0HUQ9AX5kUrEhNbVzRdvUG/9YwoWjTJfvd7tw41IYeTqgykMNXJUfGssoutXfeij9YR+t5aJaRhlTkIWcBhUjXSUNyJCl6Z3XmzWstTPZXEU9VmAvuE=,iv:LqVwIiit+WqI5NWSboexWsmPzg7e63nWJYsNFEK1Uog=,tag:ClR6oI62WXEfIYYAY6vL0A==,type:str]", | ||
28 | "pgp": null, | ||
29 | "unencrypted_suffix": "_unencrypted", | ||
30 | "version": "3.9.3" | ||
31 | } | ||
32 | } \ No newline at end of file | ||
diff --git a/modules/pgbackrest.nix b/modules/pgbackrest.nix index 886840b9..81c74a8e 100644 --- a/modules/pgbackrest.nix +++ b/modules/pgbackrest.nix | |||
@@ -216,6 +216,7 @@ in { | |||
216 | }; | 216 | }; |
217 | }; | 217 | }; |
218 | } // mapAttrs' (name: backupCfg: nameValuePair "pgbackrest-backup@${escapeSystemdPath name}" { | 218 | } // mapAttrs' (name: backupCfg: nameValuePair "pgbackrest-backup@${escapeSystemdPath name}" { |
219 | restartIfChanged = false; | ||
219 | description = "Perform pgBackRest Backup (${name}${optionalString (!(isNull backupCfg.repo)) " repo${backupCfg.repo}"})"; | 220 | description = "Perform pgBackRest Backup (${name}${optionalString (!(isNull backupCfg.repo)) " repo${backupCfg.repo}"})"; |
220 | serviceConfig = { | 221 | serviceConfig = { |
221 | Type = "oneshot"; | 222 | Type = "oneshot"; |
diff --git a/nvfetcher.toml b/nvfetcher.toml index c0566373..ecaebba0 100644 --- a/nvfetcher.toml +++ b/nvfetcher.toml | |||
@@ -78,12 +78,12 @@ git.fetchSubmodules = true | |||
78 | src.git = "https://github.com/jgreco/mpv-youtube-quality" | 78 | src.git = "https://github.com/jgreco/mpv-youtube-quality" |
79 | fetch.git = "https://github.com/jgreco/mpv-youtube-quality" | 79 | fetch.git = "https://github.com/jgreco/mpv-youtube-quality" |
80 | 80 | ||
81 | [batman-adv] | 81 | # [batman-adv] |
82 | src.webpage = "https://www.open-mesh.org/projects/open-mesh/wiki/Download" | 82 | # src.webpage = "https://www.open-mesh.org/projects/open-mesh/wiki/Download" |
83 | src.regex = "The latest version of <a[^\\>]*>batman-adv</a> is <a[^\\>]*>batman-adv-([0-9\\.]+).tar.gz</a>" | 83 | # src.regex = "The latest version of <a[^\\>]*>batman-adv</a> is <a[^\\>]*>batman-adv-([0-9\\.]+).tar.gz</a>" |
84 | src.from_pattern = "^.*batman-adv-([0-9\\.]+).tar.gz.*$" | 84 | # src.from_pattern = "^.*batman-adv-([0-9\\.]+).tar.gz.*$" |
85 | src.to_pattern = "\\1" | 85 | # src.to_pattern = "\\1" |
86 | fetch.tarball = "https://downloads.open-mesh.org/batman/stable/sources/batman-adv/batman-adv-$ver.tar.gz" | 86 | # fetch.tarball = "https://downloads.open-mesh.org/batman/stable/sources/batman-adv/batman-adv-$ver.tar.gz" |
87 | 87 | ||
88 | [scutiger] | 88 | [scutiger] |
89 | src.github_tag = "bk2204/scutiger" | 89 | src.github_tag = "bk2204/scutiger" |
@@ -107,3 +107,11 @@ fetch.tarball = "https://github.com/JonathonReinhart/spice-record/archive/refs/t | |||
107 | [yt-dlp] | 107 | [yt-dlp] |
108 | src.pypi = "yt_dlp" | 108 | src.pypi = "yt_dlp" |
109 | fetch.pypi = "yt_dlp" | 109 | fetch.pypi = "yt_dlp" |
110 | |||
111 | [mako] | ||
112 | src.git = "https://github.com/emersion/mako" | ||
113 | fetch.git = "https://github.com/emersion/mako" | ||
114 | |||
115 | [swayosd] | ||
116 | src.git = "https://github.com/ErikReider/SwayOSD" | ||
117 | fetch.git = "https://github.com/ErikReider/SwayOSD" | ||
diff --git a/overlays/batman-adv.nix b/overlays/batman-adv.nix deleted file mode 100644 index cce7dc4f..00000000 --- a/overlays/batman-adv.nix +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | { final, prev, sources, ... }: { | ||
2 | linuxPackages_latest = prev.linuxPackages_latest.extend (self: super: { | ||
3 | batman_adv = super.batman_adv.overrideAttrs (oldAttrs: { | ||
4 | version = "${sources.batman-adv.version}-${self.kernel.version}"; | ||
5 | inherit (sources.batman-adv) src; | ||
6 | }); | ||
7 | }); | ||
8 | |||
9 | linuxPackages_6_2 = prev.linuxPackages_6_2.extend (self: super: { | ||
10 | batman_adv = super.batman_adv.overrideAttrs (oldAttrs: { | ||
11 | version = "${sources.batman-adv.version}-${self.kernel.version}"; | ||
12 | inherit (sources.batman-adv) src; | ||
13 | }); | ||
14 | }); | ||
15 | } | ||
diff --git a/overlays/keepassxc/database-open-dialog.patch b/overlays/keepassxc/database-open-dialog.patch new file mode 100644 index 00000000..dff84846 --- /dev/null +++ b/overlays/keepassxc/database-open-dialog.patch | |||
@@ -0,0 +1,129 @@ | |||
1 | diff --git a/src/browser/BrowserService.cpp b/src/browser/BrowserService.cpp | ||
2 | index 60412b5a..c0497d91 100644 | ||
3 | --- a/src/browser/BrowserService.cpp | ||
4 | +++ b/src/browser/BrowserService.cpp | ||
5 | @@ -249,7 +249,7 @@ QJsonObject BrowserService::createNewGroup(const QString& groupName) | ||
6 | return result; | ||
7 | } | ||
8 | |||
9 | - auto dialogResult = MessageBox::warning(m_currentDatabaseWidget, | ||
10 | + auto dialogResult = MessageBox::warning(nullptr, | ||
11 | tr("KeePassXC - Create a new group"), | ||
12 | tr("A request for creating a new group \"%1\" has been received.\n" | ||
13 | "Do you want to create this group?\n") | ||
14 | @@ -422,7 +422,7 @@ QList<Entry*> BrowserService::confirmEntries(QList<Entry*>& entriesToConfirm, | ||
15 | |||
16 | m_dialogActive = true; | ||
17 | updateWindowState(); | ||
18 | - BrowserAccessControlDialog accessControlDialog(m_currentDatabaseWidget); | ||
19 | + BrowserAccessControlDialog accessControlDialog{}; | ||
20 | |||
21 | connect(m_currentDatabaseWidget, SIGNAL(databaseLockRequested()), &accessControlDialog, SLOT(reject())); | ||
22 | |||
23 | @@ -512,7 +512,7 @@ QString BrowserService::storeKey(const QString& key) | ||
24 | QString id; | ||
25 | |||
26 | do { | ||
27 | - QInputDialog keyDialog(m_currentDatabaseWidget); | ||
28 | + QInputDialog keyDialog{}; | ||
29 | connect(m_currentDatabaseWidget, SIGNAL(databaseLockRequested()), &keyDialog, SLOT(reject())); | ||
30 | keyDialog.setWindowTitle(tr("KeePassXC - New key association request")); | ||
31 | keyDialog.setLabelText(tr("You have received an association request for the following database:\n%1\n\n" | ||
32 | @@ -535,7 +535,7 @@ QString BrowserService::storeKey(const QString& key) | ||
33 | |||
34 | contains = db->metadata()->customData()->contains(CustomData::BrowserKeyPrefix + id); | ||
35 | if (contains) { | ||
36 | - dialogResult = MessageBox::warning(m_currentDatabaseWidget, | ||
37 | + dialogResult = MessageBox::warning(nullptr, | ||
38 | tr("KeePassXC - Overwrite existing key?"), | ||
39 | tr("A shared encryption key with the name \"%1\" " | ||
40 | "already exists.\nDo you want to overwrite it?") | ||
41 | @@ -595,7 +595,7 @@ QJsonObject BrowserService::showPasskeysRegisterPrompt(const QJsonObject& public | ||
42 | const auto existingEntries = getPasskeyEntriesWithUserHandle(rpId, userId, keyList); | ||
43 | |||
44 | raiseWindow(); | ||
45 | - BrowserPasskeysConfirmationDialog confirmDialog(m_currentDatabaseWidget); | ||
46 | + BrowserPasskeysConfirmationDialog confirmDialog{}; | ||
47 | confirmDialog.registerCredential(username, rpId, existingEntries, timeout); | ||
48 | |||
49 | auto dialogResult = confirmDialog.exec(); | ||
50 | @@ -612,7 +612,7 @@ QJsonObject BrowserService::showPasskeysRegisterPrompt(const QJsonObject& public | ||
51 | // If no entry is selected, show the import dialog for manual entry selection | ||
52 | auto selectedEntry = confirmDialog.getSelectedEntry(); | ||
53 | if (!selectedEntry) { | ||
54 | - PasskeyImporter passkeyImporter(m_currentDatabaseWidget); | ||
55 | + PasskeyImporter passkeyImporter{}; | ||
56 | const auto result = passkeyImporter.showImportDialog(db, | ||
57 | nullptr, | ||
58 | origin, | ||
59 | @@ -683,7 +683,7 @@ QJsonObject BrowserService::showPasskeysAuthenticationPrompt(const QJsonObject& | ||
60 | const auto timeout = publicKeyOptions["timeout"].toInt(); | ||
61 | |||
62 | raiseWindow(); | ||
63 | - BrowserPasskeysConfirmationDialog confirmDialog(m_currentDatabaseWidget); | ||
64 | + BrowserPasskeysConfirmationDialog confirmDialog{}; | ||
65 | confirmDialog.authenticateCredential(entries, rpId, timeout); | ||
66 | auto dialogResult = confirmDialog.exec(); | ||
67 | if (dialogResult == QDialog::Accepted) { | ||
68 | @@ -760,7 +760,7 @@ void BrowserService::addPasskeyToEntry(Entry* entry, | ||
69 | |||
70 | // Ask confirmation if entry already contains a Passkey | ||
71 | if (entry->hasPasskey()) { | ||
72 | - if (MessageBox::question(m_currentDatabaseWidget, | ||
73 | + if (MessageBox::question(nullptr, | ||
74 | tr("KeePassXC - Update passkey"), | ||
75 | tr("Entry already has a passkey.\nDo you want to overwrite the passkey in %1 - %2?") | ||
76 | .arg(entry->title(), passkeyUtils()->getUsernameFromEntry(entry)), | ||
77 | @@ -873,7 +873,7 @@ bool BrowserService::updateEntry(const EntryParameters& entryParameters, const Q | ||
78 | MessageBox::Button dialogResult = MessageBox::No; | ||
79 | if (!browserSettings()->alwaysAllowUpdate()) { | ||
80 | raiseWindow(); | ||
81 | - dialogResult = MessageBox::question(m_currentDatabaseWidget, | ||
82 | + dialogResult = MessageBox::question(nullptr, | ||
83 | tr("KeePassXC - Update Entry"), | ||
84 | tr("Do you want to update the information in %1 - %2?") | ||
85 | .arg(QUrl(entryParameters.siteUrl).host(), username), | ||
86 | @@ -909,7 +909,7 @@ bool BrowserService::deleteEntry(const QString& uuid) | ||
87 | return false; | ||
88 | } | ||
89 | |||
90 | - auto dialogResult = MessageBox::warning(m_currentDatabaseWidget, | ||
91 | + auto dialogResult = MessageBox::warning(nullptr, | ||
92 | tr("KeePassXC - Delete entry"), | ||
93 | tr("A request for deleting entry \"%1\" has been received.\n" | ||
94 | "Do you want to delete the entry?\n") | ||
95 | @@ -1536,7 +1536,7 @@ QSharedPointer<Database> BrowserService::selectedDatabase() | ||
96 | } | ||
97 | } | ||
98 | |||
99 | - BrowserEntrySaveDialog browserEntrySaveDialog(m_currentDatabaseWidget); | ||
100 | + BrowserEntrySaveDialog browserEntrySaveDialog{}; | ||
101 | int openDatabaseCount = browserEntrySaveDialog.setItems(databaseWidgets, m_currentDatabaseWidget); | ||
102 | if (openDatabaseCount > 1) { | ||
103 | int res = browserEntrySaveDialog.exec(); | ||
104 | diff --git a/src/fdosecrets/objects/Prompt.cpp b/src/fdosecrets/objects/Prompt.cpp | ||
105 | index e89cd499..347c98b8 100644 | ||
106 | --- a/src/fdosecrets/objects/Prompt.cpp | ||
107 | +++ b/src/fdosecrets/objects/Prompt.cpp | ||
108 | @@ -313,7 +313,7 @@ namespace FdoSecrets | ||
109 | if (!entries.isEmpty()) { | ||
110 | QString app = tr("%1 (PID: %2)").arg(client->name()).arg(client->pid()); | ||
111 | auto ac = new AccessControlDialog( | ||
112 | - findWindow(m_windowId), entries, app, client->processInfo(), AuthOption::Remember); | ||
113 | + nullptr, entries, app, client->processInfo(), AuthOption::Remember); | ||
114 | connect(ac, &AccessControlDialog::finished, this, &UnlockPrompt::itemUnlockFinished); | ||
115 | connect(ac, &AccessControlDialog::finished, ac, &AccessControlDialog::deleteLater); | ||
116 | ac->open(); | ||
117 | diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp | ||
118 | index 805d4eab..4836199e 100644 | ||
119 | --- a/src/gui/DatabaseTabWidget.cpp | ||
120 | +++ b/src/gui/DatabaseTabWidget.cpp | ||
121 | @@ -41,7 +41,7 @@ DatabaseTabWidget::DatabaseTabWidget(QWidget* parent) | ||
122 | : QTabWidget(parent) | ||
123 | , m_dbWidgetStateSync(new DatabaseWidgetStateSync(this)) | ||
124 | , m_dbWidgetPendingLock(nullptr) | ||
125 | - , m_databaseOpenDialog(new DatabaseOpenDialog(this)) | ||
126 | + , m_databaseOpenDialog(new DatabaseOpenDialog()) | ||
127 | , m_databaseOpenInProgress(false) | ||
128 | { | ||
129 | auto* tabBar = new QTabBar(this); | ||
diff --git a/overlays/keepassxc/default.nix b/overlays/keepassxc/default.nix new file mode 100644 index 00000000..46b3a459 --- /dev/null +++ b/overlays/keepassxc/default.nix | |||
@@ -0,0 +1,8 @@ | |||
1 | { final, prev, ... }: | ||
2 | { | ||
3 | keepassxc = prev.keepassxc.overrideAttrs (oldAttrs: { | ||
4 | patches = (oldAttrs.patches or []) ++ prev.lib.optional (prev.lib.versionAtLeast oldAttrs.version "2.7.9") [ | ||
5 | ./database-open-dialog.patch | ||
6 | ]; | ||
7 | }); | ||
8 | } | ||
diff --git a/overlays/mako.nix b/overlays/mako.nix new file mode 100644 index 00000000..1c1464fb --- /dev/null +++ b/overlays/mako.nix | |||
@@ -0,0 +1,5 @@ | |||
1 | { final, prev, sources, ... }: { | ||
2 | mako = prev.mako.overrideAttrs (oldAttrs: { | ||
3 | inherit (sources.mako) version src; | ||
4 | }); | ||
5 | } | ||
diff --git a/overlays/matrix-synapse.nix b/overlays/matrix-synapse.nix deleted file mode 100644 index 59b2c6da..00000000 --- a/overlays/matrix-synapse.nix +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | { final, prev, ... }: | ||
2 | { | ||
3 | matrix-synapse-unwrapped = prev.matrix-synapse-unwrapped.overridePythonAttrs { doCheck = false; }; | ||
4 | } | ||
diff --git a/overlays/swayosd/default.nix b/overlays/swayosd/default.nix new file mode 100644 index 00000000..28c8f1b9 --- /dev/null +++ b/overlays/swayosd/default.nix | |||
@@ -0,0 +1,30 @@ | |||
1 | { final, prev, sources, ... }: { | ||
2 | swayosd = prev.swayosd.overrideAttrs (oldAttrs: rec { | ||
3 | inherit (sources.swayosd) version src; | ||
4 | cargoDeps = prev.rustPlatform.fetchCargoTarball { | ||
5 | inherit (oldAttrs) pname; | ||
6 | inherit version src; | ||
7 | hash = "sha256-Anrk8p76HKZcNavYdi9l1oYahduLrb7Lf7knQK7Hy5E="; | ||
8 | }; | ||
9 | nativeBuildInputs = with final; [ | ||
10 | wrapGAppsHook4 | ||
11 | pkg-config | ||
12 | meson | ||
13 | rustc | ||
14 | cargo | ||
15 | ninja | ||
16 | rustPlatform.cargoSetupHook | ||
17 | ]; | ||
18 | buildInputs = with final; [ | ||
19 | gtk4-layer-shell | ||
20 | libevdev | ||
21 | libinput | ||
22 | libpulseaudio | ||
23 | udev | ||
24 | sassc | ||
25 | ]; | ||
26 | patches = (oldAttrs.patches or []) ++ [ | ||
27 | ./exponential.patch | ||
28 | ]; | ||
29 | }); | ||
30 | } | ||
diff --git a/overlays/swayosd/exponential.patch b/overlays/swayosd/exponential.patch new file mode 100644 index 00000000..eb90d739 --- /dev/null +++ b/overlays/swayosd/exponential.patch | |||
@@ -0,0 +1,57 @@ | |||
1 | diff --git a/src/brightness_backend/brightnessctl.rs b/src/brightness_backend/brightnessctl.rs | ||
2 | index ccb0e11..740fdb6 100644 | ||
3 | --- a/src/brightness_backend/brightnessctl.rs | ||
4 | +++ b/src/brightness_backend/brightnessctl.rs | ||
5 | @@ -107,10 +107,21 @@ impl VirtualDevice { | ||
6 | } | ||
7 | } | ||
8 | |||
9 | - fn set_percent(&mut self, mut val: u32) -> anyhow::Result<()> { | ||
10 | - val = val.clamp(0, 100); | ||
11 | - self.current = self.max.map(|max| val * max / 100); | ||
12 | - let _: String = self.run(("set", &*format!("{val}%")))?; | ||
13 | + fn val_to_percent(&mut self, val: u32) -> u32 { | ||
14 | + return ((val as f64 / self.get_max() as f64).powf(0.25) * 100_f64).round() as u32; | ||
15 | + } | ||
16 | + fn percent_to_val(&mut self, perc: u32) -> u32 { | ||
17 | + return ((perc as f64 / 100_f64).powf(4_f64) * self.get_max() as f64).round() as u32; | ||
18 | + } | ||
19 | + | ||
20 | + fn set_percent(&mut self, val: u32) -> anyhow::Result<()> { | ||
21 | + let new = self.percent_to_val(val); | ||
22 | + self.set_val(new) | ||
23 | + } | ||
24 | + fn set_val(&mut self, val: u32) -> anyhow::Result<()> { | ||
25 | + let curr = val.clamp(0, self.get_max()); | ||
26 | + self.current = Some(curr); | ||
27 | + let _: String = self.run(("set", &*format!("{curr}")))?; | ||
28 | Ok(()) | ||
29 | } | ||
30 | } | ||
31 | @@ -134,20 +145,18 @@ impl BrightnessBackend for BrightnessCtl { | ||
32 | |||
33 | fn lower(&mut self, by: u32) -> anyhow::Result<()> { | ||
34 | let curr = self.get_current(); | ||
35 | - let max = self.get_max(); | ||
36 | - | ||
37 | - let curr = curr * 100 / max; | ||
38 | + let mut new = self.device.val_to_percent(curr).saturating_sub(by); | ||
39 | + new = self.device.percent_to_val(new).min(curr.saturating_sub(1)); | ||
40 | |||
41 | - self.device.set_percent(curr.saturating_sub(by)) | ||
42 | + self.device.set_val(new) | ||
43 | } | ||
44 | |||
45 | fn raise(&mut self, by: u32) -> anyhow::Result<()> { | ||
46 | let curr = self.get_current(); | ||
47 | - let max = self.get_max(); | ||
48 | - | ||
49 | - let curr = curr * 100 / max; | ||
50 | + let mut new = self.device.val_to_percent(curr) + by; | ||
51 | + new = self.device.percent_to_val(new).max(curr + 1); | ||
52 | |||
53 | - self.device.set_percent(curr + by) | ||
54 | + self.device.set_val(new) | ||
55 | } | ||
56 | |||
57 | fn set(&mut self, val: u32) -> anyhow::Result<()> { | ||
diff --git a/overlays/worktime/worktime/__main__.py b/overlays/worktime/worktime/__main__.py index 362c8da4..4eee5dc2 100755 --- a/overlays/worktime/worktime/__main__.py +++ b/overlays/worktime/worktime/__main__.py | |||
@@ -23,7 +23,7 @@ import argparse | |||
23 | from copy import deepcopy | 23 | from copy import deepcopy |
24 | 24 | ||
25 | import sys | 25 | import sys |
26 | from sys import stderr | 26 | from sys import stderr, stdout |
27 | 27 | ||
28 | from tabulate import tabulate | 28 | from tabulate import tabulate |
29 | 29 | ||
@@ -38,6 +38,7 @@ from collections import defaultdict | |||
38 | 38 | ||
39 | import jsonpickle | 39 | import jsonpickle |
40 | from hashlib import blake2s | 40 | from hashlib import blake2s |
41 | import json | ||
41 | 42 | ||
42 | class TogglAPISection(Enum): | 43 | class TogglAPISection(Enum): |
43 | TOGGL = '/api/v9' | 44 | TOGGL = '/api/v9' |
@@ -223,6 +224,7 @@ class Worktime(object): | |||
223 | leave_budget = dict() | 224 | leave_budget = dict() |
224 | time_per_day = None | 225 | time_per_day = None |
225 | workdays = None | 226 | workdays = None |
227 | pull_forward = dict() | ||
226 | 228 | ||
227 | @staticmethod | 229 | @staticmethod |
228 | @cache | 230 | @cache |
@@ -390,7 +392,7 @@ class Worktime(object): | |||
390 | if e.errno != 2: | 392 | if e.errno != 2: |
391 | raise e | 393 | raise e |
392 | 394 | ||
393 | pull_forward = dict() | 395 | self.time_per_day = lambda day: timedelta(hours = hours_per_week(day)) / len(self.workdays) - (holidays[day] if day in holidays else timedelta()) |
394 | 396 | ||
395 | start_day = self.start_date.date() | 397 | start_day = self.start_date.date() |
396 | end_day = self.end_date.date() | 398 | end_day = self.end_date.date() |
@@ -418,21 +420,19 @@ class Worktime(object): | |||
418 | if not d == datetime.strptime(c, date_format).replace(tzinfo=tzlocal()).date(): break | 420 | if not d == datetime.strptime(c, date_format).replace(tzinfo=tzlocal()).date(): break |
419 | else: | 421 | else: |
420 | if d >= self.end_date.date(): | 422 | if d >= self.end_date.date(): |
421 | pull_forward[d] = min(timedelta(hours = float(hours)), self.time_per_day(d) - (holidays[d] if d in holidays else timedelta())) | 423 | self.pull_forward[d] = min(timedelta(hours = float(hours)), self.time_per_day(d) - (holidays[d] if d in holidays else timedelta())) |
422 | except IOError as e: | 424 | except IOError as e: |
423 | if e.errno != 2: | 425 | if e.errno != 2: |
424 | raise e | 426 | raise e |
425 | 427 | ||
426 | self.days_to_work = dict() | 428 | self.days_to_work = dict() |
427 | 429 | ||
428 | if pull_forward: | 430 | if self.pull_forward: |
429 | end_day = max(end_day, max(list(pull_forward))) | 431 | end_day = max(end_day, max(list(self.pull_forward))) |
430 | 432 | ||
431 | for day in [start_day + timedelta(days = x) for x in range(0, (end_day - start_day).days + 1)]: | 433 | for day in [start_day + timedelta(days = x) for x in range(0, (end_day - start_day).days + 1)]: |
432 | if day.isoweekday() in self.workdays: | 434 | if day.isoweekday() in self.workdays: |
433 | time_to_work = self.time_per_day(day) | 435 | time_to_work = self.time_per_day(day) |
434 | if day in holidays.keys(): | ||
435 | time_to_work -= holidays[day] | ||
436 | if time_to_work > timedelta(): | 436 | if time_to_work > timedelta(): |
437 | self.days_to_work[day] = time_to_work | 437 | self.days_to_work[day] = time_to_work |
438 | 438 | ||
@@ -470,17 +470,17 @@ class Worktime(object): | |||
470 | self.extra_days_to_work[self.now.date()] = timedelta() | 470 | self.extra_days_to_work[self.now.date()] = timedelta() |
471 | 471 | ||
472 | self.time_to_work = sum([self.days_to_work[day] for day in self.days_to_work.keys() if day <= self.end_date.date()], timedelta()) | 472 | self.time_to_work = sum([self.days_to_work[day] for day in self.days_to_work.keys() if day <= self.end_date.date()], timedelta()) |
473 | for day in [d for d in list(pull_forward) if d > self.end_date.date()]: | 473 | for day in [d for d in list(self.pull_forward) if d > self.end_date.date()]: |
474 | days_forward = set([d for d in self.days_to_work.keys() if d >= self.end_date.date() and d < day and (not d in pull_forward or d == self.end_date.date())]) | 474 | days_forward = set([d for d in self.days_to_work.keys() if d >= self.end_date.date() and d < day and (not d in self.pull_forward or d == self.end_date.date())]) |
475 | extra_days_forward = set([d for d in self.extra_days_to_work.keys() if d >= self.end_date.date() and d < day and (not d in pull_forward or d == self.end_date.date())]) | 475 | extra_days_forward = set([d for d in self.extra_days_to_work.keys() if d >= self.end_date.date() and d < day and (not d in self.pull_forward or d == self.end_date.date())]) |
476 | days_forward = days_forward.union(extra_days_forward) | 476 | days_forward = days_forward.union(extra_days_forward) |
477 | 477 | ||
478 | extra_day_time_left = timedelta() | 478 | extra_day_time_left = timedelta() |
479 | for extra_day in extra_days_forward: | 479 | for extra_day in extra_days_forward: |
480 | day_time = max(timedelta(), self.time_per_day(extra_day) - self.extra_days_to_work[extra_day]) | 480 | day_time = max(timedelta(), self.time_per_day(extra_day) - self.extra_days_to_work[extra_day]) |
481 | extra_day_time_left += day_time | 481 | extra_day_time_left += day_time |
482 | extra_day_time = min(extra_day_time_left, pull_forward[day]) | 482 | extra_day_time = min(extra_day_time_left, self.pull_forward[day]) |
483 | time_forward = pull_forward[day] - extra_day_time | 483 | time_forward = self.pull_forward[day] - extra_day_time |
484 | if extra_day_time_left > timedelta(): | 484 | if extra_day_time_left > timedelta(): |
485 | for extra_day in extra_days_forward: | 485 | for extra_day in extra_days_forward: |
486 | day_time = max(timedelta(), self.time_per_day(extra_day) - self.extra_days_to_work[extra_day]) | 486 | day_time = max(timedelta(), self.time_per_day(extra_day) - self.extra_days_to_work[extra_day]) |
@@ -518,7 +518,14 @@ def format_days(worktime, days, date_format=None): | |||
518 | return ', '.join(map(lambda group: ','.join(map(format_group, group)), groups)) | 518 | return ', '.join(map(lambda group: ','.join(map(format_group, group)), groups)) |
519 | 519 | ||
520 | 520 | ||
521 | def worktime(**args): | 521 | def tooltip_timedelta(td): |
522 | if td < timedelta(seconds = 0): | ||
523 | return "-" + tooltip_timedelta(-td) | ||
524 | mm, ss = divmod(td.total_seconds(), 60) | ||
525 | hh, mm = divmod(mm, 60) | ||
526 | return "%d:%02d:%02d" % (hh, mm, ss) | ||
527 | |||
528 | def worktime(pull_forward_cutoff, waybar, **args): | ||
522 | worktime = Worktime(**args) | 529 | worktime = Worktime(**args) |
523 | 530 | ||
524 | def format_worktime(worktime): | 531 | def format_worktime(worktime): |
@@ -557,24 +564,41 @@ def worktime(**args): | |||
557 | return f"{indicator}{difference_string}" | 564 | return f"{indicator}{difference_string}" |
558 | else: | 565 | else: |
559 | difference_string = difference_string(total_minutes_difference * timedelta(minutes = 1)) | 566 | difference_string = difference_string(total_minutes_difference * timedelta(minutes = 1)) |
560 | if worktime.now_is_workday: | 567 | return difference_string |
561 | return difference_string | 568 | |
562 | else: | 569 | out_class = "running" if worktime.running_entry else "stopped" |
563 | return f"({difference_string})" | 570 | difference = worktime.time_to_work - worktime.time_worked |
564 | 571 | if worktime.running_entry and -min(timedelta(milliseconds=0), difference) > sum(worktime.pull_forward.values(), start=timedelta(milliseconds=0)) or not worktime.running_entry and max(timedelta(milliseconds=0), difference) > worktime.time_per_day(worktime.now.date()) and worktime.now_is_workday: | |
565 | if worktime.time_pulled_forward >= timedelta(minutes = 15): | 572 | out_class = "over" |
573 | pull_forward_sum = sum(worktime.pull_forward.values(), start=timedelta(milliseconds=0)) | ||
574 | if pull_forward_sum >= min(pull_forward_cutoff, timedelta(seconds = 1)): | ||
566 | worktime_no_pulled_forward = deepcopy(worktime) | 575 | worktime_no_pulled_forward = deepcopy(worktime) |
567 | worktime_no_pulled_forward.time_to_work -= worktime_no_pulled_forward.time_pulled_forward | 576 | worktime_no_pulled_forward.time_to_work -= worktime_no_pulled_forward.time_pulled_forward |
568 | worktime_no_pulled_forward.time_pulled_forward = timedelta() | 577 | worktime_no_pulled_forward.time_pulled_forward = timedelta() |
578 | worktime_no_pulled_forward.pull_forward = dict() | ||
579 | worktime.time_to_work += pull_forward_sum | ||
569 | 580 | ||
570 | difference_string = format_worktime(worktime) | ||
571 | difference_string_no_pulled_forward = format_worktime(worktime_no_pulled_forward) | 581 | difference_string_no_pulled_forward = format_worktime(worktime_no_pulled_forward) |
572 | 582 | ||
573 | print(f"{difference_string_no_pulled_forward}…{difference_string}") | 583 | tooltip = tooltip_timedelta(worktime_no_pulled_forward.time_to_work - worktime_no_pulled_forward.time_worked) + "…" + tooltip_timedelta(difference + pull_forward_sum) |
584 | if pull_forward_sum >= pull_forward_cutoff: | ||
585 | out_text = f"{difference_string_no_pulled_forward}…{format_worktime(worktime)}" | ||
586 | else: | ||
587 | out_text = format_worktime(worktime) | ||
588 | else: | ||
589 | tooltip = tooltip_timedelta(difference) | ||
590 | out_text = format_worktime(worktime) | ||
591 | |||
592 | if waybar: | ||
593 | json.dump({"text": out_text, "class": out_class, "tooltip": tooltip}, stdout) | ||
574 | else: | 594 | else: |
575 | print(format_worktime(worktime)) | 595 | print(out_text) |
576 | 596 | ||
577 | def time_worked(now, **args): | 597 | def pull_forward(**args): |
598 | worktime = Worktime(**args) | ||
599 | print(tooltip_timedelta(sum(worktime.pull_forward.values(), start=timedelta(milliseconds=0)))) | ||
600 | |||
601 | def time_worked(now, waybar, **args): | ||
578 | then = now.replace(hour = 0, minute = 0, second = 0, microsecond = 0) | 602 | then = now.replace(hour = 0, minute = 0, second = 0, microsecond = 0) |
579 | if now.time() == time(): | 603 | if now.time() == time(): |
580 | now = now + timedelta(days = 1) | 604 | now = now + timedelta(days = 1) |
@@ -584,33 +608,62 @@ def time_worked(now, **args): | |||
584 | 608 | ||
585 | worked = now.time_worked - then.time_worked | 609 | worked = now.time_worked - then.time_worked |
586 | 610 | ||
611 | out_text = None | ||
612 | out_class = "running" if now.running_entry else "stopped" | ||
613 | tooltip = tooltip_timedelta(worked) | ||
614 | target_time = max(then.time_per_day(then.now.date()), now.time_per_day(now.now.date())) if then.time_per_day(then.now.date()) and now.time_per_day(now.now.date()) else (then.time_per_day(then.now.date()) if then.time_per_day(then.now.date()) else now.time_per_day(now.now.date())); | ||
615 | difference = target_time - worked | ||
616 | difference_pull_forward = difference + now.time_pulled_forward | ||
617 | if now.running_entry and difference_pull_forward < timedelta(seconds=0): | ||
618 | out_class = "over" | ||
587 | if args['do_round']: | 619 | if args['do_round']: |
588 | total_minutes_difference = 5 * ceil(worked / timedelta(minutes = 5)) | 620 | total_minutes_difference = 5 * ceil(worked / timedelta(minutes = 5)) |
589 | (hours_difference, minutes_difference) = divmod(abs(total_minutes_difference), 60) | 621 | (hours_difference, minutes_difference) = divmod(abs(total_minutes_difference), 60) |
590 | sign = '' if total_minutes_difference >= 0 else '-' | 622 | sign = '' if total_minutes_difference >= 0 else '-' |
591 | |||
592 | difference_string = f"{sign}" | ||
593 | if hours_difference != 0: | ||
594 | difference_string += f"{hours_difference}h" | ||
595 | if hours_difference == 0 or minutes_difference != 0: | ||
596 | difference_string += f"{minutes_difference}m" | ||
597 | |||
598 | clockout_time = None | ||
599 | clockout_difference = None | ||
600 | if then.now_is_workday or now.now_is_workday: | ||
601 | target_time = max(then.time_per_day(then.now.date()), now.time_per_day(now.now.date())) if then.time_per_day(then.now.date()) and now.time_per_day(now.now.date()) else (then.time_per_day(then.now.date()) if then.time_per_day(then.now.date()) else now.time_per_day(now.now.date())); | ||
602 | difference = target_time - worked | ||
603 | clockout_difference = 5 * ceil(difference / timedelta(minutes = 5)) | ||
604 | clockout_time = now.now + difference | ||
605 | clockout_time += (5 - clockout_time.minute % 5) * timedelta(minutes = 1) | ||
606 | clockout_time = clockout_time.replace(second = 0, microsecond = 0) | ||
607 | 623 | ||
608 | if now.running_entry and clockout_time and clockout_difference >= 0: | 624 | difference_string = f"{sign}" |
609 | print(f"{difference_string}/{clockout_time:%H:%M}") | 625 | if hours_difference != 0: |
610 | else: | 626 | difference_string += f"{hours_difference}h" |
611 | print(difference_string) | 627 | if hours_difference == 0 or minutes_difference != 0: |
628 | difference_string += f"{minutes_difference}m" | ||
629 | |||
630 | def round_clockout_time(difference): | ||
631 | clockout_time = None | ||
632 | clockout_difference = None | ||
633 | exact_clockout_time = None | ||
634 | if then.now_is_workday or now.now_is_workday: | ||
635 | clockout_difference = 5 * ceil(difference / timedelta(minutes = 5)) | ||
636 | clockout_time = now.now + difference | ||
637 | exact_clockout_time = clockout_time | ||
638 | clockout_time += (5 - clockout_time.minute % 5) * timedelta(minutes = 1) | ||
639 | clockout_time = clockout_time.replace(second = 0, microsecond = 0) | ||
640 | |||
641 | return clockout_time, exact_clockout_time, clockout_difference | ||
642 | |||
643 | clockout_time, exact_clockout_time, clockout_difference = round_clockout_time(difference) | ||
644 | clockout_time_pull_forward, exact_clockout_time_pull_forward, clockout_difference_pull_forward = round_clockout_time(difference_pull_forward) | ||
645 | clockout_pull_forward_sum, exact_clockout_pull_forward_sum, _ = round_clockout_time(now.time_to_work - now.time_worked + sum(now.pull_forward.values(), start=timedelta(milliseconds=0))) | ||
646 | |||
647 | if now.running_entry and clockout_time and (clockout_difference >= 0 or clockout_difference_pull_forward >= 0): | ||
648 | out_text = f"{difference_string}/{clockout_time:%H:%M}" | ||
649 | tooltip = f"{tooltip_timedelta(worked)}/{exact_clockout_time:%H:%M:%S}" | ||
650 | |||
651 | if clockout_pull_forward_sum >= clockout_time_pull_forward and clockout_time_pull_forward != clockout_time: | ||
652 | out_text += f"…{clockout_time_pull_forward:%H:%M}" | ||
653 | if exact_clockout_pull_forward_sum >= exact_clockout_time_pull_forward and exact_clockout_time_pull_forward != exact_clockout_time: | ||
654 | tooltip += f"…{exact_clockout_time_pull_forward:%H:%M:%S}" | ||
655 | else: | ||
656 | out_text = difference_string | ||
612 | else: | 657 | else: |
613 | print(worked) | 658 | out_text = str(worked) |
659 | |||
660 | if not now.now_is_workday: | ||
661 | out_text = f'({out_text})' | ||
662 | |||
663 | if waybar: | ||
664 | json.dump({"text": out_text, "class": out_class, "tooltip": tooltip}, stdout) | ||
665 | else: | ||
666 | print(out_text) | ||
614 | 667 | ||
615 | def diff(now, **args): | 668 | def diff(now, **args): |
616 | now = now.replace(hour = 0, minute = 0, second = 0, microsecond = 0) | 669 | now = now.replace(hour = 0, minute = 0, second = 0, microsecond = 0) |
@@ -798,6 +851,38 @@ def classification(classification_name, table, table_format, **args): | |||
798 | def main(): | 851 | def main(): |
799 | def isotime(s): | 852 | def isotime(s): |
800 | return datetime.fromisoformat(s).replace(tzinfo=tzlocal()) | 853 | return datetime.fromisoformat(s).replace(tzinfo=tzlocal()) |
854 | def duration_minutes(s): | ||
855 | return timedelta(minutes = float(s)) | ||
856 | |||
857 | def set_default_subparser(self, name, args=None, positional_args=0): | ||
858 | """default subparser selection. Call after setup, just before parse_args() | ||
859 | name: is the name of the subparser to call by default | ||
860 | args: if set is the argument list handed to parse_args() | ||
861 | |||
862 | , tested with 2.7, 3.2, 3.3, 3.4 | ||
863 | it works with 2.6 assuming argparse is installed | ||
864 | """ | ||
865 | subparser_found = False | ||
866 | for arg in sys.argv[1:]: | ||
867 | if arg in ['-h', '--help']: # global help if no subparser | ||
868 | break | ||
869 | else: | ||
870 | for x in self._subparsers._actions: | ||
871 | if not isinstance(x, argparse._SubParsersAction): | ||
872 | continue | ||
873 | for sp_name in x._name_parser_map.keys(): | ||
874 | if sp_name in sys.argv[1:]: | ||
875 | subparser_found = True | ||
876 | if not subparser_found: | ||
877 | # insert default in last position before global positional | ||
878 | # arguments, this implies no global options are specified after | ||
879 | # first positional argument | ||
880 | if args is None: | ||
881 | sys.argv.insert(len(sys.argv) - positional_args, name) | ||
882 | else: | ||
883 | args.insert(len(args) - positional_args, name) | ||
884 | |||
885 | argparse.ArgumentParser.set_default_subparser = set_default_subparser | ||
801 | 886 | ||
802 | config = Worktime.config() | 887 | config = Worktime.config() |
803 | 888 | ||
@@ -807,9 +892,13 @@ def main(): | |||
807 | parser.add_argument('--no-running', dest = 'include_running', action = 'store_false') | 892 | parser.add_argument('--no-running', dest = 'include_running', action = 'store_false') |
808 | parser.add_argument('--no-force-day-to-work', dest = 'force_day_to_work', action = 'store_false') | 893 | parser.add_argument('--no-force-day-to-work', dest = 'force_day_to_work', action = 'store_false') |
809 | subparsers = parser.add_subparsers(help = 'Subcommands') | 894 | subparsers = parser.add_subparsers(help = 'Subcommands') |
810 | parser.set_defaults(cmd = worktime) | 895 | worktime_parser = subparsers.add_parser('time_worked', aliases = ['time', 'worked']) |
811 | time_worked_parser = subparsers.add_parser('time_worked', aliases = ['time', 'worked', 'today']) | 896 | worktime_parser.add_argument('--pull-forward-cutoff', dest = 'pull_forward_cutoff', metavar = 'MINUTES', type = duration_minutes, default = timedelta(minutes = 15)) |
897 | worktime_parser.add_argument('--waybar', action='store_true') | ||
898 | worktime_parser.set_defaults(cmd = worktime) | ||
899 | time_worked_parser = subparsers.add_parser('today') | ||
812 | time_worked_parser.add_argument('--no-round', dest = 'do_round', action = 'store_false') | 900 | time_worked_parser.add_argument('--no-round', dest = 'do_round', action = 'store_false') |
901 | time_worked_parser.add_argument('--waybar', action='store_true') | ||
813 | time_worked_parser.set_defaults(cmd = time_worked) | 902 | time_worked_parser.set_defaults(cmd = time_worked) |
814 | diff_parser = subparsers.add_parser('diff') | 903 | diff_parser = subparsers.add_parser('diff') |
815 | diff_parser.set_defaults(cmd = diff) | 904 | diff_parser.set_defaults(cmd = diff) |
@@ -827,6 +916,9 @@ def main(): | |||
827 | classification_parser.add_argument('--table', action = 'store_true') | 916 | classification_parser.add_argument('--table', action = 'store_true') |
828 | classification_parser.add_argument('--table-format', dest='table_format', type=str, default='fancy_grid') | 917 | classification_parser.add_argument('--table-format', dest='table_format', type=str, default='fancy_grid') |
829 | classification_parser.set_defaults(cmd = partial(classification, classification_name=classification_name)) | 918 | classification_parser.set_defaults(cmd = partial(classification, classification_name=classification_name)) |
919 | pull_forward_parser = subparsers.add_parser('pull-forward') | ||
920 | pull_forward_parser.set_defaults(cmd = pull_forward) | ||
921 | parser.set_default_subparser('time_worked') | ||
830 | args = parser.parse_args() | 922 | args = parser.parse_args() |
831 | 923 | ||
832 | args.cmd(**vars(args)) | 924 | args.cmd(**vars(args)) |
diff --git a/system-profiles/core/default.nix b/system-profiles/core/default.nix index d60507b0..b85aea4e 100644 --- a/system-profiles/core/default.nix +++ b/system-profiles/core/default.nix | |||
@@ -181,7 +181,7 @@ in { | |||
181 | programs.ssh.internallyManaged = mkForce true; | 181 | programs.ssh.internallyManaged = mkForce true; |
182 | } | 182 | } |
183 | ]; | 183 | ]; |
184 | extraSpecialArgs = { inherit flake flakeInputs path; }; | 184 | extraSpecialArgs = { inherit flake flakeInputs path; hostConfig = config; }; |
185 | }; | 185 | }; |
186 | 186 | ||
187 | sops = mkIf hasSops { | 187 | sops = mkIf hasSops { |
diff --git a/system-profiles/niri-flake.nix b/system-profiles/niri-flake.nix new file mode 100644 index 00000000..b28d51ff --- /dev/null +++ b/system-profiles/niri-flake.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | { ... }: | ||
2 | { | ||
3 | config.niri-flake.cache.enable = false; | ||
4 | } | ||
diff --git a/system-profiles/niri-unstable.nix b/system-profiles/niri-unstable.nix new file mode 100644 index 00000000..3a8b393d --- /dev/null +++ b/system-profiles/niri-unstable.nix | |||
@@ -0,0 +1,11 @@ | |||
1 | { config, pkgs, lib, ... }: | ||
2 | { | ||
3 | config = { | ||
4 | programs.niri.package = lib.mkDefault pkgs.niri-unstable; | ||
5 | home-manager.sharedModules = [ | ||
6 | { | ||
7 | programs.niri.package = lib.mkDefault config.programs.niri.package; | ||
8 | } | ||
9 | ]; | ||
10 | }; | ||
11 | } | ||
diff --git a/users/gkleen/default.nix b/users/gkleen/default.nix index 4ddf4be3..5cc32521 100644 --- a/users/gkleen/default.nix +++ b/users/gkleen/default.nix | |||
@@ -29,9 +29,39 @@ | |||
29 | userName = "Gregor Kleen"; | 29 | userName = "Gregor Kleen"; |
30 | delta.enable = true; | 30 | delta.enable = true; |
31 | extraConfig = { | 31 | extraConfig = { |
32 | pull.rebase = false; | 32 | core.excludesfile = toString ./gitignore; |
33 | pull.rebase = true; | ||
33 | submodule.recurse = true; | 34 | submodule.recurse = true; |
34 | init.defaultBranch = "main"; | 35 | init.defaultBranch = "main"; |
36 | column.ui = "auto"; | ||
37 | branch.sort = "-committerdate"; | ||
38 | tag.sort = "version:refname"; | ||
39 | diff = { | ||
40 | algorithm = "histogram"; | ||
41 | colorMoved = "plain"; | ||
42 | mnemonicPrefix = true; | ||
43 | renames = true; | ||
44 | }; | ||
45 | push = { | ||
46 | default = "simple"; | ||
47 | autoSetupRemote = true; | ||
48 | followTags = true; | ||
49 | }; | ||
50 | fetch = { | ||
51 | prune = true; | ||
52 | pruneTags = true; | ||
53 | all = true; | ||
54 | }; | ||
55 | rerere = { | ||
56 | enabled = true; | ||
57 | autoupdate = true; | ||
58 | }; | ||
59 | rebase = { | ||
60 | autoSquash = true; | ||
61 | autoStash = true; | ||
62 | updateRefs = true; | ||
63 | }; | ||
64 | merge.conflictstyle = "zdiff3"; | ||
35 | }; | 65 | }; |
36 | }; | 66 | }; |
37 | 67 | ||
diff --git a/users/gkleen/gitignore b/users/gkleen/gitignore new file mode 100644 index 00000000..f7082b20 --- /dev/null +++ b/users/gkleen/gitignore | |||
@@ -0,0 +1,2 @@ | |||
1 | **/#*# | ||
2 | **/.#* | ||