aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rwxr-xr-xconfig/hypr/scripts/HyprLayoutModule.sh95
2 files changed, 95 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1d3c5d0f..bfec3498 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -55,6 +55,7 @@
## Updated:
+- Layout menu has current bindings for each layout
- Shortened `waybar` startup time
- `copy.sh`
- Defaults to LUA on Fresh Install
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