diff --git a/modules/files.nix b/modules/files.nix index 6106d8157..551c91b38 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -298,8 +298,13 @@ in home.activation.onFilesChange = hm.dag.entryAfter ["linkGeneration"] ( concatMapStrings (v: '' - if [[ ''${changedFiles[${escapeShellArg v.target}]} -eq 1 ]]; then - ${v.onChange} + if (( ''${changedFiles[${escapeShellArg v.target}]} == 1 )); then + if [[ -v DRY_RUN || -v VERBOSE ]]; then + echo "Running onChange hook for" ${escapeShellArg v.target} + fi + if [[ ! -v DRY_RUN ]]; then + ${v.onChange} + fi fi '') (filter (v: v.onChange != "") (attrValues cfg)) ); diff --git a/modules/programs/i3status-rust.nix b/modules/programs/i3status-rust.nix index b20b5f27b..0b582ea2e 100644 --- a/modules/programs/i3status-rust.nix +++ b/modules/programs/i3status-rust.nix @@ -6,14 +6,6 @@ let cfg = config.programs.i3status-rust; - restartI3 = '' - i3Socket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/i3/ipc-socket.* - if [ -S $i3Socket ]; then - echo "Reloading i3" - $DRY_RUN_CMD ${config.xsession.windowManager.i3.package}/bin/i3-msg -s $i3Socket restart 1>/dev/null - fi - ''; - settingsFormat = pkgs.formats.toml { }; in { @@ -258,7 +250,12 @@ in { xdg.configFile = mapAttrs' (cfgFileSuffix: cfg: nameValuePair ("i3status-rust/config-${cfgFileSuffix}.toml") ({ - onChange = mkIf config.xsession.windowManager.i3.enable restartI3; + onChange = mkIf config.xsession.windowManager.i3.enable '' + i3Socket="''${XDG_RUNTIME_DIR:-/run/user/$UID}/i3/ipc-socket.*" + if [[ -S $i3Socket ]]; then + ${config.xsession.windowManager.i3.package}/bin/i3-msg -s $i3Socket restart >/dev/null + fi + ''; source = settingsFormat.generate ("config-${cfgFileSuffix}.toml") ({ theme = cfg.theme; diff --git a/modules/programs/qutebrowser.nix b/modules/programs/qutebrowser.nix index 2178997fe..8327370a8 100644 --- a/modules/programs/qutebrowser.nix +++ b/modules/programs/qutebrowser.nix @@ -309,10 +309,9 @@ in { mkIf pkgs.stdenv.hostPlatform.isLinux { text = qutebrowserConfig; onChange = '' - hash="$(echo -n $USER | md5sum | cut -d' ' -f1)" + hash="$(echo -n "$USER" | md5sum | cut -d' ' -f1)" socket="''${XDG_RUNTIME_DIR:-/run/user/$UID}/qutebrowser/ipc-$hash" - if [ -S $socket ]; then - echo "Reloading qutebrowser" + if [[ -S $socket ]]; then command=${ escapeShellArg (builtins.toJSON { args = [ ":config-source" ]; @@ -320,7 +319,7 @@ in { protocol_version = 1; }) } - $DRY_RUN_CMD echo $command | ${pkgs.socat}/bin/socat -lf /dev/null - UNIX-CONNECT:$socket + echo "$command" | ${pkgs.socat}/bin/socat -lf /dev/null - UNIX-CONNECT:"$socket" fi unset hash socket command ''; diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index 0f09d4146..64fa3d395 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -192,12 +192,7 @@ in { xdg.configFile."dunst/dunstrc" = { text = toDunstIni cfg.settings; onChange = '' - pkillVerbose="" - if [[ -v VERBOSE ]]; then - pkillVerbose="-e" - fi - $DRY_RUN_CMD ${pkgs.procps}/bin/pkill -u $USER $pkillVerbose dunst || true - unset pkillVerbose + ${pkgs.procps}/bin/pkill -u "$USER" ''${VERBOSE+-e} dunst || true ''; }; }) diff --git a/modules/services/window-managers/i3-sway/i3.nix b/modules/services/window-managers/i3-sway/i3.nix index e45d415d5..fee416479 100644 --- a/modules/services/window-managers/i3-sway/i3.nix +++ b/modules/services/window-managers/i3-sway/i3.nix @@ -255,8 +255,7 @@ in { onChange = '' i3Socket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/i3/ipc-socket.* if [ -S $i3Socket ]; then - echo "Reloading i3" - $DRY_RUN_CMD ${cfg.package}/bin/i3-msg -s $i3Socket reload 1>/dev/null + ${cfg.package}/bin/i3-msg -s $i3Socket reload >/dev/null fi ''; }; diff --git a/modules/services/window-managers/i3-sway/sway.nix b/modules/services/window-managers/i3-sway/sway.nix index 6fed3701c..178c09f29 100644 --- a/modules/services/window-managers/i3-sway/sway.nix +++ b/modules/services/window-managers/i3-sway/sway.nix @@ -438,10 +438,9 @@ in { xdg.configFile."sway/config" = { source = configFile; onChange = '' - swaySocket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep -x sway || ${pkgs.coreutils}/bin/true).sock + swaySocket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep -x sway || true).sock if [ -S $swaySocket ]; then - echo "Reloading sway" - $DRY_RUN_CMD ${pkgs.sway}/bin/swaymsg -s $swaySocket reload + ${pkgs.sway}/bin/swaymsg -s $swaySocket reload fi ''; }; diff --git a/modules/services/window-managers/xmonad.nix b/modules/services/window-managers/xmonad.nix index 784160241..ef291d039 100644 --- a/modules/services/window-managers/xmonad.nix +++ b/modules/services/window-managers/xmonad.nix @@ -161,9 +161,8 @@ in { source = xmonadBin; onChange = '' # Attempt to restart xmonad if X is running. - if [[ -v DISPLAY ]] ; then - echo "Restarting xmonad" - $DRY_RUN_CMD ${config.xsession.windowManager.command} --restart + if [[ -v DISPLAY ]]; then + ${config.xsession.windowManager.command} --restart fi ''; }; diff --git a/modules/xresources.nix b/modules/xresources.nix index ef91906e0..79f924aeb 100644 --- a/modules/xresources.nix +++ b/modules/xresources.nix @@ -93,8 +93,8 @@ in { ++ optionals (cfg.properties != null) (mapAttrsToList formatLine cfg.properties)) + "\n"; onChange = '' - if [[ -v DISPLAY ]] ; then - $DRY_RUN_CMD ${xrdbMerge} + if [[ -v DISPLAY ]]; then + ${xrdbMerge} fi ''; };