From 4f0eeb52d86e78c32437bd988c261a4016e2dd4f Mon Sep 17 00:00:00 2001 From: DaanSelen Date: Wed, 4 Feb 2026 15:05:31 +0100 Subject: [PATCH] chore: begin work on op_mode --- build.sh | 0 install.sh | 8 ++--- manage.sh | 49 +++++++++++++++++++++++++++++- service-files/presentation.service | 1 - service-files/video.service | 1 - 5 files changed, 52 insertions(+), 7 deletions(-) mode change 100644 => 100755 build.sh mode change 100644 => 100755 install.sh mode change 100644 => 100755 manage.sh diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index d565f66..82b43c6 --- a/install.sh +++ b/install.sh @@ -22,6 +22,7 @@ if [[ ! -d /opt/${program_name} ]]; then mkdir -p /opt/${program_name}/media -m 755 fi +# THIS MUST BE THE SAME AR $REPO/service-files/presentation.service cat > /home/${userland_name}/.config/systemd/user/presentation.service << EOF [Unit] Description="Systemec RaspScreen" @@ -33,16 +34,16 @@ Type=simple Environment=DISPLAY=:0 WorkingDirectory=/opt/raspscreen ExecStartPre=/usr/bin/sleep 5 -ExecStart=/bin/sh -c 'exec /usr/bin/libreoffice --impress --show --norestore \$(find /opt/raspscreen/media \( -name "*.pptx" -o -name "*.odp" \))' +ExecStart=/bin/sh -c 'exec /usr/bin/libreoffice --impress --show --norestore $(find /opt/raspscreen/media \( -name "*.pptx" -o -name "*.odp" \))' ExecStop=/usr/bin/killall libreoffice Restart=always -Restart=on-failure RestartSec=2 [Install] WantedBy=default.target EOF +# THIS MUST BE THE SAME AR $REPO/service-files/video.service cat > /home/${userland_name}/.config/systemd/user/video.service << EOF [Unit] Description="Systemec RaspScreen" @@ -54,10 +55,9 @@ Type=simple Environment=DISPLAY=:0 WorkingDirectory=/opt/raspscreen ExecStartPre=/usr/bin/sleep 5 -ExecStart=/bin/sh -c 'exec /usr/bin/vlc --fullscreen --loop --no-video-title --video-on-top --no-qt-privacy-ask --no-qt-fs-controller --qt-continue=0 \$(find /opt/raspscreen/media \( -name "*.mp4" -o -name "*.mkv" -o -name "*.mov" -o -name "*.webm" \))' +ExecStart=/bin/sh -c 'exec /usr/bin/vlc --fullscreen --loop --no-video-title --video-on-top --no-qt-fs-controller --qt-continue=0 $(find /opt/raspscreen/media \( -name "*.mp4" -o -name "*.mkv" -o -name "*.mov" -o -name "*.webm" \))' ExecStop=/usr/bin/killall vlc Restart=always -Restart=on-failure RestartSec=2 [Install] diff --git a/manage.sh b/manage.sh old mode 100644 new mode 100755 index 0be8dd0..8a229a8 --- a/manage.sh +++ b/manage.sh @@ -6,8 +6,55 @@ # # Examples: # ./manage.sh (restart|stop|start) (presentation|video) +# +# systemctl must be reachable from the path of the executing user. runtime_id=$(id -u) if [[ "$runtime_id" -eq 0 ]]; then echo "Do not run as root. Run as the graphical user." -fi \ No newline at end of file + exit 1 +fi + +printf "Checking input..." +case "$1" in + restart|stop|start) + printf "Valid command...";; + *) + echo "Invalid command!" + exit 1;; +esac + +case "$2" in + presentation|video) + echo "Valid service...";; + *) + echo "Invalid service!" + exit 1;; +esac + +case "$3" in + --foreground) + if [[ "$2" == "presentation" ]]; then + /bin/sh -c 'exec /usr/bin/libreoffice --impress --show --norestore $(find /opt/raspscreen/media \( -name "*.pptx" -o -name "*.odp" \))' + fi + if [[ "$2" == "video" ]]; then + /bin/sh -c 'exec /usr/bin/libreoffice --impress --show --norestore $(find /opt/raspscreen/media \( -name "*.pptx" -o -name "*.odp" \))' + fi + *) + echo "Running in task mode...";; +esac + +echo "Executing task..." +cmd_result=$(systemctl --user "$1" "$2" 2>&1) +cmd_exit=$? + +if [[ "$cmd_exit" -eq 0 ]]; then + echo "Succesfully exited, see:" + if [[ -n "$cmd_result" ]]; then + echo " -> $cmd_result" + fi +else + echo "Something went wrong, see..." + echo " -> $cmd_result" +fi +exit 0 \ No newline at end of file diff --git a/service-files/presentation.service b/service-files/presentation.service index 196db8e..3e1b0bb 100644 --- a/service-files/presentation.service +++ b/service-files/presentation.service @@ -11,7 +11,6 @@ ExecStartPre=/usr/bin/sleep 5 ExecStart=/bin/sh -c 'exec /usr/bin/libreoffice --impress --show --norestore $(find /opt/raspscreen/media \( -name "*.pptx" -o -name "*.odp" \))' ExecStop=/usr/bin/killall libreoffice Restart=always -Restart=on-failure RestartSec=2 [Install] diff --git a/service-files/video.service b/service-files/video.service index cb4051c..cb3591f 100644 --- a/service-files/video.service +++ b/service-files/video.service @@ -11,7 +11,6 @@ ExecStartPre=/usr/bin/sleep 5 ExecStart=/bin/sh -c 'exec /usr/bin/vlc --fullscreen --loop --no-video-title --video-on-top --no-qt-fs-controller --qt-continue=0 $(find /opt/raspscreen/media \( -name "*.mp4" -o -name "*.mkv" -o -name "*.mov" -o -name "*.webm" \))' ExecStop=/usr/bin/killall vlc Restart=always -Restart=on-failure RestartSec=2 [Install]