#!/bin/bash
|
|
|
|
# Hyprland Monitor Management Script
|
|
# Disables eDP-1 when both DP-5 and DP-6 are connected
|
|
|
|
# Function to check if a monitor is connected
|
|
check_monitor_connected() {
|
|
local monitor_name="$1"
|
|
hyprctl monitors -j | jq -r ".[].name" | grep -q "^${monitor_name}$"
|
|
}
|
|
|
|
# Function to check if a monitor is disabled
|
|
check_monitor_disabled() {
|
|
local monitor_name="$1"
|
|
hyprctl monitors -j | jq -r ".[] | select(.name == \"${monitor_name}\") | .disabled" 2>/dev/null
|
|
}
|
|
|
|
# Function to disable a monitor
|
|
disable_monitor() {
|
|
local monitor_name="$1"
|
|
echo "Disabling monitor: $monitor_name"
|
|
hyprctl keyword monitor "$monitor_name,disable"
|
|
}
|
|
|
|
# Function to enable a monitor (you might want to customize the resolution/position)
|
|
enable_monitor() {
|
|
local monitor_name="$1"
|
|
echo "Enabling monitor: $monitor_name"
|
|
# Adjust the resolution and position as needed for your eDP-1
|
|
hyprctl keyword monitor "$monitor_name,preferred,auto,1"
|
|
}
|
|
|
|
# Main logic
|
|
main() {
|
|
# Check if both external monitors are connected
|
|
if check_monitor_connected "DP-5" && check_monitor_connected "DP-6"; then
|
|
echo "Both DP-5 and DP-6 are connected"
|
|
|
|
# Check if eDP-1 is currently enabled
|
|
if check_monitor_connected "eDP-1"; then
|
|
local edp_disabled=$(check_monitor_disabled "eDP-1")
|
|
if [[ "$edp_disabled" == "false" ]]; then
|
|
echo "eDP-1 is enabled, disabling it..."
|
|
disable_monitor "eDP-1"
|
|
else
|
|
echo "eDP-1 is already disabled"
|
|
fi
|
|
else
|
|
echo "eDP-1 is not detected"
|
|
fi
|
|
|
|
else
|
|
echo "Not both external monitors are connected"
|
|
|
|
# Check if eDP-1 exists and is disabled, then enable it
|
|
if check_monitor_connected "eDP-1"; then
|
|
local edp_disabled=$(check_monitor_disabled "eDP-1")
|
|
if [[ "$edp_disabled" == "true" ]]; then
|
|
echo "eDP-1 is disabled, enabling it..."
|
|
enable_monitor "eDP-1"
|
|
else
|
|
echo "eDP-1 is already enabled"
|
|
fi
|
|
else
|
|
echo "eDP-1 is not detected"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# Run the main function
|
|
main "$@"
|