From 87c99ec024bad04c5447152aa66ad36b11c457fe Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Sun, 12 Jul 2020 10:45:34 -0500 Subject: [PATCH] Use USR1 signal instead of update file for updating statusbar --- scripts/core/sxmo_audioout.sh | 2 +- scripts/core/sxmo_statusbar.sh | 18 +++--------------- scripts/core/sxmo_timezonechange.sh | 2 +- scripts/core/sxmo_vol.sh | 2 +- scripts/modem/sxmo_modemcall.sh | 5 +++-- scripts/modem/sxmo_modemdial.sh | 2 +- scripts/modem/sxmo_modemmonitortoggle.sh | 2 +- 7 files changed, 11 insertions(+), 22 deletions(-) diff --git a/scripts/core/sxmo_audioout.sh b/scripts/core/sxmo_audioout.sh index 0d3a96e..710cf58 100755 --- a/scripts/core/sxmo_audioout.sh +++ b/scripts/core/sxmo_audioout.sh @@ -17,4 +17,4 @@ elif [ "$ARG" = "Earpiece" ]; then amixer set "$EARPIECE" unmute fi -echo 1 > /tmp/sxmo_bar +pgrep -f "$(command -v sxmo_statusbar.sh)" | xargs kill -USR1 diff --git a/scripts/core/sxmo_statusbar.sh b/scripts/core/sxmo_statusbar.sh index feff352..68f4c15 100755 --- a/scripts/core/sxmo_statusbar.sh +++ b/scripts/core/sxmo_statusbar.sh @@ -1,9 +1,7 @@ #!/usr/bin/env sh +trap "update" USR1 pgrep -f sxmo_statusbar.sh | grep -v $$ | xargs kill -9 -UPDATEFILE=/tmp/sxmo_bar -touch "$UPDATEFILE" - update() { # In-call.. show length of call CALLINFO=" " @@ -54,20 +52,10 @@ update() { } # E.g. on first boot justs to make sure the bar comes in quickly -update && sleep 1 && update && sleep 1 && update - -periodicupdate() { - while : - do - echo 1 > "$UPDATEFILE" - sleep 30 - done -} - -periodicupdate & +update && sleep 1 && update && sleep 1 while : do update - inotifywait -e MODIFY "$UPDATEFILE" + sleep 30 & wait done diff --git a/scripts/core/sxmo_timezonechange.sh b/scripts/core/sxmo_timezonechange.sh index 22eb028..767956d 100755 --- a/scripts/core/sxmo_timezonechange.sh +++ b/scripts/core/sxmo_timezonechange.sh @@ -3,7 +3,7 @@ change() { echo "Changing timezone to $1" sudo setup-timezone -z "$1" - echo 1 > /tmp/sxmo_bar + pgrep -f "$(command -v sxmo_statusbar.sh)" | xargs kill -USR1 echo Timezone changed ok read -r } diff --git a/scripts/core/sxmo_vol.sh b/scripts/core/sxmo_vol.sh index 7e3c4ef..b45682b 100755 --- a/scripts/core/sxmo_vol.sh +++ b/scripts/core/sxmo_vol.sh @@ -8,7 +8,7 @@ notify() { xargs printf %.0f )" dunstify -i 0 -u normal -r 998 "♫ $VOL" - echo 1 > /tmp/sxmo_bar + pgrep -f "$(command -v sxmo_statusbar.sh)" | xargs kill -USR1 } up() { diff --git a/scripts/modem/sxmo_modemcall.sh b/scripts/modem/sxmo_modemcall.sh index d1812ae..6d6d8cc 100755 --- a/scripts/modem/sxmo_modemcall.sh +++ b/scripts/modem/sxmo_modemcall.sh @@ -2,13 +2,14 @@ LOGDIR="$XDG_CONFIG_HOME"/sxmo/modem trap "gracefulexit" INT TERM + fatalerr() { # E.g. hangup all calls, switch back to default audio, notify user, and die sxmo_vibratepine 1000 & mmcli -m "$(mmcli -L | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2)" --voice-hangup-all alsactl --file /usr/share/sxmo/default_alsa_sound.conf restore notify-send "$1" - setsid -f sh -c 'sleep 2; echo 1 > /tmp/sxmo_bar' + setsid -f sh -c 'sleep 2; pgrep -f "$(command -v sxmo_statusbar.sh)" | xargs kill -USR1' kill -9 0 } @@ -120,7 +121,7 @@ incallsetup() { incallmonitor() { CALLID="$1" while true; do - echo 1 > /tmp/sxmo_bar + pgrep -f "$(command -v sxmo_statusbar.sh)" | xargs kill -USR1 if mmcli -m "$(modem_n)" -K -o "$CALLID" | grep -E "^call.properties.state.+terminated"; then fatalerr "Call with $NUMBER terminated" fi diff --git a/scripts/modem/sxmo_modemdial.sh b/scripts/modem/sxmo_modemdial.sh index 5cf5b89..1f15550 100755 --- a/scripts/modem/sxmo_modemdial.sh +++ b/scripts/modem/sxmo_modemdial.sh @@ -5,7 +5,7 @@ fatalerr() { # E.g. hangup all calls, switch back to default audio, notify user, and die mmcli -m "$(mmcli -L | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2)" --voice-hangup-all notify-send "$1" - (sleep 0.5; echo 1 > /tmp/sxmo_bar) & + (sleep 0.5; pgrep -f "$(command -v sxmo_statusbar.sh)" | xargs kill -USR1) & kill -9 0 } diff --git a/scripts/modem/sxmo_modemmonitortoggle.sh b/scripts/modem/sxmo_modemmonitortoggle.sh index 6f3c9c0..07b3989 100755 --- a/scripts/modem/sxmo_modemmonitortoggle.sh +++ b/scripts/modem/sxmo_modemmonitortoggle.sh @@ -10,4 +10,4 @@ rm /tmp/sxmo_incomingcall # E.g. wait until process killed or started -- maybe there's a better way.. sleep 1 -echo 1 > /tmp/sxmo_bar +pgrep -f "$(command -v sxmo_statusbar.sh)" | xargs kill -USR1