commit 2b244d77ea6ddba3a35ba41f63091dd25b425904
parent 1548a4f28571f2a94114bb6c164deb0e6db5c7f1
Author: Milutin Popovic <milutin@popovic.xyz>
Date: Sat, 11 Apr 2026 18:52:45 +0100
resume hooks
Diffstat:
5 files changed, 33 insertions(+), 34 deletions(-)
diff --git a/hosts/frame/configuration.nix b/hosts/frame/configuration.nix
@@ -2,8 +2,9 @@
pkgs,
lib,
hostName,
- isDarwin,
inputs,
+ isDarwin,
+ isWayland,
...
}:
{
@@ -11,6 +12,9 @@
../../users/root.nix
../../modules/nix-settings.nix
../../modules/nm.nix
+ ]
+ + lib.optionals (isWayland) [
+ ../../modules/niri-resume-hook.nix
];
sops.defaultSopsFile = ../../secrets.yaml;
diff --git a/modules/dotfiles.nix b/modules/dotfiles.nix
@@ -2,7 +2,7 @@
dotfiles = builtins.fetchGit {
url = "git://popovic.xyz/dots.git";
ref = "master";
- rev = "18ca191d39710b320ffbed04e808d84dc19ef78b";
+ rev = "16f7908b64b131dca39309e7e82b3ca364dcd187";
};
nvim-config = builtins.fetchGit {
diff --git a/modules/niri-resume-hook.nix b/modules/niri-resume-hook.nix
@@ -0,0 +1,22 @@
+{ config, pkgs, ... }:
+
+let
+ user = "mika";
+ uid = toString config.users.users.${user}.uid;
+in
+{
+ environment.etc."systemd/system-sleep/niri-wakeup-monitors" = {
+ mode = "0755";
+ text = ''
+ #!${pkgs.bash}/bin/bash
+ # args: pre|post suspend|hibernate|hybrid-sleep|suspend-then-hibernate
+ if [ "$1" = "post" ]; then
+ # run in the user session context so niri IPC works
+ exec ${pkgs.util-linux}/bin/runuser -u ${user} -- \
+ env XDG_RUNTIME_DIR=/run/user/${uid} \
+ DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus \
+ niri-wakeup-monitors
+ fi
+ '';
+ };
+}
diff --git a/modules/systemd-services.nix b/modules/systemd-services.nix
@@ -32,30 +32,5 @@
WantedBy = [ "timers.target" ];
};
};
- services.niri-wakeup-monitors = {
- Unit = {
- Description = "Wake up external monitors after resume (niri)";
- After = [
- "systemd-suspend.service"
- "systemd-hibernate.service"
- "systemd-hybrid-sleep.service"
- "systemd-suspend-then-hibernate.service"
- ];
- };
-
- Service = {
- Type = "oneshot";
- ExecStart = "${pkgs.bash}/bin/zsh -c 'niri-wakeup-monitors'";
- };
-
- Install = {
- WantedBy = [
- "suspend.target"
- "hibernate.target"
- "hybrid-sleep.target"
- "suspend-then-hibernate.target"
- ];
- };
- };
};
}
diff --git a/users/root.nix b/users/root.nix
@@ -8,13 +8,11 @@ let
in
{
environment.pathsToLink =
- if (!isDarwin) then
- [
- "/share/applications"
- "/share/xdg-desktop-portal"
- ]
- else
- [ ];
+ [ ]
+ + lib.optionals (!isDarwin) [
+ "/share/applications"
+ "/share/xdg-desktop-portal"
+ ];
home-manager = {
useGlobalPkgs = true;