Added and tested script to prepare henrovnix_ok for publishing

This commit is contained in:
2026-02-27 23:05:46 +01:00
parent 8b19518697
commit 33618c1b07
8908 changed files with 3277 additions and 5430 deletions
@@ -0,0 +1,133 @@
#!/usr/bin/env bash
set -euo pipefail
# Usage:
# Waybar exec: hyprscroll-overflow.sh
# Waybar on-click: hyprscroll-overflow.sh --pick
#
# Env:
# COLUMN_WIDTH=0.5
# ICON="󰓒"
# DMENU_CMD="walker --dmenu" (or: "wofi --dmenu", "rofi -dmenu", etc.)
COLUMN_WIDTH="${COLUMN_WIDTH:-0.5}"
ICON="${ICON:-󰓒}"
DMENU_CMD="${DMENU_CMD:-walker --dmenu}"
json_escape() {
# minimal JSON string escape (quotes, backslashes, newlines, tabs, CR)
local s="${1:-}"
s="${s//\\/\\\\}"
s="${s//\"/\\\"}"
s="${s//$'\n'/\\n}"
s="${s//$'\r'/\\r}"
s="${s//$'\t'/\\t}"
printf '%s' "$s"
}
fail_json() {
# NOTE: errors SHOULD still show (so you notice), hence JSON output here.
local msg="hyprscroll-overflow: ${1:-unknown error}"
printf '{"text":"%s !","tooltip":"%s","class":"error"}\n' \
"$(json_escape "$ICON")" "$(json_escape "$msg")"
exit 0
}
need() { command -v "$1" >/dev/null 2>&1 || fail_json "$1 not in PATH"; }
need hyprctl
need jq
need awk
read -r focused_mon_id focused_ws_id < <(
hyprctl -j monitors 2>/dev/null | jq -r '
.[] | select(.focused==true) | "\(.id) \(.activeWorkspace.id)"
'
) || fail_json "failed to read focused monitor/workspace"
[[ -n "${focused_mon_id:-}" && -n "${focused_ws_id:-}" ]] || fail_json "no focused monitor/workspace"
# Current layout (needed for both normal + --pick paths)
layout="$(hyprctl getoption general:layout 2>/dev/null | awk '/str:/ {print $2; exit}' || true)"
layout="${layout:-}"
# Collect windows (current ws + current monitor, mapped only)
clients_json="$(hyprctl -j clients 2>/dev/null)" || fail_json "failed to read clients"
# Click action: pick a window and focus it
if [[ "${1:-}" == "--pick" ]]; then
# Build menu lines: address at end so we can parse it back reliably.
menu="$(
jq -r --argjson ws "$focused_ws_id" --argjson mid "$focused_mon_id" '
[ .[]
| select(.mapped == true)
| select(.workspace.id == $ws)
| select(.monitor == $mid)
| {address, class, title}
]
| map("[\(.class)] \(.title) \(.address)")
| .[]
' <<<"$clients_json"
)" || exit 0
[[ -n "${menu:-}" ]] || exit 0
# shellcheck disable=SC2086
choice="$(printf '%s\n' "$menu" | eval "$DMENU_CMD" || true)"
[[ -n "${choice:-}" ]] || exit 0
addr="$(awk '{print $NF}' <<<"$choice")"
[[ "$addr" =~ ^0x[0-9a-fA-F]+$ ]] || exit 0
hyprctl dispatch focuswindow "address:${addr}" >/dev/null 2>&1 || exit 0
exit 0
fi
# Tooltip list (multiline)
# Include a stable selector: address (hex), plus class + title for humans.
tooltip_list="$(
jq -r --argjson ws "$focused_ws_id" --argjson mid "$focused_mon_id" '
[ .[]
| select(.mapped == true)
| select(.workspace.id == $ws)
| select(.monitor == $mid)
| {address, class, title}
]
| to_entries
| map("\(.key+1). [\(.value.class)] \(.value.title) (\(.value.address))")
| .[]
' <<<"$clients_json"
)" || fail_json "failed to build tooltip list"
win_count="$(
jq -r --argjson ws "$focused_ws_id" --argjson mid "$focused_mon_id" '
[ .[]
| select(.mapped == true)
| select(.workspace.id == $ws)
| select(.monitor == $mid)
] | length
' <<<"$clients_json"
)" || fail_json "failed to count clients"
max_visible="$(awk -v w="$COLUMN_WIDTH" 'BEGIN{ if (w<=0) {print 1} else {print int(1.0/w)} }')" \
|| fail_json "awk failed"
(( max_visible < 1 )) && max_visible=1
overflow=$(( win_count - max_visible ))
# IMPORTANT: hide module by outputting NOTHING (no JSON) when not relevant
if (( overflow <= 0 )) || [[ "$layout" != "scrolling" ]]; then
exit 0
fi
text="$ICON +$overflow"
cls="overflow"
tooltip="WS ${focused_ws_id}${win_count} window(s)\n"
tooltip+="Approx ${max_visible} fit (column_width=${COLUMN_WIDTH})\n"
tooltip+="------------------------------\n"
tooltip+="${tooltip_list:-"(no windows)"}"
printf '{"text":"%s","tooltip":"%s","class":"%s"}\n' \
"$(json_escape "$text")" \
"$(json_escape "$tooltip")" \
"$(json_escape "$cls")"
@@ -0,0 +1,92 @@
#!/usr/bin/env bash
set -euo pipefail
# hyprscrolling-per-monitor.sh
# Usage:
# ./hyprscrolling-per-monitor.sh <MONITOR_NAME>
#
# Example:
# ./hyprscrolling-per-monitor.sh DP-1
#
# This script reads the current resolution for the given monitor via hyprctl
# and sets hyprscrolling column width accordingly.
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <MONITOR_NAME>"
exit 2
fi
MONITOR="$1"
# Map a resolution (WIDTHxHEIGHT) to a column width value for hyprscrolling.
# Tune these values to taste.
columnwidth_for_resolution() {
local res="$1"
case "$res" in
# --- Ultra-wide / super-wide ---
5120x1440) echo "0.22" ;; # 49" 32:9
3840x1080) echo "0.25" ;; # 49" 32:9 (your ultrawide)
3440x1440) echo "0.33" ;; # 34" 21:9
2560x1080) echo "0.40" ;; # 21:9 budget ultrawide
# --- QHD / high DPI ---
3840x2160) echo "0.40" ;; # 4K
3200x1800) echo "0.50" ;;
2880x1800) echo "0.50" ;;
2560x1600) echo "0.55" ;; # 16:10
2560x1440) echo "0.55" ;; # QHD
# --- FHD / laptop-ish ---
1920x1200) echo "0.55" ;; # 16:10
1920x1080) echo "0.50" ;; # FHD (your laptop request)
# --- HD / smaller ---
1680x1050) echo "0.65" ;;
1600x900) echo "0.70" ;;
1366x768) echo "0.80" ;;
1280x720) echo "0.85" ;;
# Unknown / fallback
*) echo "" ;;
esac
}
# Get resolution for a named monitor from hyprctl.
# Output format should be WIDTHxHEIGHT (e.g. 3840x1080).
get_monitor_resolution() {
local mon="$1"
# hyprctl monitors prints lines like:
# Monitor DP-1 (ID 0): 3840x1080@119.88 at 0x0 ...
# We'll extract the first WIDTHxHEIGHT after the colon.
local line
if ! line="$(hyprctl monitors 2>/dev/null | grep -F "Monitor ${mon} " -m1 || true)"; then
echo ""
return 0
fi
# Extract token like 3840x1080@... then strip @...
local token
token="$(awk -F': ' '{print $2}' <<<"$line" | awk '{print $1}' | cut -d'@' -f1 || true)"
echo "$token"
}
resolution="$(get_monitor_resolution "$MONITOR")"
if [[ -z "$resolution" ]]; then
echo "Could not determine resolution for monitor '$MONITOR'."
echo "Tip: check available names with: hyprctl monitors"
exit 1
fi
colw="$(columnwidth_for_resolution "$resolution")"
if [[ -z "$colw" ]]; then
echo "No mapping for resolution '$resolution' on monitor '$MONITOR'."
echo "Add it to columnwidth_for_resolution() in this script."
exit 1
fi
# Apply to hyprscrolling.
# Using layoutmsg colresize (as in your snippet).
hyprctl dispatch layoutmsg colresize all "$colw"
echo "hyprscrolling: set column width to $colw for monitor '$MONITOR' ($resolution)"
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail
INTERNAL="eDP1"
has_external() {
# Any monitor name that is not INTERNAL counts as external
hyprctl monitors -j | grep -q '"name"' && ! hyprctl monitors -j | grep -q "\"name\":\"$INTERNAL\"\""
}
has_external_robust() {
# robust without jq: count monitor names; if there's >1 OR there's a name not INTERNAL
local names
names="$(hyprctl monitors -j | sed -n 's/.*"name":"\([^"]*\)".*/\1/p')"
# if any name != INTERNAL then external
echo "$names" | grep -vx "$INTERNAL" >/dev/null 2>&1
}
if has_external_robust; then
# Clamshell: disable laptop panel, no lock
hyprctl keyword monitor "${INTERNAL},disable"
else
# Laptop only: suspend
systemctl suspend
fi
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
INTERNAL="eDP1"
# Restore panel using preferred mode, auto position, scale 1
hyprctl keyword monitor "${INTERNAL},preferred,auto,1"
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -euo pipefail
OPTIONS=" Lock
 Logout (Hyprland)
 Suspend
 Hibernate
 Reboot
 Shutdown
 Cancel"
CHOICE=$(printf "%s" "$OPTIONS" | walker --dmenu )
case "$CHOICE" in
"Lock")
loginctl lock-session
;;
"Logout (Hyprland)")
hyprctl dispatch exit
;;
"Suspend")
loginctl lock-session && systemctl suspend
;;
"Hibernate")
loginctl lock-session && systemctl hibernate
;;
"Reboot")
systemctl reboot
;;
"Shutdown")
systemctl poweroff
;;
*)
exit 0
;;
esac
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail
cur="$(hyprctl getoption general:layout 2>/dev/null | awk '/str:/ {print $2; exit}')"
if [[ "$cur" == "scrolling" ]]; then
new="dwindle"
else
new="scrolling"
fi
hyprctl keyword general:layout "$new" >/dev/null
msg="Hyprland layout: $new"
echo "$msg"
# Show a notification if possible
if command -v notify-send >/dev/null 2>&1; then
notify-send -a Hyprland "Layout switched" "$msg"
fi