Skip to content
31 changes: 30 additions & 1 deletion lib/awful/hotkeys_popup/widget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,29 @@ local function join_plus_sort(modifiers)
return table.concat(modifiers, '+')
end

--- Use spacial order for hotkey modifier sorting
-- @tfield boolean widget.use_special_hotkey_mod_sort
-- @param boolean
widget.use_special_hotkey_mod_sort = false

--- Spacial modifier sort order
-- Default: Super -> Ctrl -> Alt -> Shift
-- @table
local special_hotkey_mod_order = {
Super = 1,
Ctrl = 2,
Alt = 3,
Shift = 4,
}

local function special_hotkey_join_plus_sort(modifier)
if #modifiers<1 then return "none" end
table.sort(modifiers, function(a,b)
return special_hotkey_mod_order[a] < special_hotkey_mod_order[b]
end)
return table.concat(modifiers, '+')
end

local function get_screen(s)
return s and capi.screen[s]
end
Expand Down Expand Up @@ -394,7 +417,13 @@ function widget.new(args)
for _, mod in ipairs(data.mod) do
table.insert(readable_mods, self.labels[mod] or mod)
end
local joined_mods = join_plus_sort(readable_mods)
local joined_mods = {}

if widget.use_special_hotkey_mod_sort then
joined_mods = special_hotkey_join_plus_sort(readable_mods)
else
joined_mods = join_plus_sort(readable_mods)
end

local group = data.group or "none"
self._group_list[group] = true
Expand Down
Loading