config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

commit 4f3dae4ceb464535b9a3f1e43b720dee81515017
parent 45f053d485e22ad1f3078a4d203bec02674a09e9
Author: dwrz <dwrz@dwrz.net>
Date:   Thu, 25 Jul 2024 12:40:37 +0000

Update monitor-hotplug script

Diffstat:
Mscripts/monitor-hotplug | 40++++++++++++++++++++++++++++++++++------
1 file changed, 34 insertions(+), 6 deletions(-)

diff --git a/scripts/monitor-hotplug b/scripts/monitor-hotplug @@ -3,18 +3,46 @@ export DISPLAY=:0.0 connect() { - xrandr --output eDP-1 --off --output DP-3 --auto && \ - notify-send "Connected external monitor." + local display=$1 + local position=$2 + + case "${position}" in + "left"|"l") xrandr --output eDP-1 --auto --left-of "${display}" \ + --output "${display}" --auto ;; + "right"|"r") xrandr --output eDP-1 --auto --right-of "${display}" \ + --output "${display}" --auto ;; + "above"|"a") xrandr --output eDP-1 --auto --above "${display}" \ + --output "${display}" --auto ;; + "below"|"b") xrandr --output eDP-1 --auto --below "${display}" \ + --output "${display}" --auto ;; + *) xrandr --output eDP-1 --off --output "${display}" --auto ;; + esac + + notify-send "Connected monitor." } disconnect() { - xrandr --output eDP-1 --auto --output DP-3 --off && \ - notify-send "Disconnected external monitor." + xrandr --output eDP-1 --auto \ + --output DP-1 --off \ + --output DP-2 --off \ + --output DP-3 --off \ + --output DP-4 --off + + notify-send "Disconnected monitor." } main() { - if xrandr | grep -q "DP-3 connected"; then - connect + local display + for d in DP-1 DP-2 DP-3 DP-4; do + if xrandr | grep -q "^${d} connected"; then + display="${d}" + break + fi + done + + if [ -n "${display}" ]; then + printf "connecting" + connect "${display}" "$1" else disconnect fi