heads/NetworkManager/60-yokai-launcher.sh

46 lines
848 B
Bash
Executable File

#! /bin/sh
set -e
killtree() {
local _pid=$1
local _sig=${2:--KILL}
for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
killtree ${_child} ${_sig}
done
kill -9 ${_pid}
}
# Get LIVE_USERNAME
. /etc/live/config.d/username.conf
# Get LANG
. /etc/default/locale
export LANG
export DISPLAY=':0.0'
export XAUTHORITY="`echo /var/run/gdm3/auth-for-${LIVE_USERNAME}-*/database`"
LOCKFILE=/var/lock/yokai-launcher.lock
# Run only when the interface is not "lo":
if [ "${1}" = "lo" ]; then
exit 0
fi
if [ "${2}" = "up" ]; then
(
sudo -u ${LIVE_USERNAME} lckdo $LOCKFILE yokai-launcher -DISPLAY=${DISPLAY}
) &
elif [ "${2}" = "down" ]; then
for i in $(seq 10); do
PPID=`pgrep "^yokai-launcher$"`
killtree $PPID
sleep 1
if ! pgrep "^yokai-launcher$"; then
break
fi
done
fi