]> 91.132.146.200 Git - klimbim.git/commitdiff
code cleanup and added new script: center window
authorBanana <banana@starscream.de>
Thu, 12 Dec 2019 07:46:30 +0000 (08:46 +0100)
committerBanana <banana@starscream.de>
Thu, 12 Dec 2019 07:46:30 +0000 (08:46 +0100)
bash/center-window.sh [new file with mode: 0644]
bash/move-window.sh

diff --git a/bash/center-window.sh b/bash/center-window.sh
new file mode 100644 (file)
index 0000000..5d889d3
--- /dev/null
@@ -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
index 1086899637b06b7830201ab5dcc8c20db6927bd7..7d982c53bc0d97c310ff223f40e80c03d45307b1 100644 (file)
@@ -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