@@ -86,6 +86,18 @@ local function launch(args)
86
86
local onreboot_key = args .onreboot_key or ' r'
87
87
local onsuspend_key = args .onsuspend_key or ' u'
88
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
+
93
+ if ignore_case then
94
+ onlogout_key = string.lower (onlogout_key )
95
+ onlock_key = string.lower (onlock_key )
96
+ onreboot_key = string.lower (onreboot_key )
97
+ onsuspend_key = string.lower (onsuspend_key )
98
+ onpoweroff_key = string.lower (onpoweroff_key )
99
+ all_keys = string.lower (all_keys )
100
+ end
89
101
90
102
w :set_bg (bg_color )
91
103
if # phrases > 0 then
@@ -147,19 +159,23 @@ local function launch(args)
147
159
phrase_widget :set_text (' ' )
148
160
capi .keygrabber .stop ()
149
161
w .visible = false
150
- elseif string.lower (key ) == string.lower (onpoweroff_key ) then onpoweroff ()
151
- elseif string.lower (key ) == string.lower (onreboot_key ) then onreboot ()
152
- elseif string.lower (key ) == string.lower (onsuspend_key ) then onsuspend ()
153
- elseif string.lower (key ) == string.lower (onlock_key ) then onlock ()
154
- elseif string.lower (key ) == string.lower (onlogout_key ) then onlogout ()
155
- end
162
+ else
163
+ if ignore_case then
164
+ key = string.lower (key )
165
+ end
156
166
157
- local all_keys = onlogout_key .. onlock_key .. onreboot_key .. onsuspend_key .. onpoweroff_key
167
+ if key == onpoweroff_key then onpoweroff ()
168
+ elseif key == onreboot_key then onreboot ()
169
+ elseif key == onsuspend_key then onsuspend ()
170
+ elseif key == onlock_key then onlock ()
171
+ elseif key == onlogout_key then onlogout ()
172
+ end
158
173
159
- if key == ' Escape' or string.match (string.lower (all_keys ), string.lower (key )) then
160
- phrase_widget :set_text (' ' )
161
- capi .keygrabber .stop ()
162
- w .visible = false
174
+ if string.match (all_keys , key ) then
175
+ phrase_widget :set_text (' ' )
176
+ capi .keygrabber .stop ()
177
+ w .visible = false
178
+ end
163
179
end
164
180
end
165
181
end )
0 commit comments