Kput

Various KDE 1.-4. Improvements

Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net

0
Score 70.0%
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.

9

BastianBalthazarreBux

7 years ago

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}"

Report

C

jaugen

7 years ago

Great. You should do a complete set for multiple monitors. I use these only on my laptop. Thanks for your input.

Report

12345678910
4
product-maker nikore90 Dec 30 2011 9 excellent
product-maker BastianBalthazarreBux Dec 23 2011 9 excellent
product-maker AlexeyK Dec 23 2011 9 excellent
product-maker vitoubien Dec 23 2011 9 excellent
product-maker Base: 4 x 5.0 Ratings
Be the first to comment
File (click to download) Version Description PackagetypeArchitecture Downloads Date Filesize DL OCS-Install MD5SUM
*Needs pling-store or ocs-url to install things
Pling
0 Affiliates
Details
license
version
1.0
updated Dec 23 2011
added Dec 23 2011
downloads 24h
0
mediaviews 24h 0
pageviews 24h 3