Skip to content

Instantly share code, notes, and snippets.

@jparrill
Last active December 17, 2015 00:58
Show Gist options
  • Save jparrill/5524459 to your computer and use it in GitHub Desktop.
Save jparrill/5524459 to your computer and use it in GitHub Desktop.
Script to handle the panels hung in LXDE
#!/bin/bash
######
## OS: Mint 12 / Debian
## Service: LXDE
## Desc: This script stop and start the lxde panel if it is hang
## Auth: Juan Manuel Parrilla
######
INSTANCE=/usr/bin/lxpanel
PROFILE=`ps aux | grep $INSTANCE | grep -v grep | awk '{print $13}'`
PROG="lxpanel"
LSB=`head -1 /etc/lsb-release | awk -F= '{print $2}'`
if [ "$LSB" == "LinuxMint" ] || [ "$PROFILE" == "" ];then
PROFILE="Mint-LXDE"
else
PROFILE=`/etc/xdg/lxsession/`
fi
OPTIONS=" --profile $PROFILE"
start()
{
echo -n $"Starting ${PROG}: "
nohup $INSTANCE $OPTIONS &
RETVAL=$?
echo
[ $RETVAL -eq 0 ]
return $RETVAL
}
stop()
{
echo -n $"Stopping ${PROG}: "
pkill $PROG
RETVAL=$?
echo
return $RETVAL
}
restart () {
stop
start
}
RETVAL=0
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
restart
;;
status)
PID=`ps aux | grep $INSTANCE | grep -v grep | awk '{print $2}'`
RETVAL=$?
if [ "$RETVAL" == "0" ];then
STAT="Ok"
else
STAT="Down"
fi
echo "PID: $PID"
echo "Profile: $PROFILE"
echo "Status: $STAT"
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
RETVAL=1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment