From: Banana Date: Thu, 12 Dec 2019 07:46:30 +0000 (+0100) Subject: code cleanup and added new script: center window X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=fe64ac944d7e44fccac87412a1f7e7d527487c1c;p=klimbim.git code cleanup and added new script: center window --- diff --git a/bash/center-window.sh b/bash/center-window.sh new file mode 100644 index 0000000..5d889d3 --- /dev/null +++ b/bash/center-window.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Center the current actve window based on screen and window size +# create a kyboard shortcut to execute the script + +# needs the following applications +# xdotool +# xdpyinfo + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE +# +# You should have received a copy of the +# COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 +# along with this program. If not, see http://www.sun.com/cddl/cddl.html + +# 2019 https://www.bananas-playground.net + +screenWidth=$(xdpyinfo | awk -F" |x" '/dimensions:/ { print $7 }') +screenHeight=$(xdpyinfo | awk -F" |x" '/dimensions:/ { print $8 }') +window_id=$(xdotool getactivewindow) + +width=$(xdotool getwindowgeometry $window_id | awk -F" |x" '/Geometry:/ { print $4 }') +height=$(xdotool getwindowgeometry $window_id | awk -F" |x" '/Geometry:/ { print $5 }') + +newPosX=$((screenWidth/2-width/2)) +newPosY=$((screenHeight/2-height/2)) + +xdotool getactivewindow windowmove "$newPosX" "$newPosY" \ No newline at end of file diff --git a/bash/move-window.sh b/bash/move-window.sh index 1086899..7d982c5 100644 --- a/bash/move-window.sh +++ b/bash/move-window.sh @@ -1,5 +1,5 @@ #!/bin/bash -# + # Move the current window to the next monitor. # # original code from: @@ -23,7 +23,7 @@ # COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 # along with this program. If not, see http://www.sun.com/cddl/cddl.html -# 2018-2019 http://www.bananas-playground.net +# 2018-2019 https://www.bananas-playground.net # set this variable to your monitor count