forked from cedlemo/blingbling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
system.lua
160 lines (147 loc) · 7.12 KB
/
system.lua
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
--@author cedlemo
local table = table
local awful = require("awful")
local superproperties = require('blingbling.superproperties')
---launchers for reboot, shutdown, shutdown, logout or lock menus for your system.
--@module blingbling.system
local system = {}
local shutdown_cmd= 'systemctl poweroff'
local reboot_cmd='systemctl reboot'
local lock_cmd='xscreensaver-command -lock'
---Main menu launcher.
--Create a button which will spawn a menu allowing the user to shutdown, reboot, logout and lock screen
--Only the first parameter is mandatory. The other values can be nil and specified in the theme.lua via the theme.blingbling table. See the superproperties module documentation.
--@usage mymainmenu = system.mainmenu(main_image, shutdown_image, reboot_image, logout_image, lock_image)
--@param main_image the image that will be displayed with the shutdown option
--@param shutdown_image the image that will be displayed with the shutdown option
--@param reboot_image the image that will be displayed with the reboot option
--@param logout_image the image that will be displayed with the logout option
--@param lock_image the image that will be displayed with the lock option
function system.mainmenu(main_image, shutdown_image, reboot_image, logout_image, lock_image)
if not shutdown_image then
shutdown_image = superproperties.shutdown or nil
end
if not reboot_image then
reboot_image = superproperties.reboot or nil
end
if not logout_image then
logout_image = superproperties.logout or nil
end
if not lock_image then
lock_image = nil
end
powermenu = awful.menu({ items = {
{ "Shutdown", shutdown_cmd, shutdown_image },
{ "Reboot", reboot_cmd, reboot_image },
{ "Logout", function() awesome.quit() end, logout_image },
{ "Lock", lock_cmd, lock_image }
}
})
return awful.widget.launcher({ image = main_image,
menu = powermenu })
end
---Shutdown menu launcher.
--Create a button with an accept/cancel menu for shutdown the system
--No mandatory parameter. All values can be nil and specified in the theme.lua via the theme.blingbling table. See the superproperties module documentation.
--@usage shutdown=blingbling.system.shutdownmenu(launcher_image, menu_dialog_image_ok, menu_.dialog_image_cancel)
--@param button_image an image file that will be displayed in the wibox
--@param accept_image an image file for the accept menu entry
--@param cancel_image an image file for the cancel menu entry
function system.shutdownmenu(button_image, accept_image, cancel_image)
if not button_image then
button_image = superproperties.shutdown or nil
end
if not accept_image then
accept_image = superproperties.accept or nil
end
if not cancel_image then
cancel_image = superproperties.cancel or nil
end
shutdownmenu = awful.menu({ items = {
{ "Shutdown", shutdown_cmd, accept_image },
{ "Cancel", "", cancel_image }
}
})
shutdownbutton = awful.widget.launcher({ image = button_image,
menu = shutdownmenu })
return shutdownbutton
end
---Lock menu launcher.
--Create a button with an accept/cancel menu for locking the system:
--No mandatory parameter. All values can be nil and specified in the theme.lua via the theme.blingbling table. See the superproperties module documentation.
--@usage shutdown=blingbling.system.lockmenu(launcher_image, menu_dialog_image_ok, menu_.dialog_image_cancel)
--@param button_image an image file that will be displayed in the wibox
--@param accept_image an image file for the accept menu entry
--@param cancel_image an image file for the cancel menu entry
function system.lockmenu(button_image, accept_image, cancel_image)
if not button_image then
button_image = superproperties.lock or nil
end
if not accept_image then
accept_image = superproperties.accept or nil
end
if not cancel_image then
cancel_image = superproperties.cancel or nil
end
shutdownmenu = awful.menu({ items = {
{ "Lock", lock_cmd, accept_image },
{ "Cancel", "", cancel_image }
}
})
shutdownbutton = awful.widget.launcher({ image = button_image,
menu = shutdownmenu })
return shutdownbutton
end
---Reboot menu launcher.
--Create a button with an accept/cancel menu for reboot the system:
--No mandatory parameter. All values can be nil and specified in the theme.lua via the theme.blingbling table. See the superproperties module documentation.
--@usage reboot=blingbling.system.rebootmenu(launcher_image, menu_dialog_image_ok, menu_.dialog_image_cancel)
--@param button_image an image file that will be displayed in the wibox
--@param accept_image an image file for the accept menu entry
--@param cancel_image an image file for the cancel menu entry
function system.rebootmenu(button_image, accept_image, cancel_image)
if not button_image then
button_image = superproperties.reboot or nil
end
if not accept_image then
accept_image = superproperties.accept or nil
end
if not cancel_image then
cancel_image = superproperties.cancel or nil
end
rebootmenu = awful.menu({ items = {
{ "Reboot", reboot_cmd, accept_image },
{ "Cancel", "" , cancel_image}
}
})
rebootbutton = awful.widget.launcher({ image = button_image,
menu = rebootmenu })
return rebootbutton
end
---Logout menu launcher.
--Create a button with an accept/cancel menu for reboot the system:
--No mandatory parameter. All values can be nil and specified in the theme.lua via the theme.blingbling table. See the superproperties module documentation.
--@usage logout=blingbling.system.logouttmenu(launcher_image, menu_dialog_image_ok, menu_.dialog_image_cancel)
--@param button_image an image file that will be displayed in the wibox
--@param accept_image an image file for the accept menu entry
--@param cancel_image an image file for the cancel menu entry
function system.logoutmenu(button_image, accept_image, cancel_image)
if not buttom_image then
button_image = superproperties.logout or nil
end
if not accept_image then
accept_image = superproperties.accept or nil
end
if not cancel_image then
cancel_image = superproperties.cancel or nil
end
logoutmenu = awful.menu({ items = {
{ "Logout", awesome.quit, accept_image },
{ "Cancel", "" , cancel_image}
}
})
logoutbutton = awful.widget.launcher({ image = button_image,
menu = logoutmenu })
return logoutbutton
end
return system