dtoverlay: only run lxpanelctl hooks when lxpanel is running

This commit is contained in:
Serge Schneider
2019-08-02 17:43:31 +01:00
committed by popcornmix
parent 1117308aaa
commit f594b9b161
2 changed files with 26 additions and 28 deletions

View File

@@ -1,17 +1,16 @@
#!/bin/bash
if [ "$DISPLAY" == "" ]; then
export DISPLAY=":0.0"
if ! hash lxpanelctl 2> /dev/null; then
exit 0
fi
CMD="which lxpanelctl >/dev/null 2>&1 && lxpanelctl command volumealsabt start >/dev/null"
if [ $EUID -eq 0 ]; then
if [ "$SUDO_USER" != "" ]; then
user=$SUDO_USER
elif [ "$LOGNAME" != "" ]; then
user=$LOGNAME
else
user=pi
CMD="lxpanelctl command volumealsabt start > /dev/null"
for PID in $(pgrep -x lxpanel); do
eval "$(grep -z "DISPLAY=" "/proc/$PID/environ" | tr -d '\0')"
if [ "$EUID" -ne 0 ]; then
exec $CMD
fi
exec su $user -c "$CMD"
else
exec $CMD
fi
user="$(ps -p "$PID" -o uname=)"
su "$user" -c "$CMD"
done

View File

@@ -1,17 +1,16 @@
#!/bin/bash
if [ "$DISPLAY" == "" ]; then
export DISPLAY=":0.0"
if ! hash lxpanelctl 2> /dev/null; then
exit 0
fi
CMD="which lxpanelctl >/dev/null 2>&1 && lxpanelctl command volumealsabt stop >/dev/null"
if [ $EUID -eq 0 ]; then
if [ "$SUDO_USER" != "" ]; then
user=$SUDO_USER
elif [ "$LOGNAME" != "" ]; then
user=$LOGNAME
else
user=pi
CMD="lxpanelctl command volumealsabt stop >/dev/null"
for PID in $(pgrep -x lxpanel); do
eval "$(grep -z "DISPLAY=" "/proc/$PID/environ" | tr -d '\0')"
if [ "$EUID" -ne 0 ]; then
exec $CMD
fi
exec su $user -c "$CMD"
else
exec $CMD
fi
user="$(ps -p "$PID" -o uname=)"
su "$user" -c "$CMD"
done