Loading refreshVP.sh +23 −6 Original line number Diff line number Diff line Loading @@ -17,6 +17,14 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # Get rights to access display DEBUG=false log(){ if $DEBUG then echo "$@" >> /var/log/vp.log fi } log "starting VP $(date)" user=$(who | grep -v "root" | head -n 1 | cut -d ' ' -f 1) if [ ! -z "$user" ] then Loading Loading @@ -52,12 +60,15 @@ then # No main screen : use the first connected MAIN_SCREEN=$(xrandr | grep " connected" | head -n 1 | cut -d ' ' -f 1) fi log "MAIN_SCREEN '$MAIN_SCREEN'" screens=$(xrandr | grep " connected" | cut -f 1 -d ' ' \ | sed -e 's/ /\n/g' | grep -v $MAIN_SCREEN) if [ "$(echo -e "$screens\n$MAIN_SCREEN" | wc -l)" -eq 0 ] log "SCREENS '$screens'" if [ -z "$screens$MAIN_SCREEN" ] then log "noscreens exiting on $(date)" exit fi Loading Loading @@ -103,6 +114,7 @@ done # Primary screen cmd="xrandr --output $MAIN_SCREEN --auto --mode $mode --rotate normal --primary" log "command $cmd" # Add all connected as copy prev_s=$MAIN_SCREEN Loading @@ -111,6 +123,7 @@ do cmd="$cmd --output $s --auto --mode $mode --same-as $prev_s --rotate normal" prev_s="$s" done log "command after all outputs $cmd" # Disable all disconnected screens screens=$(xrandr | grep " disconnected" | cut -f 1 -d ' ' ) Loading @@ -118,13 +131,17 @@ for s in $(echo -e $screens) do cmd="$cmd --output $s --off" done log "command after all offs $cmd" # Debug # date >> /var/log/vp.log # echo $cmd >> /var/log/vp.log [ "$cmd" == "$(cat /tmp/vp)" ] && exit log "old cmd '$(cat /tmp/vp)'" log "new cmd '$cmd'" if [ "$cmd" == "$(cat /tmp/vp)" ] then log "No cmd change, exiting on $(date)" exit fi echo $cmd > /tmp/vp # echo $cmd # Actually do stuff $cmd log "Runned $cmd, exiting on $(date)" Loading
refreshVP.sh +23 −6 Original line number Diff line number Diff line Loading @@ -17,6 +17,14 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # Get rights to access display DEBUG=false log(){ if $DEBUG then echo "$@" >> /var/log/vp.log fi } log "starting VP $(date)" user=$(who | grep -v "root" | head -n 1 | cut -d ' ' -f 1) if [ ! -z "$user" ] then Loading Loading @@ -52,12 +60,15 @@ then # No main screen : use the first connected MAIN_SCREEN=$(xrandr | grep " connected" | head -n 1 | cut -d ' ' -f 1) fi log "MAIN_SCREEN '$MAIN_SCREEN'" screens=$(xrandr | grep " connected" | cut -f 1 -d ' ' \ | sed -e 's/ /\n/g' | grep -v $MAIN_SCREEN) if [ "$(echo -e "$screens\n$MAIN_SCREEN" | wc -l)" -eq 0 ] log "SCREENS '$screens'" if [ -z "$screens$MAIN_SCREEN" ] then log "noscreens exiting on $(date)" exit fi Loading Loading @@ -103,6 +114,7 @@ done # Primary screen cmd="xrandr --output $MAIN_SCREEN --auto --mode $mode --rotate normal --primary" log "command $cmd" # Add all connected as copy prev_s=$MAIN_SCREEN Loading @@ -111,6 +123,7 @@ do cmd="$cmd --output $s --auto --mode $mode --same-as $prev_s --rotate normal" prev_s="$s" done log "command after all outputs $cmd" # Disable all disconnected screens screens=$(xrandr | grep " disconnected" | cut -f 1 -d ' ' ) Loading @@ -118,13 +131,17 @@ for s in $(echo -e $screens) do cmd="$cmd --output $s --off" done log "command after all offs $cmd" # Debug # date >> /var/log/vp.log # echo $cmd >> /var/log/vp.log [ "$cmd" == "$(cat /tmp/vp)" ] && exit log "old cmd '$(cat /tmp/vp)'" log "new cmd '$cmd'" if [ "$cmd" == "$(cat /tmp/vp)" ] then log "No cmd change, exiting on $(date)" exit fi echo $cmd > /tmp/vp # echo $cmd # Actually do stuff $cmd log "Runned $cmd, exiting on $(date)"