From 683f812f1f0b7c2f1e844820418f93a20967df9a Mon Sep 17 00:00:00 2001 From: Henro Veijer Date: Thu, 26 Feb 2026 15:53:31 +0100 Subject: [PATCH] Edited script for dynamic columnwidth in hyprscroll --- .../hypr/scripts/hyprscrolling-per-monitor.sh | 97 ++++++++++++++++--- 1 file changed, 86 insertions(+), 11 deletions(-) diff --git a/henrovnix_ok/assets/conf/desktop/hypr/scripts/hyprscrolling-per-monitor.sh b/henrovnix_ok/assets/conf/desktop/hypr/scripts/hyprscrolling-per-monitor.sh index 629b62313..a9221b535 100755 --- a/henrovnix_ok/assets/conf/desktop/hypr/scripts/hyprscrolling-per-monitor.sh +++ b/henrovnix_ok/assets/conf/desktop/hypr/scripts/hyprscrolling-per-monitor.sh @@ -1,17 +1,92 @@ #!/usr/bin/env bash set -euo pipefail -# Adjust these to match `hyprctl monitors` -ULTRAWIDE="DP-1" -LAPTOP="eDP-1" +# hyprscrolling-per-monitor.sh +# Usage: +# ./hyprscrolling-per-monitor.sh +# +# 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 " + exit 2 +fi MONITOR="$1" -#case "$MONITOR" in - #"$ULTRAWIDE") - # hyprctl dispatch layoutmsg colresize all 0.25 - # ;; - #"$LAPTOP") - # hyprctl dispatch layoutmsg colresize all 1.0 - # ;; -#esac +# 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)"