52 lines
1.4 KiB
Bash
Executable file
52 lines
1.4 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
# extdisplay:
|
|
# this is a wrapper around xrandr to handle one external monitor on a laptop
|
|
# (c) 2020 Derek Stevens <drkste@zoho.com>
|
|
# MIT License -- do whatever you want
|
|
|
|
helpme()
|
|
{
|
|
echo "$0, wrapper for using xrandr to handle an external on a laptop"
|
|
echo ""
|
|
echo "USAGE: $0 solo|off|left-of|right-of|above|below [res]"
|
|
echo " solo\n activates the plugged monitor, deactivates the native display"
|
|
echo " off\n activates the native display, deactivates the plugged monitor"
|
|
echo " left-of, right-of, above, below\n activates the plugged monitor in the given"
|
|
echo " relation to the native display"
|
|
echo " res\n if included, sets the resolution of the plugged monitor"
|
|
}
|
|
|
|
if [ -z $1 ]; then
|
|
helpme
|
|
fi
|
|
|
|
native=xrandr | grep LVDS | awk '{print $1}'
|
|
plugged=xrandr | grep connected | grep -v $native | awk '{print $1}'
|
|
|
|
if [ "$1" = solo ]; then
|
|
xrandr --output ${plugged} --primary
|
|
xrandr --output ${native} --off
|
|
xrandr --output ${plugged} --auto
|
|
if [ ! -z $2 ]; then
|
|
xrandr -s $2
|
|
fi
|
|
|
|
elif [ "$1" = off ]; then
|
|
xrandr --output ${native} --primary
|
|
xrandr --output ${plugged} --off
|
|
xrandr --output ${native} --auto
|
|
|
|
else
|
|
case $1 in
|
|
right-of|left-of|above|below)
|
|
xrandr --output ${native} --auto --output ${plugged} --auto --$1 ${native}
|
|
if [ ! -z $2 ]; then
|
|
xrandr --output ${plugged} -s $2
|
|
;;
|
|
*)
|
|
helpme
|
|
;;
|
|
esac
|
|
fi
|
|
|