Description: This is a set of 9 bash scripts which I use to move my active window on screen similar to the Compiz Put plugin. You need to have the xdotool installed which can be found in most repositories.
Associating these scripts with keyboard shortcuts creates a great KDE desktop improvement for manipulating windows.
Ratings & Comments
2 Comments
for multiple monitors the following example (kput_top_right.sh) could be more appropriate: warning bash arrays inside http://paste.kde.org/177092/ #! /bin/bash Bottom_Panel=35 Gap=20 window=$(xdotool getactivewindow) # mousepos == ( "2401" "750" ) mousepos=( $( xdotool getmouselocation 2>&1 | sed -n -e 's|^x:\([0-9]\+\) y:\([0-9]\+\) .*$|\1 \2|p' | head -n1 ) ) # ${monitors[@]} == ( "2560,1440,1920,0" "1920,1080,0,0" ) monitors=( $(xrandr | sed -n -e 's:^.*\bconnected \([0-9]\+\)x\([0-9]\+\)+\([0-9]\+\)+\([0-9]\+\) .*$:\1,\2,\3,\4:p') ) monitor=( 0 0 1024 768 ) for m in ${monitors[@]} do tmpm=( ${m//,/ } ) x0=${tmpm[2]} x1=$((x0 + ${tmpm[0]})) y0=${tmpm[3]} y1=$((y0 + ${tmpm[1]})) xm=${mousepos[0]} ym=${mousepos[1]} if [[ ($x0 -le $xm) && ($xm -le $x1) && ($y0 -le $ym) && ($ym -le $y1) ]] then monitor=( $x0 $y0 $x1 $y1 ) break fi done x=${monitor[2]} y=${monitor[3]} w=$(xwininfo -id $window | grep "Width" | awk '{print $2}') h=$(xwininfo -id $window | grep "Height" | awk '{print $2}') newx=$(( x - w )) xpos=$(( newx - Gap )) xdotool windowmove "${window}" "${xpos}" "${Gap}"
Great. You should do a complete set for multiple monitors. I use these only on my laptop. Thanks for your input.