1
0
Fork 0
chezmoi/dot_config/herbstluftwm/executable_monitors.plug
2022-05-06 10:08:57 +02:00

28 lines
621 B
Bash

#!/bin/bash
trap '[[ -n "$reload" ]] && herbstclient detect_monitors && systemctl restart --user panel-handler@$DISPLAY' EXIT
if [[ -z "$*" ]]
then
for mon in $(xrandr | grep -E 'disconnected [[:digit:]]{3,4}' | awk '{ print $1}')
do
xrandr --output "$mon" --off
reload=yes
done
fi
MONITORS=$(xrandr | grep -v LVDS1 | grep ' connected' | awk '{print $1}')
[[ -z "$MONITORS" ]] && exit
CONFIG="$(echo "$MONITORS" | rofi -dmenu)"
[[ -z "$CONFIG" ]] && exit
DIRECTION="$(echo -e 'left\nright' | rofi -dmenu)"
[[ -z "$DIRECTION" ]] && exit
xrandr --output "$CONFIG" "--$DIRECTION-of" LVDS1 --auto
reload=yes