@@ -81,6 +81,15 @@ local function launch(args)
81
81
local onsuspend = args .onsuspend or function () awful .spawn .with_shell (" systemctl suspend" ) end
82
82
local onpoweroff = args .onpoweroff or function () awful .spawn .with_shell (" shutdown now" ) end
83
83
84
+ local onlogout_key = args .onlogout_key or ' l'
85
+ local onlock_key = args .onlock_key or ' k'
86
+ local onreboot_key = args .onreboot_key or ' r'
87
+ local onsuspend_key = args .onsuspend_key or ' u'
88
+ local onpoweroff_key = args .onpoweroff_key or ' s'
89
+ local all_keys = onlogout_key .. onlock_key .. onreboot_key .. onsuspend_key .. onpoweroff_key
90
+
91
+ local ignore_case = args .ignore_case or true
92
+
84
93
w :set_bg (bg_color )
85
94
if # phrases > 0 then
86
95
phrase_widget :set_markup (
@@ -92,15 +101,15 @@ local function launch(args)
92
101
phrase_widget ,
93
102
{
94
103
{
95
- create_button (' log-out' , ' Log Out (l )' ,
104
+ create_button (' log-out' , ' Log Out (' .. onlogout_key .. ' )' ,
96
105
accent_color , label_color , onlogout , icon_size , icon_margin ),
97
- create_button (' lock' , ' Lock (k )' ,
106
+ create_button (' lock' , ' Lock (' .. onlock_key .. ' )' ,
98
107
accent_color , label_color , onlock , icon_size , icon_margin ),
99
- create_button (' refresh-cw' , ' Reboot (r )' ,
108
+ create_button (' refresh-cw' , ' Reboot (' .. onreboot_key .. ' )' ,
100
109
accent_color , label_color , onreboot , icon_size , icon_margin ),
101
- create_button (' moon' , ' Suspend (u )' ,
110
+ create_button (' moon' , ' Suspend (' .. onsuspend_key .. ' )' ,
102
111
accent_color , label_color , onsuspend , icon_size , icon_margin ),
103
- create_button (' power' , ' Power Off (s )' ,
112
+ create_button (' power' , ' Power Off (' .. onpoweroff_key .. ' )' ,
104
113
accent_color , label_color , onpoweroff , icon_size , icon_margin ),
105
114
id = ' buttons' ,
106
115
spacing = 8 ,
@@ -141,17 +150,29 @@ local function launch(args)
141
150
phrase_widget :set_text (' ' )
142
151
capi .keygrabber .stop ()
143
152
w .visible = false
144
- elseif key == ' s' then onpoweroff ()
145
- elseif key == ' r' then onreboot ()
146
- elseif key == ' u' then onsuspend ()
147
- elseif key == ' k' then onlock ()
148
- elseif key == ' l' then onlogout ()
149
- end
153
+ else
154
+ if ignore_case then
155
+ key = string.lower (key )
156
+ onlogout_key = string.lower (onlogout_key )
157
+ onlock_key = string.lower (onlock_key )
158
+ onreboot_key = string.lower (onreboot_key )
159
+ onsuspend_key = string.lower (onsuspend_key )
160
+ onpoweroff_key = string.lower (onpoweroff_key )
161
+ all_keys = string.lower (all_keys )
162
+ end
150
163
151
- if key == ' Escape' or string.match (" srukl" , key ) then
152
- phrase_widget :set_text (' ' )
153
- capi .keygrabber .stop ()
154
- w .visible = false
164
+ if key == onpoweroff_key then onpoweroff ()
165
+ elseif key == onreboot_key then onreboot ()
166
+ elseif key == onsuspend_key then onsuspend ()
167
+ elseif key == onlock_key then onlock ()
168
+ elseif key == onlogout_key then onlogout ()
169
+ end
170
+
171
+ if string.match (all_keys , key ) then
172
+ phrase_widget :set_text (' ' )
173
+ capi .keygrabber .stop ()
174
+ w .visible = false
175
+ end
155
176
end
156
177
end
157
178
end )
0 commit comments