summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Babič2015-09-09 21:21:06 +0200
committerPeter Babič2015-09-09 21:21:06 +0200
commit914c3be7bb1deeaca0ca87b026735584a7f9f2f3 (patch)
treef0a203ce67b0fe8df7b602654ccccc5e13b1d227
downloadaur-914c3be7bb1deeaca0ca87b026735584a7f9f2f3.tar.gz
Initial import
-rw-r--r--.SRCINFO13
-rw-r--r--.gitignore17
-rw-r--r--PKGBUILD26
-rwxr-xr-xmtnm72
4 files changed, 128 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..89c730dace9b
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,13 @@
+pkgbase = mtnm
+ pkgdesc = Moves window to next monitor / screen
+ pkgver = 2012.05.23
+ pkgrel = 1
+ url = http://icyrock.com/blog/2012/05/xubuntu-moving-windows-between-monitors/
+ arch = any
+ license = unknown
+ depends = xdotool wmctrl
+ source = mtnm
+ md5sums = dc2fb22fb51cf83634474c7740dbfcf2
+
+pkgname = mtnm
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..9b97681014e9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,17 @@
+*.zip
+*.jar
+*.tar
+*.tgz
+*.tbz2
+*.gz
+*.bz2
+*.xz
+*.gem
+*.run
+*.deb
+*.rpm
+*.sig
+*.log
+/src
+/pkg
+*.kate-swp
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..77bb14664f37
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,26 @@
+# Maintainer: Peter Babič <babicpet at gmail dot com>
+pkgname=mtnm
+pkgver=2012.05.23
+pkgrel=1
+pkgdesc="Moves window to next monitor / screen"
+arch=(any)
+url="http://icyrock.com/blog/2012/05/xubuntu-moving-windows-between-monitors/"
+license=('unknown')
+groups=()
+depends=('xdotool' 'wmctrl')
+makedepends=()
+optdepends=()
+provides=()
+conflicts=()
+replaces=()
+backup=()
+options=()
+install=
+changelog=
+source=('mtnm')
+noextract=()
+md5sums=('c64f49268124746d83eb634aa6b9bbd0')
+
+package() {
+ install -Dm755 "$srcdir"/mtnm "$pkgdir"/usr/bin/mtnm
+}
diff --git a/mtnm b/mtnm
new file mode 100755
index 000000000000..84eb8b758aeb
--- /dev/null
+++ b/mtnm
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+#
+# Move the current window to the next monitor.
+#
+# Also works only on one X screen (which is the most common case).
+#
+# Props to
+# http://icyrock.com/blog/2012/05/xubuntu-moving-windows-between-monitors/
+# http://makandracards.com/makandra/12447-how-to-move-a-window-to-the-next-monitor-on-xfce-xubuntu
+#
+# Unfortunately, both "xdotool getwindowgeometry --shell $window_id" and
+# checking "-geometry" of "xwininfo -id $window_id" are not sufficient, as
+# the first command does not respect panel/decoration offsets and the second
+# will sometimes give a "-0-0" geometry. This is why we resort to "xwininfo".
+
+screen_width=`xdpyinfo | awk '/dimensions:/ { print $2; exit }' | cut -d"x" -f1`
+screen_height=`xdpyinfo | awk '/dimensions:/ { print $2; exit }' | cut -d"x" -f2`
+display_width=`xdotool getdisplaygeometry | cut -d" " -f1`
+display_height=`xdotool getdisplaygeometry | cut -d" " -f2`
+window_id=`xdotool getactivewindow`
+
+# Remember if it was maximized.
+window_state=`xprop -id $window_id _NET_WM_STATE | awk '{ print $3 }'`
+
+# Un-maximize current window so that we can move it
+wmctrl -ir $window_id -b remove,maximized_vert,maximized_horz
+
+# Read window position
+x=`xwininfo -id $window_id | awk '/Absolute upper-left X:/ { print $4 }'`
+y=`xwininfo -id $window_id | awk '/Absolute upper-left Y:/ { print $4 }'`
+
+# Subtract any offsets caused by panels or window decorations
+x_offset=`xwininfo -id $window_id | awk '/Relative upper-left X:/ { print $4 }'`
+y_offset=`xwininfo -id $window_id | awk '/Relative upper-left Y:/ { print $4 }'`
+x=`expr $x - $x_offset`
+y=`expr $y - $y_offset`
+
+# Compute new X position
+new_x=`expr $x + $display_width`
+# Compute new Y position
+new_y=`expr $y + $display_height`
+
+# If we would move off the right-most monitor, we set it to the left one.
+# We also respect the window's width here: moving a window off more than half its width won't happen.
+width=`xdotool getwindowgeometry $window_id | awk '/Geometry:/ { print $2 }'|cut -d"x" -f1`
+if [ `expr $new_x + $width / 2` -gt $screen_width ]; then
+ new_x=`expr $new_x - $screen_width`
+fi
+
+height=`xdotool getwindowgeometry $window_id | awk '/Geometry:/ { print $2 }'|cut -d"x" -f2`
+if [ `expr $new_y + $height / 2` -gt $screen_height ]; then
+ new_y=`expr $new_y - $screen_height`
+fi
+
+# Don't move off the left side.
+if [ $new_x -lt 0 ]; then
+ new_x=0
+fi
+
+# Don't move off the bottom
+if [ $new_y -lt 0 ]; then
+ new_y=0
+fi
+
+# Move the window
+xdotool windowmove $window_id $new_x $new_y
+
+# Maximize window again, if it was before
+if [ -n "${window_state}" ]; then
+ wmctrl -ir $window_id -b add,maximized_vert,maximized_horz
+fi