47 lines
1.1 KiB
Bash
Executable File
47 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
#$1 is -
|
|
|
|
#echo "DISP:eDP1"
|
|
#exit 0
|
|
|
|
function primary() {
|
|
xrandr | grep primary | awk '{print $1}'
|
|
}
|
|
|
|
#displays=($(xrandr | sed -rn 's/(^|(.* ))([^ ]*) connected(( .*)|$)/\3/g; T; p' ))
|
|
displays=$(xrandr | grep " connected" | awk '{print $1}')
|
|
case "$1" in
|
|
"connected")
|
|
echo "$displays"
|
|
# for i in "${displays[@]}"; do
|
|
# echo "$i"
|
|
# done
|
|
;;
|
|
"lemonbar")
|
|
echo "DISP ${displays[@]}" | sed "s/ /:/g"
|
|
;;
|
|
*)
|
|
# -F Fix strings, -x exactly, -q quiet
|
|
if echo "$displays" | grep -Fqx "$1"; then
|
|
case "$2" in
|
|
"off")
|
|
action="--off"
|
|
;;
|
|
"mirror")
|
|
action="--same-as $(primary)"
|
|
;;
|
|
"left")
|
|
action="--left-of $(primary) --auto"
|
|
;;
|
|
"right")
|
|
action="--right-of $(primary) --auto"
|
|
;;
|
|
*)
|
|
exit 1
|
|
;;
|
|
esac
|
|
xrandr --output $1 $action
|
|
fi
|
|
esac
|
|
|