| 1 |
#!/bin/bash |
| 2 |
# |
| 3 |
# Copyright : (C) see the 'copyright' file. |
| 4 |
# E-mail : see the 'copyright' file. |
| 5 |
# |
| 6 |
# |
| 7 |
# This program is free software; you can redistribute it and/or |
| 8 |
# modify it under the terms of the GNU General Public License |
| 9 |
# as published by the Free Software Foundation; either version 3 |
| 10 |
# of the License, or (at your option) any later version. |
| 11 |
# |
| 12 |
# This program is distributed in the hope that it will be useful, |
| 13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU General Public License for more details. |
| 16 |
# http://www.gnu.org/licenses/licenses.html#GPL |
| 17 |
# |
| 18 |
# |
| 19 |
# look for GDM/KDM/LDM/XDM/lightdm/MDM |
| 20 |
# if one of them is used, then it has launched either the session-manager, or the stand-alone script, both blocking. |
| 21 |
# so just take this one, and kill it so that we return to GDM. |
| 22 |
|
| 23 |
gdm_proc=`pgrep "gdm|kdm|ldm|xdm|lightdm|mdm" | tail -1` |
| 24 |
if test -n "$gdm_proc"; then |
| 25 |
last_process=`ps -ef | grep $gdm_proc | grep $USER | grep -v grep | tail -1 | tr -s " " | cut -d " " -f 2` |
| 26 |
if test -n "$last_process"; then |
| 27 |
kill $last_process |
| 28 |
exit 0 |
| 29 |
fi |
| 30 |
fi |
| 31 |
|
| 32 |
# if the display manager couldn't be found, look for an endless sleep (likely to be the last process of the session), and kill it. |
| 33 |
sleep_proc=`ps -ef | grep sleep | grep $USER | grep -v grep | head -1` |
| 34 |
if test -n "$sleep_proc"; then |
| 35 |
sleep_time=`echo $sleep_proc | sed "s/.*sleep//g"` |
| 36 |
if test $sleep_time -gt 3600; then |
| 37 |
pkill sleep |
| 38 |
fi |
| 39 |
fi |