Files
nixos/henrovnix_ok/assets/conf (kopie 1)/desktop/hypr/scripts/hyprscrolling-per-monitor.sh
T

91 lines
2.4 KiB
Bash
Executable File

#!/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"
local line
if ! line="$(hyprctl monitors 2>/dev/null | grep -A1 -E "^Monitor ${mon} " -m1 | tail -n1 || true)"; then
echo ""
return 0
fi
# Extract the resolution (e.g., 3840x1080) from the line
local token
token="$(echo "$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)"