···11+#!/bin/bash
22+set -e
33+44+# Update desktop database
55+if [ -x /usr/bin/update-desktop-database ]; then
66+ update-desktop-database /usr/share/applications || true
77+fi
88+99+# Enable systemd user service for the user who invoked the installation
1010+if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
1111+ # Get the user's home directory
1212+ USER_HOME=$(getent passwd "$SUDO_USER" | cut -d: -f6)
1313+ USER_UID=$(id -u "$SUDO_USER")
1414+1515+ # Enable the service for the user
1616+ sudo -u "$SUDO_USER" XDG_RUNTIME_DIR=/run/user/$USER_UID systemctl --user daemon-reload || true
1717+ sudo -u "$SUDO_USER" XDG_RUNTIME_DIR=/run/user/$USER_UID systemctl --user enable rockbox.service || true
1818+1919+ echo "Rockbox systemd service has been enabled for user $SUDO_USER"
2020+ echo "To start the service now, run: systemctl --user start rockbox.service"
2121+else
2222+ # If installed without sudo or by root, enable globally for all users
2323+ systemctl --global enable rockbox.service || true
2424+ echo "Rockbox systemd service has been enabled globally"
2525+ echo "Users can start the service with: systemctl --user start rockbox.service"
2626+fi
2727+2828+exit 0
+28
dist/debian/arm64/DEBIAN/postinst
···11+#!/bin/bash
22+set -e
33+44+# Update desktop database
55+if [ -x /usr/bin/update-desktop-database ]; then
66+ update-desktop-database /usr/share/applications || true
77+fi
88+99+# Enable systemd user service for the user who invoked the installation
1010+if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
1111+ # Get the user's home directory
1212+ USER_HOME=$(getent passwd "$SUDO_USER" | cut -d: -f6)
1313+ USER_UID=$(id -u "$SUDO_USER")
1414+1515+ # Enable the service for the user
1616+ sudo -u "$SUDO_USER" XDG_RUNTIME_DIR=/run/user/$USER_UID systemctl --user daemon-reload || true
1717+ sudo -u "$SUDO_USER" XDG_RUNTIME_DIR=/run/user/$USER_UID systemctl --user enable rockbox.service || true
1818+1919+ echo "Rockbox systemd service has been enabled for user $SUDO_USER"
2020+ echo "To start the service now, run: systemctl --user start rockbox.service"
2121+else
2222+ # If installed without sudo or by root, enable globally for all users
2323+ systemctl --global enable rockbox.service || true
2424+ echo "Rockbox systemd service has been enabled globally"
2525+ echo "Users can start the service with: systemctl --user start rockbox.service"
2626+fi
2727+2828+exit 0
+58
dist/rpm/amd64/rockbox.spec
···3232/usr/bin/rockbox-gpui
3333/usr/share/applications/rockbox-gpui.desktop
3434/usr/share/pixmaps/rockbox-gpui.png
3535+/usr/lib/systemd/user/rockbox.service
3636+3737+%post
3838+# Update desktop database
3939+if [ -x /usr/bin/update-desktop-database ]; then
4040+ /usr/bin/update-desktop-database /usr/share/applications &> /dev/null || :
4141+fi
4242+4343+# Enable systemd user service
4444+if [ "$1" -eq 1 ]; then
4545+ # Fresh install
4646+ if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
4747+ # Get the user's UID
4848+ USER_UID=$(id -u "$SUDO_USER" 2>/dev/null)
4949+ if [ -n "$USER_UID" ]; then
5050+ sudo -u "$SUDO_USER" XDG_RUNTIME_DIR=/run/user/$USER_UID systemctl --user daemon-reload &> /dev/null || :
5151+ sudo -u "$SUDO_USER" XDG_RUNTIME_DIR=/run/user/$USER_UID systemctl --user enable rockbox.service &> /dev/null || :
5252+ echo "Rockbox systemd service has been enabled for user $SUDO_USER"
5353+ echo "To start the service now, run: systemctl --user start rockbox.service"
5454+ fi
5555+ else
5656+ # Enable globally for all users
5757+ systemctl --global enable rockbox.service &> /dev/null || :
5858+ echo "Rockbox systemd service has been enabled globally"
5959+ echo "Users can start the service with: systemctl --user start rockbox.service"
6060+ fi
6161+fi
6262+6363+%preun
6464+# Stop and disable service on uninstall
6565+if [ "$1" -eq 0 ]; then
6666+ # Uninstall (not upgrade)
6767+ if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
6868+ USER_UID=$(id -u "$SUDO_USER" 2>/dev/null)
6969+ if [ -n "$USER_UID" ]; then
7070+ sudo -u "$SUDO_USER" XDG_RUNTIME_DIR=/run/user/$USER_UID systemctl --user stop rockbox.service &> /dev/null || :
7171+ sudo -u "$SUDO_USER" XDG_RUNTIME_DIR=/run/user/$USER_UID systemctl --user disable rockbox.service &> /dev/null || :
7272+ fi
7373+ else
7474+ systemctl --global disable rockbox.service &> /dev/null || :
7575+ fi
7676+fi
7777+7878+%postun
7979+# Update desktop database after uninstall
8080+if [ "$1" -eq 0 ]; then
8181+ # Uninstall (not upgrade)
8282+ if [ -x /usr/bin/update-desktop-database ]; then
8383+ /usr/bin/update-desktop-database /usr/share/applications &> /dev/null || :
8484+ fi
8585+8686+ if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
8787+ USER_UID=$(id -u "$SUDO_USER" 2>/dev/null)
8888+ if [ -n "$USER_UID" ]; then
8989+ sudo -u "$SUDO_USER" XDG_RUNTIME_DIR=/run/user/$USER_UID systemctl --user daemon-reload &> /dev/null || :
9090+ fi
9191+ fi
9292+fi