aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorDon Williams <don.e.williams@gmail.com>2026-08-11 12:27:20 -0400
committerPinapelz <yukais@pinapelz.com>2026-08-29 21:41:34 -0700
commite5240e10ae61fcc877be6d6c8f1b26d2fa21d1fd (patch)
treef65daa0728fad0527762da3a492234310ea96a73 /config
parent5b26f6efcea9e1ecb3c5abc5577ec0cad24721be (diff)
Added current keybinds to layout menu
Signed-off-by: Don Williams <don.e.williams@gmail.com> On branch development Your branch is up to date with 'origin/development'. Changes to be committed: modified: CHANGELOG.md modified: config/hypr/scripts/HyprLayoutModule.sh
Diffstat (limited to 'config')
-rwxr-xr-xconfig/hypr/scripts/HyprLayoutModule.sh95
1 files changed, 94 insertions, 1 deletions
diff --git a/config/hypr/scripts/HyprLayoutModule.sh b/config/hypr/scripts/HyprLayoutModule.sh
index 4948acaa..0ca75e3e 100755
--- a/config/hypr/scripts/HyprLayoutModule.sh
+++ b/config/hypr/scripts/HyprLayoutModule.sh
@@ -34,6 +34,85 @@ layout_name() {
esac
}
+# Fallback shortcut labels used when live Hyprland bind data is unavailable.
+layout_shortcut_fallback() {
+ case "$1" in
+ dwindle) echo "SUPER+ALT+1" ;;
+ master) echo "SUPER+ALT+2" ;;
+ scrolling) echo "SUPER+ALT+3" ;;
+ monocle) echo "SUPER+ALT+4" ;;
+ *) echo "" ;;
+ esac
+}
+
+# Resolve live shortcut label from currently loaded Hyprland binds.
+# Works for both Hyprlang and Lua config modes since it reads runtime bind state.
+layout_shortcut_live() {
+ local target="$1"
+ local shortcuts
+
+ if ! command -v hyprctl >/dev/null 2>&1 || ! command -v jq >/dev/null 2>&1; then
+ return 1
+ fi
+
+ shortcuts="$(
+ hyprctl -j binds 2>/dev/null | jq -r --arg target "$target" '
+ [
+ .[]?
+ | select(
+ (
+ (.dispatcher // "") == "exec"
+ and (
+ (.arg // .args // .argument // "")
+ | tostring
+ | test("(^|[[:space:];])([^;]*ChangeLayout\\.sh[[:space:]]+" + $target + "([[:space:];]|$))")
+ )
+ )
+ or (
+ (.description // "")
+ | tostring
+ | ascii_downcase
+ == ("layout " + $target)
+ )
+ )
+ | (
+ .display_key
+ // (
+ [
+ (.mods // [] | if type == "array" then .[] else empty end),
+ (.key // empty)
+ ]
+ | map(select(. != null and . != ""))
+ | join("+")
+ )
+ )
+ | tostring
+ | gsub("\\s*\\+\\s*"; "+")
+ | gsub("\\$mainMod"; "SUPER")
+ | select(length > 0)
+ ]
+ | unique
+ | join(" / ")
+ ' 2>/dev/null
+ )"
+
+ [[ -n "$shortcuts" ]] || return 1
+ printf '%s\n' "$shortcuts"
+}
+
+layout_shortcut() {
+ local target="$1"
+ local live_value
+
+ live_value="$(layout_shortcut_live "$target" || true)"
+ if [[ -n "$live_value" ]]; then
+ printf '%s\n' "$live_value"
+ return
+ fi
+
+ layout_shortcut_fallback "$target"
+}
+
get_layout() {
local layout
@@ -86,10 +165,13 @@ show_status() {
show_menu() {
local current default_row choice target i
local options=()
+ local left_width=0
+ local row left_text shortcut
current="$(get_layout)"
default_row=0
+ # First pass: collect left-column text and shortcuts, track max left width.
for i in "${!layouts[@]}"; do
local layout="${layouts[i]}"
local prefix=" "
@@ -99,7 +181,18 @@ show_menu() {
default_row="$i"
fi
- options+=("${prefix}$(layout_icon "$layout") $(layout_name "$layout")")
+ shortcut="$(layout_shortcut "$layout")"
+ left_text="$(printf '%s%s %s' "$prefix" "$(layout_icon "$layout")" "$(layout_name "$layout")")"
+ (( ${#left_text} > left_width )) && left_width=${#left_text}
+ options+=("$left_text|$shortcut")
+ done
+
+ # Second pass: align the separator and right-side shortcut column.
+ for i in "${!options[@]}"; do
+ row="${options[i]}"
+ left_text="${row%%|*}"
+ shortcut="${row#*|}"
+ options[i]="$(printf "%-${left_width}s -----------> %s" "$left_text" "$shortcut")"
done
if pgrep -x rofi >/dev/null; then
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage