feat: account for post-reboot
All checks were successful
Cross-Compile Binaries / compile-linux (push) Successful in 3m50s
Cross-Compile Binaries / compile-windows (push) Successful in 9m42s

This commit is contained in:
2026-02-05 16:22:18 +01:00
parent 7eef1c067a
commit 66cc9dae97
5 changed files with 27 additions and 43 deletions

View File

@@ -9,7 +9,9 @@ if [[ "$runtime_id" -ne 0 ]]; then
echo "Not running as root, please run as root." echo "Not running as root, please run as root."
exit 1 exit 1
fi fi
apt-get -y install libreoffice-impress psmisc ssh vlc apt-get -y install \
default-jre libreoffice-impress libreoffice-java-common psmisc ssh vlc
systemctl enable --now ssh systemctl enable --now ssh
# Create the systemd userland folder # Create the systemd userland folder
@@ -27,16 +29,14 @@ cat > /home/${userland_name}/.config/systemd/user/presentation.service << EOF
[Unit] [Unit]
Description="Systemec RaspScreen Presentation" Description="Systemec RaspScreen Presentation"
Conflicts=video.service Conflicts=video.service
After=graphical.target After=graphical-session.target
[Service] [Service]
Type=simple Type=simple
Environment=DISPLAY=:0 Environment=DISPLAY=:0
WorkingDirectory=/opt/raspscreen WorkingDirectory=/opt/raspscreen
ExecStartPre=/usr/bin/sleep 5
ExecStart=/opt/raspscreen/bin/manage.sh start presentation --foreground ExecStart=/opt/raspscreen/bin/manage.sh start presentation --foreground
ExecStop=/opt/raspscreen/bin/manage kill video KillSignal=SIGKILL
Restart=always
Restart=on-failure Restart=on-failure
RestartSec=2 RestartSec=2
@@ -49,16 +49,14 @@ cat > /home/${userland_name}/.config/systemd/user/video.service << EOF
[Unit] [Unit]
Description="Systemec RaspScreen Video" Description="Systemec RaspScreen Video"
Conflicts=presentation.service Conflicts=presentation.service
After=graphical.target After=graphical-session.target
[Service] [Service]
Type=simple Type=simple
Environment=DISPLAY=:0 Environment=DISPLAY=:0
WorkingDirectory=/opt/raspscreen WorkingDirectory=/opt/raspscreen
ExecStartPre=/usr/bin/sleep 5
ExecStart=/opt/raspscreen/bin/manage.sh start video --foreground ExecStart=/opt/raspscreen/bin/manage.sh start video --foreground
ExecStop=/opt/raspscreen/bin/manage kill video KillSignal=SIGKILL
Restart=always
Restart=on-failure Restart=on-failure
RestartSec=2 RestartSec=2

View File

@@ -11,12 +11,6 @@
app_name="raspscreen" app_name="raspscreen"
# Fallback for display selection
if [[ -z $DISPLAY ]]; then
echo "Triggered exporting display variable fallback..."
export DISPLAY=:0
fi
runtime_id=$(id -u) runtime_id=$(id -u)
if [[ "$runtime_id" -eq 0 ]]; then if [[ "$runtime_id" -eq 0 ]]; then
echo "Do not run as root. Run as the graphical user." echo "Do not run as root. Run as the graphical user."
@@ -25,7 +19,7 @@ fi
printf "Checking input..." printf "Checking input..."
case "$1" in case "$1" in
restart|stop|start|kill) restart|stop|start)
printf "Valid command...";; printf "Valid command...";;
*) *)
echo "Invalid command!" echo "Invalid command!"
@@ -40,19 +34,16 @@ case "$2" in
exit 1;; exit 1;;
esac esac
if [[ "$1" == "kill" ]]; then
if [[ "$2" == "presentation" ]]; then
/usr/bin/killall libreoffice
exit $?
fi
if [[ "$2" == "video" ]]; then
/usr/bin/killall vlc
exit $?
fi
fi
case "$3" in case "$3" in
--foreground) --foreground)
echo "Gathering uptime data..."
sys_uptime=$(cat /proc/uptime | awk '{print int($1)}')
if [[ "$sys_uptime" -lt 60 ]]; then
echo "Detected a recent restart - giving the operating system some time..."
sleep 10s
fi
if [[ "$2" == "presentation" ]]; then if [[ "$2" == "presentation" ]]; then
media_file=$(find /opt/raspscreen/media \( -name "*.pptx" -o -name "*.odp" \)) media_file=$(find /opt/raspscreen/media \( -name "*.pptx" -o -name "*.odp" \))
@@ -64,8 +55,7 @@ case "$3" in
else else
/usr/bin/libreoffice --impress --show --norestore "$media_file" /usr/bin/libreoffice --impress --show --norestore "$media_file"
fi fi
fi elif [[ "$2" == "video" ]]; then
if [[ "$2" == "video" ]]; then
media_file=$(find /opt/raspscreen/media \( -name "*.mp4" -o -name "*.mkv" -o -name "*.mov" -o -name "*.webm" \)) media_file=$(find /opt/raspscreen/media \( -name "*.mp4" -o -name "*.mkv" -o -name "*.mov" -o -name "*.webm" \))
if [[ -z "$media_file" ]]; then if [[ -z "$media_file" ]]; then

View File

@@ -1,16 +1,14 @@
[Unit] [Unit]
Description="Systemec RaspScreen Presentation" Description="Systemec RaspScreen Presentation"
Conflicts=video.service Conflicts=video.service
After=graphical.target After=graphical-session.target
[Service] [Service]
Type=simple Type=simple
Environment=DISPLAY=:0 Environment=DISPLAY=:0
WorkingDirectory=/opt/raspscreen WorkingDirectory=/opt/raspscreen
ExecStartPre=/usr/bin/sleep 5
ExecStart=/opt/raspscreen/bin/manage.sh start presentation --foreground ExecStart=/opt/raspscreen/bin/manage.sh start presentation --foreground
ExecStop=/opt/raspscreen/bin/manage.sh kill presentation KillSignal=SIGKILL
Restart=always
Restart=on-failure Restart=on-failure
RestartSec=2 RestartSec=2

View File

@@ -1,16 +1,14 @@
[Unit] [Unit]
Description="Systemec RaspScreen Video" Description="Systemec RaspScreen Video"
Conflicts=presentation.service Conflicts=presentation.service
After=graphical.target After=graphical-session.target
[Service] [Service]
Type=simple Type=simple
Environment=DISPLAY=:0 Environment=DISPLAY=:0
WorkingDirectory=/opt/raspscreen WorkingDirectory=/opt/raspscreen
ExecStartPre=/usr/bin/sleep 5
ExecStart=/opt/raspscreen/bin/manage.sh start video --foreground ExecStart=/opt/raspscreen/bin/manage.sh start video --foreground
ExecStop=/opt/raspscreen/bin/manage.sh kill video KillSignal=SIGKILL
Restart=always
Restart=on-failure Restart=on-failure
RestartSec=2 RestartSec=2

View File

@@ -141,14 +141,14 @@ func restartShow(targetName string, targetMode int, cfg RaspiConfig) bool {
switch targetMode { switch targetMode {
case 1: case 1:
log.Println("Configuring application workflow: Presentation") log.Println("Configuring application workflow: Presentation")
_, err = runSSHCommand(sshClient, disableVideo) _, err = runSSHCommand(sshClient, disableVideo) // Disable the conflicting service
_, err = runSSHCommand(sshClient, restartPresentation) _, err = runSSHCommand(sshClient, restartPresentation) // Restart the wanted service (which MUST be a restart because the media might have changed)
_, err = runSSHCommand(sshClient, enablePresentation) _, err = runSSHCommand(sshClient, enablePresentation) // Make sure the wanted service starts on reboot
case 2: case 2:
log.Println("Configuring application workflow: Video") log.Println("Configuring application workflow: Video")
_, err = runSSHCommand(sshClient, disablePresentation) _, err = runSSHCommand(sshClient, disablePresentation) // Disable the conflicting service
_, err = runSSHCommand(sshClient, restartVideo) _, err = runSSHCommand(sshClient, restartVideo) // Restart the wanted service (which MUST be a restart because the media might have changed)
_, err = runSSHCommand(sshClient, enableVideo) _, err = runSSHCommand(sshClient, enableVideo) // Make sure the wanted service starts on reboot
} }
if err != nil { if err != nil {