Sort keybindings on SUPER + K

Easier to learn when presented in order
This commit is contained in:
David Heinemeier Hansson
2025-10-24 06:06:34 -07:00
parent 1776981ebf
commit de2b32d77f
5 changed files with 61 additions and 25 deletions

View File

@@ -147,6 +147,43 @@ parse_bindings() {
}'
}
prioritize_entries() {
awk '
{
line = $0
prio = 50
if (match(line, /Terminal/)) prio = 0
if (match(line, /Browser/) && !match(line, /Browser[[:space:]]*\(/)) prio = 1
if (match(line, /File manager/)) prio = 2
if (match(line, /Launch apps/)) prio = 3
if (match(line, /Omarchy menu/)) prio = 4
if (match(line, /System menu/)) prio = 5
if (match(line, /Theme menu/)) prio = 6
if (match(line, /Full screen/)) prio = 7
if (match(line, /Close window/)) prio = 8
if (match(line, /Toggle window floating/)) prio = 9
if (match(line, /Toggle window split/)) prio = 10
if (match(line, /Universal/)) prio = 11
if (match(line, /Clipboard/)) prio = 12
if (match(line, /Emoji picker/)) prio = 13
if (match(line, /Screenshot/)) prio = 14
if (match(line, /Screenrecording/)) prio = 15
if (match(line, /Switch to workspace/)) prio = 16
if (match(line, /Move window to workspace/)) prio = 17
if (match(line, /Swap window/)) prio = 18
if (match(line, /Move window focus/)) prio = 19
if (match(line, /notification/)) prio = 20
if (match(line, /group/)) prio = 97
if (match(line, /Apple Display/)) prio = 98
if (match(line, /XF86/)) prio = 99
# print "priority<TAB>line"
printf "%d\t%s\n", prio, line
}' |
sort -k1,1n -k2,2 |
cut -f2-
}
monitor_height=$(hyprctl monitors -j | jq -r '.[] | select(.focused == true) | .height')
menu_height=$((monitor_height * 40 / 100))
@@ -156,4 +193,5 @@ dynamic_bindings |
sort -u |
parse_keycodes |
parse_bindings |
prioritize_entries |
walker --dmenu -p 'Keybindings' --width 800 --height "$menu_height"