feat: improve monitor toggle
This commit is contained in:
parent
a64a298181
commit
97a72e9dc8
@ -1,35 +0,0 @@
|
|||||||
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
# ~/.local/bin/hypr‑auto‑internal.sh
|
|
||||||
# Disable the laptop panel (eDP‑1) when any other monitor is connected,
|
|
||||||
# otherwise enable it.
|
|
||||||
|
|
||||||
set -u
|
|
||||||
|
|
||||||
INT="eDP-1" # internal monitor name – change if yours differs
|
|
||||||
|
|
||||||
log() {
|
|
||||||
notify-send "$*"
|
|
||||||
}
|
|
||||||
|
|
||||||
# -------------------------------------------------
|
|
||||||
# 1️⃣ Get current monitor list
|
|
||||||
# -------------------------------------------------
|
|
||||||
MONS=$(hyprctl monitors 2>/dev/null || true)
|
|
||||||
|
|
||||||
# -------------------------------------------------
|
|
||||||
# 2️⃣ Decide whether an external monitor is present
|
|
||||||
# -------------------------------------------------
|
|
||||||
# Any line that is *not* the internal monitor counts as external.
|
|
||||||
if echo "$MONS" | grep -qv "$INT"; then
|
|
||||||
# At least one external monitor is connected
|
|
||||||
log "External monitor detected → disabling $INT"
|
|
||||||
hyprctl keyword monitor $INT, disable 2>/dev/null
|
|
||||||
hyprctl keyword workspace r[1-5] m[DP-4]
|
|
||||||
hyprctl keyword workspace r[6-0] m[DP-5]
|
|
||||||
else
|
|
||||||
# No external monitor → make sure the internal one is on
|
|
||||||
log "No external monitor → enabling $INT"
|
|
||||||
hyprctl keyword monitor $INT, preferred,auto,1.5 2>/dev/null
|
|
||||||
hyprctl reload 2>/dev/null
|
|
||||||
fi
|
|
36
bin/comarchy-toggle-disable-internal-monitor
Executable file
36
bin/comarchy-toggle-disable-internal-monitor
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Disable the laptop panel (eDP‑1) when any other monitor is connected,
|
||||||
|
# otherwise enable it.
|
||||||
|
|
||||||
|
set -u
|
||||||
|
|
||||||
|
# internal monitor name – change if yours differs
|
||||||
|
INT="eDP-1"
|
||||||
|
|
||||||
|
log() {
|
||||||
|
notify-send "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
output=$(hyprctl monitors 2>/dev/null) || {
|
||||||
|
echo "Error: hyprctl not found or command failed" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
mapfile -t monitors < <(
|
||||||
|
grep -oP '(?<=^Monitor ).*?(?= \(ID )' <<<"$output"
|
||||||
|
)
|
||||||
|
|
||||||
|
len=${#monitors[@]}
|
||||||
|
|
||||||
|
if (( len == 2 )); then
|
||||||
|
hyprctl keyword monitor $INT, disable 2>/dev/null
|
||||||
|
hyprctl keyword workspace r[0-9] m[${monitors[1]}]
|
||||||
|
elif (( len == 3 )); then
|
||||||
|
hyprctl keyword monitor $INT, disable 2>/dev/null
|
||||||
|
hyprctl keyword workspace r[1-5] m[${monitors[1]}]
|
||||||
|
hyprctl keyword workspace r[6-9] m[${monitors[2]}]
|
||||||
|
hyprctl keyword workspace r[0] m[${monitors[2]}]
|
||||||
|
else
|
||||||
|
hyprctl keyword monitor $INT, preferred,auto,1.5 2>/dev/null
|
||||||
|
hyprctl reload 2>/dev/null
|
||||||
|
fi
|
@ -40,4 +40,4 @@ bindd = CTRL ALT, PRINT, Screen record display, exec, omarchy-cmd-screenrecord o
|
|||||||
bindd = SUPER, PRINT, Color picker, exec, pkill hyprpicker || hyprpicker -a
|
bindd = SUPER, PRINT, Color picker, exec, pkill hyprpicker || hyprpicker -a
|
||||||
|
|
||||||
# Disable internal monitor
|
# Disable internal monitor
|
||||||
bindd = SUPER CTRL, F12, Disable Internal Monitor, exec, comarchy-disable-internal-monitor
|
bindd = SUPER CTRL, F12, Disable Internal Monitor, exec, comarchy-toggle-disable-internal-monitor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user