61 lines
1.9 KiB
Bash
Executable File
61 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Get all monitor info (including disabled)
|
|
MONITORS=$(hyprctl monitors -j all)
|
|
ALL_MONITORS=$(echo "$MONITORS" | jq -r '.[] | .name')
|
|
EXTERNAL_COUNT=$(echo "$ALL_MONITORS" | grep -v "eDP-1" | wc -l)
|
|
|
|
#echo $MONITORS
|
|
#echo $ALL_MONITORS
|
|
#echo $EXTERNAL_COUNT
|
|
|
|
# Case 1: No externals - laptop only
|
|
if [[ $EXTERNAL_COUNT -eq 0 ]]; then
|
|
hyprctl keyword monitor "eDP-1,1920x1200@60,0x0,1"
|
|
exit 0
|
|
fi
|
|
|
|
# Case 2: Single external monitor
|
|
if [[ $EXTERNAL_COUNT -eq 1 ]]; then
|
|
EXT_MON=$(echo "$ALL_MONITORS" | grep -v "eDP-1")
|
|
MODES=$(echo "$MONITORS" | jq -r ".[] | select(.name == \"$EXT_MON\") | .availableModes | join(\" \")")
|
|
MAX_RES=$(echo "$MODES" | grep -oE "[0-9]+x[0-9]+@[0-9.]+" | awk -F'[@x]' '{print $1,$2,$3}' | sort -k1,1nr -k2,2nr -k3,3nr | awk '{print $1"x"$2"@"$3}' | head -n1)
|
|
|
|
hyprctl keyword monitor "eDP-1,1920x1200@60,0x0,1"
|
|
hyprctl keyword monitor "$EXT_MON,$MAX_RES,1920x0,1" # Right of laptop
|
|
exit 0
|
|
fi
|
|
|
|
# Identify our specific monitors
|
|
ULTRAWIDE=""
|
|
STANDARD_ULTRAWIDE=""
|
|
|
|
for MON in $(echo "$ALL_MONITORS"); do
|
|
echo $MON
|
|
[[ $MON == "eDP-1" ]] && continue
|
|
|
|
MODES=$(echo "$MONITORS" | jq -r ".[] | select(.name == \"$MON\") | .availableModes | join(\" \")")
|
|
|
|
echo $MODES
|
|
|
|
if [[ $MODES =~ "5120x1440" ]]; then
|
|
ULTRAWIDE=$MON
|
|
echo "Ultrawide = $ULTRAWIDE"
|
|
elif [[ $MODES =~ "3440x1440" ]]; then
|
|
STANDARD_ULTRAWIDE=$MON
|
|
echo "Standard = $STANDARD_ULTRAWIDE"
|
|
fi
|
|
done
|
|
|
|
# Case 3: Dual monitor setup (only if we found both our specific monitors)
|
|
if [[ -n "$ULTRAWIDE" && -n "$STANDARD_ULTRAWIDE" ]]; then
|
|
echo "dual monitors"
|
|
hyprctl keyword monitor "eDP-1,disable"
|
|
hyprctl keyword monitor "$ULTRAWIDE,5120x1440@120,0x1440,1" # 49" at bottom
|
|
hyprctl keyword monitor "$STANDARD_ULTRAWIDE,3440x1440@60,840x0,1" # 34" at top-left
|
|
exit 0
|
|
fi
|
|
|
|
# If we get here, it's an unexpected configuration - do nothing
|
|
notify-send "Error detecting monitors, no changes"
|