Created
February 20, 2024 07:54
-
-
Save Karitham/7050b764bd7afb98dc49bf4cc19d9ca5 to your computer and use it in GitHub Desktop.
script to set display settings based on the existence of a screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env bash | |
set -x +o pipefail | |
# Get the current output of hyprland monitors command | |
output=$(hyprctl monitors -j) | |
# Check if the HDMI-A-1 display exists in the output | |
# use grep because it fails if it doesn't find anything, unlike jq. | |
if echo "$output" | grep "HDMI-A-1"; then | |
# If the external display exists, set the eDPI-1 resolution to 1920x1200 at 60fps | |
# Set the resolution of the external display to its maximum size and refresh rate | |
max_size=$(echo "$output" | jq '.[] | select(.name == "HDMI-A-1") | .width, .height' | head -n 1 | awk '{printf "%dx%d", $1, $2}') | |
max_refresh=$(echo "$output" | jq '.[] | select(.name == "HDMI-A-1") | .refreshRate' | head -n 1) | |
hyprctl --batch "keyword monitor eDP-1, 1920x1200@60, 0x0, 1; keyword monitor HDMI-A-1, ${max_size}@${max_refresh}, -${max_size}x0, 1" | |
else | |
hyprctl keyword monitor eDP-1, 2560x1600@60, 0x0, 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment