dot

vizie's NixOS desktop: Hyprland, CachyOS kernel and gaming tweaks

76 lines3336 bytesLua
1-- Run once when Hyprland starts. Loaded from the hyprland.lua that Home Manager
2-- writes (modules/home/desktop.nix has the rest of the Hyprland config).
3
4hl.on("hyprland.start", function()
5 -- Wallpaper, bar, notifications, the control centre, tray helpers, the
6 -- clipboard bridge and the polkit agent are systemd user services now
7 -- (modules/home/services.nix in the dot repo): uwsm starts them with
8 -- graphical-session.target, restarts them if they crash, and
9 -- `systemctl --user status <name>` / `journalctl --user -u <name>` show them.
10
11 -- Apps opened at login, in their usual places (scripts/autostart-apps starts
12 -- them, from autostart-apps.service). These placement rules are switched off
13 -- again after two minutes, so opening the same apps by hand later behaves like
14 -- any other window.
15 local startup_rules = {
16 hl.window_rule({
17 name = "startup-signal",
18 match = { class = "^signal$" },
19 workspace = "3 silent",
20 }),
21 hl.window_rule({
22 name = "startup-discord",
23 match = { class = "^discord$" },
24 workspace = "3 silent",
25 }),
26 hl.window_rule({
27 name = "startup-faugus",
28 match = { class = "^io\\.github\\.Faugus\\.faugus-launcher$" },
29 workspace = "1 silent",
30 float = true,
31 size = { 430, 610 },
32 move = { 1901, 333 },
33 }),
34 }
35 hl.timer(function()
36 for _, rule in ipairs(startup_rules) do
37 rule:set_enabled(false)
38 end
39 end, { timeout = 120000, type = "oneshot" })
40
41 -- WowUp can't start hidden, so the window it opens at login is sent to a hidden
42 -- workspace and closed again, which leaves it in the tray. Its class is
43 -- "wowupcf" on NixOS ("WowUpCf" on CachyOS), so both are matched. Before that
44 -- window it can open Overwolf's consent popup (same class, titled "WowUpCf"),
45 -- which is hidden and closed the same way. The rule must not outlive the main window:
46 -- it is dropped as soon as that has opened (or after a minute if none came),
47 -- so opening WowUp yourself right after login lands on your workspace like any
48 -- other window.
49 local wowup_rule = hl.window_rule({
50 name = "startup-wowup",
51 match = { class = "(?i)^wowupcf$" },
52 workspace = "special:autostart silent",
53 })
54 local wowup_pending = true
55 local function wowup_done()
56 wowup_pending = false
57 wowup_rule:set_enabled(false)
58 end
59 hl.on("window.open", function(window)
60 if wowup_pending and window.class:lower() == "wowupcf" then
61 if window.title ~= "" and window.title ~= "WowUpCf" then
62 wowup_done()
63 end
64 -- closing it from inside the open event is too early and gets ignored
65 local address = window.address
66 hl.timer(function()
67 hl.dispatch(hl.dsp.window.close({ window = "address:" .. address }))
68 end, { timeout = 300, type = "oneshot" })
69 end
70 end)
71 hl.timer(wowup_done, { timeout = 60000, type = "oneshot" })
72
73 -- hl.exec_cmd("gsettings set org.gnome.desktop.interface color-scheme prefer-dark")
74 -- hl.exec_cmd("gsettings set org.gnome.desktop.interface gtk-theme Adwaita-dark")
75end)
76