/
logoutscript
executable file
·107 lines (86 loc) · 3.36 KB
/
logoutscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# this script opens a box with some options to log out, suspend or halt
# the running system. I wrote it for desktops that don't have this service
# already
. /usr/lib/librokenman
exec 2>/dev/null
## Variables
export GLO="/tmp/glo_$$"
export PIXMAPS=/usr/share/pixmaps/porteus
mkdir -p $GLO
## export functions to perform logout actions:
gtklogout_halt()
{
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
}; export -f gtklogout_halt
gtklogout_reboot()
{
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
}; export -f gtklogout_reboot
gtklogout_suspend()
{
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
}; export -f gtklogout_suspend
gtklogout_logout()
{
openbox --exit &
}; export -f gtklogout_logout
export GTKLOGOUT='
<window window_position="1" decorated="false" skip_taskbar_hint="true" window_position="1" allow-shrink="true" width-request="220" height-request="425">
<vbox margin="30">
<hbox>
<pixmap><height>128</height><width>128</width><input file icon="system-log-out"></input></pixmap>
</hbox>
<hbox>
'`txtcolor 100 darkred x-large normal " Log out"`'
</hbox>
'`hsep`'
<hbox>
<button tooltip-text="Shut Down your system" width-request="140">
<variable>HALT</variable>
<label>Shut Down</label>
<input file icon="system-shutdown"></input>
<action type="function">gtklogout_halt</action>
</button>
</hbox>
<hbox>
<button tooltip-text="Restart your system" width-request="140">
<variable>REBOOT</variable>
<label>Reboot</label>
<input file icon="system-reboot"></input>
<action type="function">gtklogout_reboot</action>
</button>
</hbox>
<hbox>
<button tooltip-text="Put your system into a low power state" width-request="140">
<variable>SUSPEND</variable>
<label>Suspend</label>
<input file icon="system-suspend"></input>
<action type="function">gtklogout_suspend</action>
</button>
</hbox>
<hbox>
<button tooltip-text="Log out of openbox" width-request="140">
<variable>LOGOUT</variable>
<label>Log out</label>
<input file icon="exit"></input>
<action type="function">gtklogout_logout</action>
</button>
</hbox>
<hbox>
<button tooltip-text="Cancel" width-request="140">
<variable>CANCEL</variable>
<label>Cancel</label>
<input file icon="gtk-cancel"></input>
<action>exit:Cancel</action>
</button>
</hbox>
</vbox>
<action signal="hide">exit:Cancel</action>
</window>
'
gtkdialog -p GTKLOGOUT > /tmp/.glo_dump
## Did user cancel ?
[ `egrep -o "Cancel|abort" /tmp/.glo_dump` ] && rm -rf $GLO && rm /tmp/.glo_* && exit
rm -rf $GLO && rm /tmp/.glo_*
exitlo