mirror of
https://github.com/LukeHagar/omarchy.git
synced 2025-12-06 04:20:23 +00:00
* fix: remove theme-flag * migration: walker 1.0.0-beta * Fixups * Add elephant and walker * Update for new layout.xml * Clean up some styling * add unicode and todo providers * remove default quick activate keybinds * Update keybinds and remove defaults to prevent conflict * Fix menu option * Fixes * Remove * Update height * Add elephant service * Remove from hyprland * Restart service now * Trim * Update height * Fix keybindings style * Fix install location * Add walker restart * Fix indention * Fix indention * Fix indention * Fix indention * Advance to present * Need to refresh to bring over the new config * style adjustments * Correct the installation of the 1pw policy installer * Skip the prebuilt for a second while we test * Need libyaml to build ruby * No longer needed, gcc-15 compatibility has been added * Let's just stick to the official path * GCC15 compatibility for Ruby has been achieved * No longer necessary The other mise option is set on Ruby on Rails install * Added ZLS - Zig's Language Server when installing Zig (#1718) * style adjustments * styling changes * add only_search_title * css adjustments to fix broken styles * Be tall again * Remove for future variable height menu * Update height / width params * fix: remove theme-flag * Fix spacing..again * Remove service and add launch util * Fix * fix: wrong emojis flag * remove flag, its dmenu only * set min content width to prevent flickering if the item list contains shorter items * Remove unused service * Megakill needed * Remove any old themes too * Remove min-width * Style adjustments * changes for walker/elephant updates * Match current width * Add a little more space between icon and text * fix: bluetooth find bind * remove archlinux provider, fix migration with missing providers * fix: css import * Fix theme path * fix: add new error label to layout * Fix migration --------- Co-authored-by: David Heinemeier Hansson <david@hey.com> Co-authored-by: Ryan Hughes <ryan@heyoodle.com> Co-authored-by: DoKoB0512 <123281216+DoKoB0512@users.noreply.github.com>
160 lines
4.5 KiB
Bash
Executable File
160 lines
4.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# A script to display Hyprland keybindings defined in your configuration
|
|
# using walker for an interactive search menu.
|
|
|
|
declare -A KEYCODE_SYM_MAP
|
|
|
|
build_keymap_cache() {
|
|
local keymap
|
|
keymap="$(xkbcli compile-keymap)" || {
|
|
echo "Failed to compile keymap" >&2
|
|
return 1
|
|
}
|
|
|
|
while IFS=, read -r code sym; do
|
|
[[ -z "$code" || -z "$sym" ]] && continue
|
|
KEYCODE_SYM_MAP["$code"]="$sym"
|
|
done < <(
|
|
awk '
|
|
BEGIN { sec = "" }
|
|
/xkb_keycodes/ { sec = "codes"; next }
|
|
/xkb_symbols/ { sec = "syms"; next }
|
|
sec == "codes" {
|
|
if (match($0, /<([A-Za-z0-9_]+)>\s*=\s*([0-9]+)\s*;/, m)) code_by_name[m[1]] = m[2]
|
|
}
|
|
sec == "syms" {
|
|
if (match($0, /key\s*<([A-Za-z0-9_]+)>\s*\{\s*\[\s*([^, \]]+)/, m)) sym_by_name[m[1]] = m[2]
|
|
}
|
|
END {
|
|
for (k in code_by_name) {
|
|
c = code_by_name[k]
|
|
s = sym_by_name[k]
|
|
if (c != "" && s != "" && s != "NoSymbol") print c "," s
|
|
}
|
|
}
|
|
' <<<"$keymap"
|
|
)
|
|
}
|
|
|
|
lookup_keycode_cached() {
|
|
printf '%s\n' "${KEYCODE_SYM_MAP[$1]}"
|
|
}
|
|
|
|
parse_keycodes() {
|
|
local start end elapsed
|
|
[[ "${DEBUG:-0}" == "1" ]] && start=$(date +%s.%N)
|
|
while IFS= read -r line; do
|
|
if [[ "$line" =~ code:([0-9]+) ]]; then
|
|
code="${BASH_REMATCH[1]}"
|
|
symbol=$(lookup_keycode_cached "$code" "$XKB_KEYMAP_CACHE")
|
|
echo "${line/code:${code}/$symbol}"
|
|
else
|
|
echo "$line"
|
|
fi
|
|
done
|
|
|
|
if [[ "$DEBUG" == "1" ]]; then
|
|
end=$(date +%s.%N)
|
|
# fall back to awk if bc is missing
|
|
if command -v bc >/dev/null 2>&1; then
|
|
elapsed=$(echo "$end - $start" | bc)
|
|
else
|
|
elapsed=$(awk -v s="$start" -v e="$end" 'BEGIN{printf "%.6f", (e - s)}')
|
|
fi
|
|
echo "[DEBUG] parse_keycodes elapsed: ${elapsed}s" >&2
|
|
fi
|
|
}
|
|
|
|
# Fetch dynamic keybindings from Hyprland
|
|
#
|
|
# Also do some pre-processing:
|
|
# - Remove standard Omarchy bin path prefix
|
|
# - Remove uwsm prefix
|
|
# - Map numeric modifier key mask to a textual rendition
|
|
# - Output comma-separated values that the parser can understand
|
|
dynamic_bindings() {
|
|
hyprctl -j binds |
|
|
jq -r '.[] | {modmask, key, keycode, description, dispatcher, arg} | "\(.modmask),\(.key)@\(.keycode),\(.description),\(.dispatcher),\(.arg)"' |
|
|
sed -r \
|
|
-e 's/null//' \
|
|
-e 's,~/.local/share/omarchy/bin/,,' \
|
|
-e 's,uwsm app -- ,,' \
|
|
-e 's,uwsm-app -- ,,' \
|
|
-e 's/@0//' \
|
|
-e 's/,@/,code:/' \
|
|
-e 's/^0,/,/' \
|
|
-e 's/^1,/SHIFT,/' \
|
|
-e 's/^4,/CTRL,/' \
|
|
-e 's/^5,/SHIFT CTRL,/' \
|
|
-e 's/^8,/ALT,/' \
|
|
-e 's/^9,/SHIFT ALT,/' \
|
|
-e 's/^12,/CTRL ALT,/' \
|
|
-e 's/^13,/SHIFT CTRL ALT,/' \
|
|
-e 's/^64,/SUPER,/' \
|
|
-e 's/^65,/SUPER SHIFT,/' \
|
|
-e 's/^68,/SUPER CTRL,/' \
|
|
-e 's/^69,/SUPER SHIFT CTRL,/' \
|
|
-e 's/^72,/SUPER ALT,/' \
|
|
-e 's/^73,/SUPER SHIFT ALT,/' \
|
|
-e 's/^76,/SUPER CTRL ALT,/' \
|
|
-e 's/^77,/SUPER SHIFT CTRL ALT,/'
|
|
}
|
|
|
|
# Parse and format keybindings
|
|
#
|
|
# `awk` does the heavy lifting:
|
|
# - Set the field separator to a comma ','.
|
|
# - Joins the key combination (e.g., "SUPER + Q").
|
|
# - Joins the command that the key executes.
|
|
# - Prints everything in a nicely aligned format.
|
|
parse_bindings() {
|
|
awk -F, '
|
|
{
|
|
# Combine the modifier and key (first two fields)
|
|
key_combo = $1 " + " $2;
|
|
|
|
# Clean up: strip leading "+" if present, trim spaces
|
|
gsub(/^[ \t]*\+?[ \t]*/, "", key_combo);
|
|
gsub(/[ \t]+$/, "", key_combo);
|
|
|
|
# Use description, if set
|
|
action = $3;
|
|
|
|
if (action == "") {
|
|
# Reconstruct the command from the remaining fields
|
|
for (i = 4; i <= NF; i++) {
|
|
action = action $i (i < NF ? "," : "");
|
|
}
|
|
|
|
# Clean up trailing commas, remove leading "exec, ", and trim
|
|
sub(/,$/, "", action);
|
|
gsub(/(^|,)[[:space:]]*exec[[:space:]]*,?/, "", action);
|
|
gsub(/^[ \t]+|[ \t]+$/, "", action);
|
|
gsub(/[ \t]+/, " ", key_combo); # Collapse multiple spaces to one
|
|
|
|
# Escape XML entities
|
|
gsub(/&/, "\\&", action);
|
|
gsub(/</, "\\<", action);
|
|
gsub(/>/, "\\>", action);
|
|
gsub(/"/, "\\"", action);
|
|
gsub(/'"'"'/, "\\'", action);
|
|
}
|
|
|
|
if (action != "") {
|
|
printf "%-35s → %s\n", key_combo, action;
|
|
}
|
|
}'
|
|
}
|
|
|
|
monitor_height=$(hyprctl monitors -j | jq -r '.[] | select(.focused == true) | .height')
|
|
menu_height=$((monitor_height * 40 / 100))
|
|
|
|
build_keymap_cache
|
|
|
|
dynamic_bindings |
|
|
sort -u |
|
|
parse_keycodes |
|
|
parse_bindings |
|
|
walker --dmenu -p 'Keybindings' --width 800 --height "$menu_height"
|