85 lines
2.2 KiB
Bash
Executable File
85 lines
2.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# devices
|
|
_primary=$(xrandr | grep -v ^Screen | head -1 | cut -d" " -f1)
|
|
_max_res=$(xrandr | grep "^ " | head -1 | xargs | cut -d" " -f1)
|
|
_con_dev=$(xrandr | grep " connected" | grep -v "$_primary" | cut -d" " -f1 | xargs)
|
|
_dis_dev=$(xrandr | grep "disconnected" | cut -d" " -f1 | xargs)
|
|
|
|
if [ "$1" == "auto" ]
|
|
then
|
|
xrandr --output $_primary --auto
|
|
fi
|
|
|
|
if [ "$1" == "mirror" ]
|
|
then
|
|
for _dev in $_con_dev
|
|
do
|
|
xrandr --output $_dev --same-as $_primary
|
|
done
|
|
fi
|
|
|
|
_loop() {
|
|
set -x
|
|
for _dev in $1
|
|
do xrandr --output $_dev $2
|
|
done
|
|
}
|
|
|
|
[ "$1" == "left" ] \
|
|
&& _loop "$_con_dev" "--left-of $_primary"
|
|
|
|
[ "$1" == "right" ] \
|
|
&& _loop "$_con_dev" "--right-of $_primary"
|
|
|
|
[ "$1" == "above" ] \
|
|
&& _loop "$_con_dev" "--above $_primary"
|
|
|
|
[ "$1" == "auto" ] \
|
|
&& _loop "$_con_dev $_primary" "--auto"
|
|
|
|
[ "$1" == "off" ] \
|
|
&& _loop "$_con_dev" "--off"
|
|
|
|
[ "$1" == "fullhd" ] \
|
|
&& xrandr --output $_primary --mode "1920x1080"
|
|
|
|
[ "$1" == "hd" ] \
|
|
&& xrandr --output $_primary --mode "1280x720"
|
|
|
|
[ "$1" == "max" ] \
|
|
&& xrandr --output $_primary --mode "$_max_res"
|
|
|
|
if [ "$1" == "b" ]
|
|
then
|
|
[ -z "$2" ] \
|
|
&& doas wsconsctl -n display.brightness \
|
|
|| doas wsconsctl display.brightness=$2
|
|
fi
|
|
|
|
[ "$1" == "r" ] && [ -n "$2" ] \
|
|
&& xrandr --output $_primary --mode "$2"
|
|
|
|
if [ -z "$1" ]
|
|
then
|
|
echo "usage: res [mode]"
|
|
echo " auto - sets prefered mode for all connected displays"
|
|
echo " left - put screen left of primary screen"
|
|
echo " right - put screen right of primary screen"
|
|
echo " above - put screen above of primary screen"
|
|
echo " off - turn all connected screens off (except primary)"
|
|
echo " fullhd - set primary display resolution to FullHD (1920x1080)"
|
|
echo " hd - set primary display resolution to HD (1280x720)"
|
|
echo " max - set primary display to highest resolution ($_max_res)"
|
|
echo " r <res> - set primary display resolution"
|
|
echo " b <%> - display / set screen brightness"
|
|
echo
|
|
echo "Primary: $_primary"
|
|
echo "Connected: $_con_dev"
|
|
echo "Disconnected: $_dis_dev"
|
|
echo "Brightness: $(doas wsconsctl -n display.brightness)%"
|
|
echo
|
|
fi
|
|
|
|
exit 0
|