#!/bin/bash# omarchy:summary=Keybindings menu (user override): groups the K-family cheat sheets together at the bottom of the SUPER+K popup.## omarchy-menu-keybindings — user override for the stock Omarchy keybindings# menu (SUPER+K). It runs the CURRENT packaged script unchanged, except it# assigns bottom-of-list priorities to the rest of the K-family cheat sheets so# they cluster next to "Tmux keybindings" / "Herdr keybindings" instead of# scattering among ~230 real bindings at the default middle priority.## Grouped at the end, in order:# Tmux keybindings (stock, prio 100) SUPER + ALT + K# Herdr keybindings (stock, prio 101) SUPER + CTRL + K# RK R65 keyboard (cheat sheet) (added, prio 102) SUPER + CTRL + ALT + K# Pentest arsenal (cheat sheet) (added, prio 103) SUPER + SHIFT + K# Emacs cheat sheet (added, prio 104) SUPER + ALT + E# Neovim / AstroNvim cheat sheet(added, prio 105) SUPER + ALT + N# mpv cheat sheet (added, prio 106) SUPER + ALT + M# Zathura cheat sheet (added, prio 107) SUPER + ALT + Z## HOW: it never edits /usr/share/omarchy or /usr/bin. It reads whichever stock# copy is on disk, rewrites the priority table + cache namespace in memory, and# execs that. ~/.local/bin precedes /usr/bin on PATH (shell and Hyprland), so# this shadows the stock name. If a future `omarchy update` changes the script# so the anchors no longer match, the injection no-ops and you get the stock# menu unchanged. Delete this file to fully revert.set -uo pipefail
self=$(readlink -f "${BASH_SOURCE[0]}"2>/dev/null ||echo"${BASH_SOURCE[0]}")real=""for cand in /usr/share/omarchy/bin/omarchy-menu-keybindings /usr/bin/omarchy-menu-keybindings; do[[ -r $cand]]||continue[[$(readlink -f "$cand"2>/dev/null ||echo"$cand")=="$self"]]&&continuereal="$cand"breakdoneif[[ -z $real]]; thenwhileIFS=read -r cand; do[[$(readlink -f "$cand"2>/dev/null ||echo"$cand")=="$self"]]&&continuereal="$cand"breakdone < <(command -v -a omarchy-menu-keybindings 2>/dev/null)fi[[ -n $real]]||{echo"omarchy-menu-keybindings: stock script not found" >&2; exit127; }patched=$(awk ' # Own cache namespace so this ordering never collides with a cache written by # a direct call to the unpatched stock script. /printf .v11.n./ && !vdone { sub(/v11/, "v11-cheatgroup"); vdone = 1 } { print } # Cluster the remaining K-family cheat sheets right after Tmux/Herdr. /match\(line, \/Herdr keybindings\/\)\) prio = 101/ { print " if (match(line, /Kitty cheat sheet/)) prio = 100" print " if (match(line, /Tmux keybindings/)) prio = 101" print " if (match(line, /RK R65 keyboard/)) prio = 102" print " if (match(line, /Pentest arsenal/)) prio = 103" print " if (match(line, /Emacs cheat sheet/)) prio = 104" print " if (match(line, /Neovim/)) prio = 105" print " if (match(line, /mpv cheat sheet/)) prio = 106" print " if (match(line, /Zathura cheat sheet/)) prio = 107" }'"$real")# If the anchors ever stop matching, fall back to the stock script unchanged.if[[ -z $patched]]; thenexec bash "$real""$@"fiexec bash -c "$patched" omarchy-menu-keybindings "$@"