tazpanel rev 521
settings.cgi: fix "tweak" working
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Thu Aug 06 01:03:10 2015 +0300 (2015-08-06) |
parents | fe7c4edfa21b |
children | 8b67a70440c2 |
files | settings.cgi |
line diff
1.1 --- a/settings.cgi Tue Aug 04 11:16:14 2015 +0200 1.2 +++ b/settings.cgi Thu Aug 06 01:03:10 2015 +0300 1.3 @@ -25,14 +25,39 @@ 1.4 1.5 restart_lxpanel() { 1.6 # `lxpanelctl restart` exists, but it breaks often leaving us without any panel 1.7 - lxpanel_pid="$(ps -o comm,pid | fgrep lxpanel | awk '{print $2}')" 1.8 - lxpanel_user="$(ps -o comm,user | fgrep lxpanel | awk '{print $2}')" 1.9 - lxpanel_comm="$(ps -o pid,args | grep -e "^\ *$lxpanel_pid " | awk '{$1="";print}')" 1.10 1.11 - if [ "$USER" == "$lxpanel_user" ]; then 1.12 - kill $lxpanel_pid 1.13 - DISPLAY=':0.0' XAUTHORITY='/var/run/slim.auth' $lxpanel_comm & 1.14 + # parameters needed to run graphical application from script 1.15 + if [ -z "$XAUTHORITY" ]; then 1.16 + if [ -e "$HOME/.Xauthority" ]; then 1.17 + export XAUTHORITY="$HOME/.Xauthority" 1.18 + elif [ -e '/var/run/slim.auth' ]; then 1.19 + export XAUTHORITY='/var/run/slim.auth' 1.20 + fi 1.21 fi 1.22 + [ -z "$DISPLAY" ] && export DISPLAY=':0.0' 1.23 + 1.24 + # find LXPanel ProcessID, filter out zombie '[lxpanel]' (if any) 1.25 + lxpanel_pid="$(ps -o comm,pid,args | fgrep lxpanel | fgrep -v fgrep | fgrep -v '[' | awk '{print $2}')" 1.26 + 1.27 + # if LXPanel not running, just run it with default option 1.28 + if [ -z "$lxpanel_pid" ]; then 1.29 + lxpanel -p slitaz & 1.30 + else 1.31 + # who started LXPanel?.. 1.32 + lxpanel_user="$(ps -o pid,user | fgrep "$lxpanel_pid " | awk '{print $2}')" 1.33 + 1.34 + # ... current user? 1.35 + if [ "$USER" == "$lxpanel_user" ]; then 1.36 + # custom command? 1.37 + lxpanel_comm="$(ps -o pid,args | grep -e "^\ *$lxpanel_pid " | awk '{$1="";print}')" 1.38 + [ -z "$lxpanel_comm" ] && lxpanel_comm='lxpanel -p slitaz' 1.39 + 1.40 + # stop LXPanel and start it again with the same command 1.41 + kill $lxpanel_pid 1.42 + $lxpanel_comm & 1.43 + fi 1.44 + fi 1.45 + 1.46 } 1.47 1.48 1.49 @@ -118,7 +143,7 @@ 1.50 1.51 *\ tweak\ *) 1.52 HOME="$(getdb passwd | awk -F: -vu=$REMOTE_USER '$1==u{print $6}')" 1.53 - [ -d "$HOME" ] && exit 0 1.54 + [ ! -d "$HOME" ] && exit 0 1.55 1.56 dd="$HOME/.local/share/desktop-directories"; sd="$dd/SliTazMenu.directory" 1.57