diff --git a/assets/himalaya-watch@.service b/assets/himalaya-watch@.service new file mode 100644 index 0000000..dd7e88e --- /dev/null +++ b/assets/himalaya-watch@.service @@ -0,0 +1,13 @@ +[Unit] +Description=Email client Himalaya CLI envelopes watcher service +After=network.target + +[Service] +Type=exec +ExecStart=%install_dir%/himalaya envelopes watch --account %i +ExecSearchPath=/bin +Restart=always +RestartSec=10 + +[Install] +WantedBy=default.target diff --git a/install.sh b/install.sh index d6e72e5..57a4240 100644 --- a/install.sh +++ b/install.sh @@ -32,4 +32,11 @@ tar -xzf "$tmpdir/himalaya.tar.gz" -C "$tmpdir" mkdir -p "$PREFIX/bin" cp -f -- "$tmpdir/$binary" "$PREFIX/bin/$binary" +# See User Unit Search Path in `man systemd.unit(5)` +if [ "$system" = "linux" ] && [ "$PREFIX" = "/usr" ]; then + mkdir -p "$PREFIX/lib/systemd/user" + sed "s:%install_dir%:$PREFIX/bin:" "$tmpdir/assets/himalaya-watch@.service" \ + > "$PREFIX/lib/systemd/user/himalaya-watch@.service" +fi + die "$("$PREFIX/bin/$binary" --version) installed!" 0