activationScripts: cleanup the "nixos activated" graphical notification
This commit is contained in:
@@ -1319,19 +1319,28 @@ in
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
system.activationScripts.notifyActive = lib.mkIf config.sane.programs.guiApps.enabled {
|
system.activationScripts.notifyActive = lib.mkIf config.sane.programs.guiApps.enabled {
|
||||||
text = lib.concatStringsSep "\n" ([
|
text = let
|
||||||
''
|
notify-active = pkgs.writeShellScriptBin "notify-active-inner" ''
|
||||||
tryNotifyUser() {
|
export PATH="/etc/profiles/per-user/$USER/bin:$PATH:${pkgs.libnotify}/bin"
|
||||||
local user="$1"
|
|
||||||
local new_path="$PATH:/etc/profiles/per-user/$user/bin:${pkgs.sudo}/bin:${pkgs.libnotify}/bin"
|
systemConfig="$1"
|
||||||
local version="$(cat $systemConfig/nixos-version)"
|
NIXOS_VERSION="$(cat $systemConfig/nixos-version)"
|
||||||
PATH="$new_path" sudo -u "$user" \
|
|
||||||
env PATH="$new_path" NIXOS_VERSION="$version" /bin/sh -c \
|
if [ -e "$HOME/.profile" ]; then
|
||||||
'. $HOME/.profile; dbus_file="$XDG_RUNTIME_DIR/bus"; if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && [ -e "$dbus_file" ]; then export DBUS_SESSION_BUS_ADDRESS="unix:path=$dbus_file"; fi ; if [ -n "$DBUS_SESSION_BUS_ADDRESS" ]; then notify-send "nixos activated" "version: $NIXOS_VERSION" ; fi'
|
. "$HOME/.profile"
|
||||||
}
|
fi
|
||||||
''
|
|
||||||
] ++ lib.mapAttrsToList
|
dbus_file="$XDG_RUNTIME_DIR/bus"
|
||||||
(user: en: lib.optionalString en "tryNotifyUser ${user} > /dev/null")
|
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && [ -e "$dbus_file" ]; then
|
||||||
|
export DBUS_SESSION_BUS_ADDRESS="unix:path=$dbus_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$DBUS_SESSION_BUS_ADDRESS" ]; then
|
||||||
|
notify-send "nixos activated" "version: $NIXOS_VERSION"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
in lib.concatStringsSep "\n" (lib.mapAttrsToList
|
||||||
|
(user: en: lib.optionalString en ''${lib.getExe pkgs.sudo} -u "${user}" "${lib.getExe notify-active}" "$systemConfig" > /dev/null'')
|
||||||
config.sane.programs.guiApps.enableFor.user
|
config.sane.programs.guiApps.enableFor.user
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user