This repository has no description
3.2 kB
98 lines
1{
2 pkgs,
3 config,
4 self,
5 ...
6}:
7let
8 # Patch noctalia-shell to use workspace name instead of number for sway
9 # Quickshell's activate() sends "workspace number <num>" which fails for named workspaces (num=-1)
10 noctalia-shell-patched = pkgs.noctalia-shell.overrideAttrs (old: {
11 postInstall = (old.postInstall or "") + ''
12 substituteInPlace $out/share/noctalia-shell/Services/Compositor/SwayService.qml \
13 --replace-fail 'workspace.handle.activate();' \
14 'Quickshell.execDetached([msgCommand, "workspace", workspace.name]);' \
15 --replace-fail 'property bool initialized: false' \
16 'property bool globalWorkspaces: true
17 property bool initialized: false'
18 '';
19 });
20in
21{
22 systemd.user.services.noctalia-shell = {
23 description = "Noctalia Shell - Wayland desktop shell";
24 documentation = [ "https://docs.noctalia.dev" ];
25 partOf = [ "sway-session.target" ];
26 wantedBy = [ "sway-session.target" ];
27 after = [ "sway-session.target" ];
28 path = [
29 pkgs.bash
30 pkgs.coreutils
31 pkgs.gnugrep
32 pkgs.gawk
33 pkgs.procps
34 pkgs.util-linux
35 pkgs.sway
36 pkgs.brightnessctl
37 pkgs.pulseaudio
38 pkgs.networkmanager
39 pkgs.wl-clipboard
40 ];
41 serviceConfig = {
42 ExecStart = "${noctalia-shell-patched}/bin/noctalia-shell";
43 Restart = "on-failure";
44 };
45 };
46
47 environment.systemPackages = [
48 noctalia-shell-patched
49 # ryzenadj and power-profile for power profile control
50 pkgs.ryzenadj
51 self.packages.${pkgs.system}.power-profile
52 ];
53
54 # Idle inhibit service - toggled by bar button
55 systemd.user.services.sway-idle-inhibit = {
56 description = "Inhibit idle/sleep";
57 serviceConfig = {
58 Type = "simple";
59 ExecStart = "${pkgs.systemd}/bin/systemd-inhibit --what=idle:sleep --who=noctalia --why='User requested' --mode=block sleep infinity";
60 };
61 };
62
63 # Allow user to run ryzenadj without password (for power profile switching)
64 security.sudo.extraRules = [
65 {
66 users = [ config.users.users.mainUser.name ];
67 commands = [
68 {
69 command = "/run/current-system/sw/bin/ryzenadj";
70 options = [ "NOPASSWD" ];
71 }
72 ];
73 }
74 ];
75
76 # Make RAPL energy counters readable for power monitoring
77 services.udev.extraRules = ''
78 SUBSYSTEM=="powercap", ACTION=="add", RUN+="${pkgs.coreutils}/bin/chmod a+r /sys/class/powercap/%k/energy_uj"
79 '';
80
81 # Configure noctalia darkModeChange hook to trigger switch-theme
82 # This makes noctalia's dark mode button also switch the system theme
83 system.activationScripts.noctalia-hooks.text =
84 let
85 jq = "${pkgs.jq}/bin/jq";
86 settingsFile = "/home/${config.users.users.mainUser.name}/.config/noctalia/settings.json";
87 in
88 ''
89 if [ -f "${settingsFile}" ]; then
90 ${jq} '
91 .hooks.enabled = true |
92 .hooks.darkModeChange = "if [ \"$1\" = \"true\" ]; then switch-theme dark; else switch-theme light; fi"
93 ' "${settingsFile}" > "${settingsFile}.tmp" && \
94 mv "${settingsFile}.tmp" "${settingsFile}" && \
95 chown ${config.users.users.mainUser.name}:users "${settingsFile}" || true
96 fi
97 '';
98}