скриптик для ноута для поддержки функций хоткеев(мож кому интересно)

Наваял тут на досуге. задолбало с перетаскиванием окон с монитора на монитор и поиском мышки. В итоге родился скриптик:



Colorized Source Code


#!/bin/sh
#
# mode_switch.sh cmd [args]
#
# Commands:
#	wlan <on|off>		     - switch on/off wlan power
#	power			     - moving to stadby mode
#	mwindow			     - move active window to second monitor
#	mmouse			     - move mouse cursor to top of active window
#       monupd <up|down|left|right> - update monitors settings after plug/unplug monitor
#
get_current_window() {
    wid=`xprop -root |awk '/_NET_ACTIVE_WINDOW/ {print $5; exit;}'|cut -d"," -f1|sed 's/0x/0x0/'`
}

action=$1
case $action in
	wlan)
	state=`sed -n '1p;1q' /sys/class/net/wlan0/device/tx_power`
	case $state in
		off)
		iwconfig wlan0 tx on
		ifconfig wlan0 up
		echo "on"
	    ;;
		*)
		iwconfig wlan0 tx off
		echo "off"
	    ;;
	esac
    ;;
	power)
		sync
		echo -n mem > /sys/power/state
    ;;
	monupd)
	    out=`xrandr | awk '/^(VGA|LVDS)/ {print $1}'`
	    LVDS=`echo $out | sed 's/VGA[a-zA-Z0-9]//'`
	    VGA=`echo $out | sed 's/LVDS[a-zA-Z0-9]//'`
	    case $2 in
		up)
		xrandr --output $LVDS --auto --output $VGA --auto --above $LVDS
	    ;;
	    	down)
		xrandr --output $LVDS --auto --output $VGA --auto --below $LVDS
	    ;;
	    	left)
		xrandr --output $LVDS --auto --output $VGA --auto --left-of $LVDS
	    ;;
	    	right)
		xrandr --output $LVDS --auto --output $VGA --auto --right-of $LVDS
	    ;;
	    	*)
		echo "wrong position"
		exit
	    ;;
	esac
    ;;
    	mwindow) # move window betwin monitors
		monitors=`xvinfo|grep Adaptor|wc -l`
		# if more than one
		if [ ${monitors} -ge 1 ] ;then
			# get window id
			wid=0;
			get_current_window
			# get window giometry and position
			metric=`xwininfo -id ${wid} -metric|grep -E "(Width|Height|Corner)"`
			inc=`xrandr -q | sed 's/+/ /g' | awk '/^(VGA|LVDS)/ { if ( $4 > 0 ) print $4 }'`
			# $10 - x, $11 - y, $2 - width $6 height
			repos=`echo ${metric} |sed 's/+/ /g' | awk -v inc=$inc '{
					if( inc < $10 ) npos= $10 - inc - 1
					else npos= $10 + inc -1
					if( $11 > 46 ) h = $11 - 22
					else h = 0
					printf("%s,%s,%s,%s,%s", 0, npos, h, -1, -1);}'`
			wmctrl -e ${repos} -i -r ${wid}
		fi
    ;;
    	mmouse) # move mouse cursor to the current window
            wid=0
            get_current_window
            # convert from hex to binary
            wid=`printf "%d" ${wid}`

            xdotool mousemove -w ${wid} 55 0
    ;;
	*)
		echo "error"
		exit1
    ;;
esac