From 6d4545c414fe91b14de91bb5e6fea468751e754c Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Sun, 30 Aug 2015 12:10:17 +0200 Subject: [PATCH] Neues monitor manage script mit 3 modi: off, clone und second, sowie ein menu script --- bspwm/bspwmrc | 8 +----- bspwm/sxhkdrc | 2 +- scripts/monsetup.sh | 55 ++++++++++++++++++++++++++++++++++++++++ scripts/monsetup_menu.sh | 20 +++++++++++++++ xprofile | 2 +- 5 files changed, 78 insertions(+), 9 deletions(-) create mode 100755 scripts/monsetup.sh create mode 100755 scripts/monsetup_menu.sh diff --git a/bspwm/bspwmrc b/bspwm/bspwmrc index 1917886..c60ba0d 100755 --- a/bspwm/bspwmrc +++ b/bspwm/bspwmrc @@ -4,14 +4,8 @@ INTERN="LVDS1" EXTERN="VGA1" 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 config border_width 1 diff --git a/bspwm/sxhkdrc b/bspwm/sxhkdrc index 4646cbd..1593c3d 100644 --- a/bspwm/sxhkdrc +++ b/bspwm/sxhkdrc @@ -118,7 +118,7 @@ super + d # monitor switch XF86Display - ~/.config/scripts/monitor_switch.sh + ~/.config/scripts/monsetup_menu.sh XF86AudioPlay mpc toggle diff --git a/scripts/monsetup.sh b/scripts/monsetup.sh new file mode 100755 index 0000000..a742dfa --- /dev/null +++ b/scripts/monsetup.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +EXTERN="VGA1" +INTERN="LVDS1" + +if [ $# -lt 1 ]; then + echo "monsetup " + 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 + + diff --git a/scripts/monsetup_menu.sh b/scripts/monsetup_menu.sh new file mode 100755 index 0000000..6afb19e --- /dev/null +++ b/scripts/monsetup_menu.sh @@ -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 diff --git a/xprofile b/xprofile index 79a15fd..e0d50f9 100755 --- a/xprofile +++ b/xprofile @@ -15,4 +15,4 @@ xsetroot -cursor_name left_ptr & #rm -f /tmp/bspwm* -~/.config/scripts/prepare_monitors.sh +~/.config/scripts/monsetup.sh off