Adapted script to correctly detect the size of the monitor
This commit is contained in:
@@ -55,22 +55,20 @@ columnwidth_for_resolution() {
|
|||||||
# Output format should be WIDTHxHEIGHT (e.g. 3840x1080).
|
# Output format should be WIDTHxHEIGHT (e.g. 3840x1080).
|
||||||
get_monitor_resolution() {
|
get_monitor_resolution() {
|
||||||
local mon="$1"
|
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
|
local line
|
||||||
if ! line="$(hyprctl monitors 2>/dev/null | grep -F "Monitor ${mon} " -m1 || true)"; then
|
if ! line="$(hyprctl monitors 2>/dev/null | grep -A1 -E "^Monitor ${mon} " -m1 | tail -n1 || true)"; then
|
||||||
echo ""
|
echo ""
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
# Extract the resolution (e.g., 3840x1080) from the line
|
||||||
# Extract token like 3840x1080@... then strip @...
|
|
||||||
local token
|
local token
|
||||||
token="$(awk -F': ' '{print $2}' <<<"$line" | awk '{print $1}' | cut -d'@' -f1 || true)"
|
token="$(echo "$line" | awk '{print $1}' | cut -d'@' -f1 || true)"
|
||||||
echo "$token"
|
echo "$token"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resolution="$(get_monitor_resolution "$MONITOR")"
|
resolution="$(get_monitor_resolution "$MONITOR")"
|
||||||
if [[ -z "$resolution" ]]; then
|
if [[ -z "$resolution" ]]; then
|
||||||
echo "Could not determine resolution for monitor '$MONITOR'."
|
echo "Could not determine resolution for monitor '$MONITOR'."
|
||||||
|
|||||||
Reference in New Issue
Block a user