Neues monitor manage script mit 3 modi: off, clone und second, sowie ein menu script

This commit is contained in:
madmaurice 2015-08-30 12:10:17 +02:00
parent 3014e2223c
commit 6d4545c414
5 changed files with 78 additions and 9 deletions

View file

@ -4,14 +4,8 @@ INTERN="LVDS1"
EXTERN="VGA1" EXTERN="VGA1"
bspc monitor $INTERN -d 1 2 3 4 5 6 7 8 9 bspc monitor $INTERN -d 1 2 3 4 5 6 7 8 9
bspc monitor $EXTERN -d 1 2 3 4 5 6 7 8 9
EXTERN_CONNECTED=$(bspc query -M | grep $EXTERN)
if [ -n "$EXTERN_CONNECTED" ]; then
bspc monitor $EXTERN -d 1 2 3 4 5 6 7 8 9
else
bspc monitor $EXTERN -d
fi
bspc control --adopt-orphans bspc control --adopt-orphans
bspc config border_width 1 bspc config border_width 1

View file

@ -118,7 +118,7 @@ super + d
# monitor switch # monitor switch
XF86Display XF86Display
~/.config/scripts/monitor_switch.sh ~/.config/scripts/monsetup_menu.sh
XF86AudioPlay XF86AudioPlay
mpc toggle mpc toggle

55
scripts/monsetup.sh Executable file
View file

@ -0,0 +1,55 @@
#!/bin/bash
EXTERN="VGA1"
INTERN="LVDS1"
if [ $# -lt 1 ]; then
echo "monsetup <off|clone|second>"
exit 1
fi
bspwm_mv_win() {
for wid in $(bspc query -W -m $EXTERN); do
bspc window "$wid" -m $INTERN
done
}
bspwm_config_second() {
if [ "$1" != "1" ]; then
bspwm_mv_win
fi
}
xrandr_off() { xrandr --output VGA1 --off --output LVDS1 --primary --auto ; }
xrandr_clone() { xrandr --output VGA1 --auto --same-as LVDS1 --scale-from 1366x768 --output LVDS1 --primary --auto ; }
xrandr_second() { xrandr --output VGA1 --auto --right-of LVDS1 --output LVDS1 --primary --auto ; }
mode_off() {
bspwm_config_second 0
xrandr_off
}
mode_clone() {
bspwm_config_second 0
xrandr_off
xrandr_clone
}
mode_second() {
xrandr_off
xrandr_second
bspwm_config_second 1
}
case $1 in
off|clone|second)
mode_$1
;;
*)
echo No mode named $1
exit 1
;;
esac

20
scripts/monsetup_menu.sh Executable file
View file

@ -0,0 +1,20 @@
#!/bin/bash
cd $(dirname $0)
DMENU="./dmenu.sh"
menu() {
echo $@ | tr ' ' '\n' | $DMENU
}
EXTERN="VGA1"
if [ -n "$(xrandr -q | grep "$EXTERN connected")" ]; then # External Monitor connected
mode=$(menu second clone off)
else
mode=off
fi
[ -n "$mode" ] && ./monsetup.sh $mode

View file

@ -15,4 +15,4 @@ xsetroot -cursor_name left_ptr &
#rm -f /tmp/bspwm* #rm -f /tmp/bspwm*
~/.config/scripts/prepare_monitors.sh ~/.config/scripts/monsetup.sh off