aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYui Hirasawa <yui@cock.li>2016-12-23 21:54:14 +0200
committerjc00ke <jesse@jc00ke.com>2016-12-26 17:12:42 -0800
commit6ee1d53f5f2470ca41a6462cfb3e3cad21af664a (patch)
tree837e60943921b1e614d12da3095696fb72d61f2a
parentFixing the bug that always maximized the window after it was moved. This chan... (diff)
downloadmove-to-next-monitor-6ee1d53f5f2470ca41a6462cfb3e3cad21af664a.tar.gz
move-to-next-monitor-6ee1d53f5f2470ca41a6462cfb3e3cad21af664a.tar.bz2
move-to-next-monitor-6ee1d53f5f2470ca41a6462cfb3e3cad21af664a.zip
fix everything in the shellcheck
Signed-off-by: jc00ke <jesse@jc00ke.com>
-rwxr-xr-xmove-to-next-monitor62
1 files changed, 31 insertions, 31 deletions
diff --git a/move-to-next-monitor b/move-to-next-monitor
index 400054c..07a6ff0 100755
--- a/move-to-next-monitor
+++ b/move-to-next-monitor
@@ -12,64 +12,64 @@
# 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`
+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_horz_maxed=`xprop -id $window_id _NET_WM_STATE | grep '_NET_WM_STATE_MAXIMIZED_HORZ'`
-window_vert_maxed=`xprop -id $window_id _NET_WM_STATE | grep '_NET_WM_STATE_MAXIMIZED_VERT'`
+window_horz_maxed=$(xprop -id "$window_id" _NET_WM_STATE | grep '_NET_WM_STATE_MAXIMIZED_HORZ')
+window_vert_maxed=$(xprop -id "$window_id" _NET_WM_STATE | grep '_NET_WM_STATE_MAXIMIZED_VERT')
# Un-maximize current window so that we can move it
-wmctrl -ir $window_id -b remove,maximized_vert,maximized_horz
+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 }'`
+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`
+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=$(( x - x_offset))
+y=$(( y - y_offset))
# Compute new X position
-new_x=`expr $x + $display_width`
+new_x=$((x + display_width))
# Compute new Y position
-new_y=`expr $y + $display_height`
+new_y=$((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`
+width=$(xdotool getwindowgeometry "$window_id" | awk '/Geometry:/ { print $2 }'|cut -d"x" -f1)
+if [ "$(( new_x + width / 2))" -gt "$screen_width" ]; then
+ new_x=$((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`
+height=$(xdotool getwindowgeometry "$window_id" | awk '/Geometry:/ { print $2 }'|cut -d"x" -f2)
+if [ "$((new_y + height / 2))" -gt "$screen_height" ]; then
+ new_y=$((new_y - screen_height))
fi
# Don't move off the left side.
-if [ $new_x -lt 0 ]; then
- new_x=0
+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
+if [ "$new_y" -lt 0 ]; then
+ new_y=0
fi
# Move the window
-xdotool windowmove $window_id $new_x $new_y
+xdotool windowmove "$window_id" "$new_x" "$new_y"
# Maximize window again, if it was before
-if [ -n "${window_horz_maxed}" -a -n "${window_vert_maxed}" ]; then
- wmctrl -ir $window_id -b add,maximized_vert,maximized_horz
+if [ -n "${window_horz_maxed}" ] && [ -n "${window_vert_maxed}" ]; then
+ wmctrl -ir "$window_id" -b add,maximized_vert,maximized_horz
elif [ -n "${window_horz_maxed}" ]; then
- wmctrl -ir $window_id -b add,maximized_horz
+ wmctrl -ir "$window_id" -b add,maximized_horz
elif [ -n "${window_vert_maxed}" ]; then
- wmctrl -ir $window_id -b add,maximized_vert
+ wmctrl -ir "$window_id" -b add,maximized_vert
fi
bgstack15