1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 11:39:46 +01:00

sway: fix onChange for sway config when sway isn't running (#1506)

`pgrep -x somecommand` exits with a non-zero status if it finds no
process running with the given name. When using home-manager as a
NixOS module, on boot (when sway isn't running) this script would
fail and then fail the unit since it seems the onChange scripts
are running with the -e switch.

This change ensures we're always returning a 0 exit status where we
attempt to get the pid of sway - we're only interested in either the
pid or an empty string, the exit status isn't important.
This commit is contained in:
John Axel Eriksson 2020-09-23 13:10:58 +02:00 committed by GitHub
parent a6a3abb295
commit 8a160f01ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -396,7 +396,7 @@ in {
xdg.configFile."sway/config" = {
source = configFile;
onChange = ''
swaySocket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep -x sway).sock
swaySocket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep -x sway || ${pkgs.coreutils}/bin/true).sock
if [ -S $swaySocket ]; then
echo "Reloading sway"
$DRY_RUN_CMD ${pkgs.sway}/bin/swaymsg -s $swaySocket reload