Add scripts
This commit is contained in:
46
scripts/displays.sh
Executable file
46
scripts/displays.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/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
|
||||
|
||||
Reference in New Issue
Block a user