mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-07-26 05:46:59 +00:00
refactor: better systemd service (#161)
* move `pwsp-daemon.service` from `pwsp-gui/assets` to pwsp-daemon/assets + autorestart service + better logging + wait for pipewire until start * adapt all packages * improve systemd service calling for .deb package
This commit is contained in:
@@ -28,7 +28,7 @@ package() {
|
|||||||
|
|
||||||
install -Dm644 "$_srcsrc/pwsp-gui/assets/pwsp-gui.desktop" "${pkgdir}/usr/share/applications/pwsp-gui.desktop"
|
install -Dm644 "$_srcsrc/pwsp-gui/assets/pwsp-gui.desktop" "${pkgdir}/usr/share/applications/pwsp-gui.desktop"
|
||||||
install -Dm644 "$_srcsrc/pwsp-gui/assets/icon.png" "${pkgdir}/usr/share/icons/hicolor/256x256/apps/pwsp.png"
|
install -Dm644 "$_srcsrc/pwsp-gui/assets/icon.png" "${pkgdir}/usr/share/icons/hicolor/256x256/apps/pwsp.png"
|
||||||
install -Dm644 "$_srcsrc/pwsp-gui/assets/pwsp-daemon.service" "${pkgdir}/usr/lib/systemd/user/pwsp-daemon.service"
|
install -Dm644 "$_srcsrc/pwsp-daemon/assets/pwsp-daemon.service" "${pkgdir}/usr/lib/systemd/user/pwsp-daemon.service"
|
||||||
|
|
||||||
install -Dm644 "$_srcsrc/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
install -Dm644 "$_srcsrc/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,5 +44,5 @@ package() {
|
|||||||
install -Dm644 "pwsp-gui/assets/pwsp-gui.desktop" "${pkgdir}/usr/share/applications/pwsp-gui.desktop"
|
install -Dm644 "pwsp-gui/assets/pwsp-gui.desktop" "${pkgdir}/usr/share/applications/pwsp-gui.desktop"
|
||||||
install -Dm644 "pwsp-gui/assets/icon.png" "${pkgdir}/usr/share/icons/hicolor/256x256/apps/pwsp.png"
|
install -Dm644 "pwsp-gui/assets/icon.png" "${pkgdir}/usr/share/icons/hicolor/256x256/apps/pwsp.png"
|
||||||
|
|
||||||
install -Dm644 "pwsp-gui/assets/pwsp-daemon.service" "${pkgdir}/usr/lib/systemd/user/pwsp-daemon.service"
|
install -Dm644 "pwsp-daemon/assets/pwsp-daemon.service" "${pkgdir}/usr/lib/systemd/user/pwsp-daemon.service"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,16 @@ install -Dm755 target/release/pwsp-gui %{buildroot}%{_bindir}/pwsp-gui
|
|||||||
install -Dm644 pwsp-gui/assets/pwsp-gui.desktop %{buildroot}%{_datadir}/applications/pwsp.desktop
|
install -Dm644 pwsp-gui/assets/pwsp-gui.desktop %{buildroot}%{_datadir}/applications/pwsp.desktop
|
||||||
install -Dm644 pwsp-gui/assets/icon.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/pwsp.png
|
install -Dm644 pwsp-gui/assets/icon.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/pwsp.png
|
||||||
|
|
||||||
install -Dm644 pwsp-gui/assets/pwsp-daemon.service %{buildroot}/usr/lib/systemd/user/pwsp-daemon.service
|
install -Dm644 pwsp-daemon/assets/pwsp-daemon.service %{buildroot}/usr/lib/systemd/user/pwsp-daemon.service
|
||||||
|
|
||||||
|
%post
|
||||||
|
%systemd_user_post pwsp-daemon.service
|
||||||
|
|
||||||
|
%preun
|
||||||
|
%systemd_user_preun pwsp-daemon.service
|
||||||
|
|
||||||
|
%postun
|
||||||
|
%systemd_user_postun_with_restart pwsp-daemon.service
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%license LICENSE
|
%license LICENSE
|
||||||
|
|||||||
+10
-1
@@ -68,7 +68,16 @@ install -Dm755 target/release/pwsp-gui %{buildroot}%{_bindir}/pwsp-gui
|
|||||||
install -Dm644 pwsp-gui/assets/pwsp-gui.desktop %{buildroot}%{_datadir}/applications/pwsp.desktop
|
install -Dm644 pwsp-gui/assets/pwsp-gui.desktop %{buildroot}%{_datadir}/applications/pwsp.desktop
|
||||||
install -Dm644 pwsp-gui/assets/icon.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/pwsp.png
|
install -Dm644 pwsp-gui/assets/icon.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/pwsp.png
|
||||||
|
|
||||||
install -Dm644 pwsp-gui/assets/pwsp-daemon.service %{buildroot}/usr/lib/systemd/user/pwsp-daemon.service
|
install -Dm644 pwsp-daemon/assets/pwsp-daemon.service %{buildroot}/usr/lib/systemd/user/pwsp-daemon.service
|
||||||
|
|
||||||
|
%post
|
||||||
|
%systemd_user_post pwsp-daemon.service
|
||||||
|
|
||||||
|
%preun
|
||||||
|
%systemd_user_preun pwsp-daemon.service
|
||||||
|
|
||||||
|
%postun
|
||||||
|
%systemd_user_postun_with_restart pwsp-daemon.service
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%license LICENSE
|
%license LICENSE
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Pipewire Soundpad Daemon
|
||||||
|
Requires=pipewire.service
|
||||||
|
After=pipewire.service
|
||||||
|
PartOf=graphical-session.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/bin/pwsp-daemon
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=3
|
||||||
|
RuntimeDirectory=pwsp
|
||||||
|
SyslogIdentifier=pwsp-daemon
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
+2
-1
@@ -38,6 +38,7 @@ percent-encoding.workspace = true
|
|||||||
name = "pwsp"
|
name = "pwsp"
|
||||||
section = "sound"
|
section = "sound"
|
||||||
priority = "optional"
|
priority = "optional"
|
||||||
|
maintainer-scripts = "maintainer-scripts"
|
||||||
assets = [
|
assets = [
|
||||||
[
|
[
|
||||||
"target/release/pwsp-daemon",
|
"target/release/pwsp-daemon",
|
||||||
@@ -65,7 +66,7 @@ assets = [
|
|||||||
"644",
|
"644",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"assets/pwsp-daemon.service",
|
"../pwsp-daemon/assets/pwsp-daemon.service",
|
||||||
"usr/lib/systemd/user/pwsp-daemon.service",
|
"usr/lib/systemd/user/pwsp-daemon.service",
|
||||||
"644",
|
"644",
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Pipewire Soundpad Daemon
|
|
||||||
After=pipewire.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecStart=/usr/bin/pwsp-daemon
|
|
||||||
Restart=no
|
|
||||||
RuntimeDirectory=pwsp
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=default.target
|
|
||||||
Executable
+21
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$1" = "configure" ]; then
|
||||||
|
if [ -x "/usr/bin/systemctl" ]; then
|
||||||
|
systemctl --global enable pwsp-daemon.service || true
|
||||||
|
|
||||||
|
for uid_dir in /run/user/*; do
|
||||||
|
if [ -d "$uid_dir/systemd" ]; then
|
||||||
|
uid=$(basename "$uid_dir")
|
||||||
|
if [ "$uid" != "0" ]; then
|
||||||
|
username=$(id -un "$uid" 2>/dev/null) || continue
|
||||||
|
su -s /bin/sh -c "XDG_RUNTIME_DIR=$uid_dir systemctl --user daemon-reload" "$username" || true
|
||||||
|
su -s /bin/sh -c "XDG_RUNTIME_DIR=$uid_dir systemctl --user try-restart pwsp-daemon.service" "$username" || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
Executable
+18
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$1" = "remove" ]; then
|
||||||
|
if [ -x "/usr/bin/systemctl" ]; then
|
||||||
|
for uid_dir in /run/user/*; do
|
||||||
|
if [ -d "$uid_dir/systemd" ]; then
|
||||||
|
uid=$(basename "$uid_dir")
|
||||||
|
if [ "$uid" != "0" ]; then
|
||||||
|
username=$(id -un "$uid" 2>/dev/null) || continue
|
||||||
|
su -s /bin/sh -c "XDG_RUNTIME_DIR=$uid_dir systemctl --user daemon-reload" "$username" || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
Executable
+20
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$1" = "remove" ] || [ "$1" = "deconfigure" ]; then
|
||||||
|
if [ -x "/usr/bin/systemctl" ]; then
|
||||||
|
systemctl --global disable pwsp-daemon.service || true
|
||||||
|
|
||||||
|
for uid_dir in /run/user/*; do
|
||||||
|
if [ -d "$uid_dir/systemd" ]; then
|
||||||
|
uid=$(basename "$uid_dir")
|
||||||
|
if [ "$uid" != "0" ]; then
|
||||||
|
username=$(id -un "$uid" 2>/dev/null) || continue
|
||||||
|
su -s /bin/sh -c "XDG_RUNTIME_DIR=$uid_dir systemctl --user stop pwsp-daemon.service" "$username" || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
Reference in New Issue
Block a user