From 1d640d4158f653288fba8d99050a673a213539d2 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Wed, 3 May 2023 22:57:27 +0200 Subject: [PATCH] Adds ability to run multiple instanses. --- src/frameless | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/frameless b/src/frameless index 16b0db2..4c292f7 100755 --- a/src/frameless +++ b/src/frameless @@ -27,6 +27,9 @@ DEVICE='' # the screen number SCREEN_NUMBER='' +# the mplayer PID ID +MPLAYER_PID + # main function function main() { # select the video to use @@ -155,6 +158,7 @@ function getDevices() { function previewDevice() { device=$1 mplayer tv:// -tv driver=v4l2:device="/dev/$device" -geometry "300x300" -quiet -nolirc -ontop -noborder -nosound -vo xv & + MPLAYER_PID=$! disown } @@ -208,6 +212,7 @@ function mainMenu() { function showLarge() { mplayer -zoom -ontop -noborder -nosound -vo gl:nomanyfmts \ -vf mirror -xy 2 tv:// -tv driver=v4l2:device="/dev/${DEVICE}" -screen "${SCREEN_NUMBER}" & + MPLAYER_PID=$! disown } @@ -258,14 +263,18 @@ function showVideo() { esac mplayer -zoom -ontop -noborder -nosound -vo gl:nomanyfmts \ - -geometry 320x240+"${x}"+"${y}" -vf mirror tv:// -tv driver=v4l2:device="/dev/${DEVICE}" -screen "${SCREEN_NUMBER}" & + -geometry 320x240+"${x}"+"${y}" -vf mirror tv:// -tv driver=v4l2:device="/dev/${DEVICE}" -screen "${SCREEN_NUMBER}" & + MPLAYER_PID=$! disown } # stop videos playing function stopVideo() { - pkill mplayer - sleep 1 + if [ -n "${MPLAYER_PID}" ]; then + kill "${MPLAYER_PID}" + unset MPLAYER_PID + sleep 1 + fi } # start program