]> 91.132.146.200 Git - klimbim.git/commitdiff
well the script is needed...
authorBanana <banana@starscream.de>
Mon, 23 Jan 2023 13:42:41 +0000 (14:42 +0100)
committerBanana <banana@starscream.de>
Mon, 23 Jan 2023 13:42:41 +0000 (14:42 +0100)
bash/move-window-to-current-workspace.sh [new file with mode: 0644]

diff --git a/bash/move-window-to-current-workspace.sh b/bash/move-window-to-current-workspace.sh
new file mode 100644 (file)
index 0000000..5dc0e24
--- /dev/null
@@ -0,0 +1,42 @@
+#!/usr/bin/env -S bash -e
+
+# Get a window of a workspace indentified by a name
+# Not very safe in case of errors. Use at onw risk
+
+# 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
+
+# 2023 https://www.bananas-playground.net
+
+
+# needs xdotool, wmctrl, xprop, wmctrl
+
+if [ -z "$1" ]
+  then
+    echo "Missing string to search for"
+       exit 1;
+fi
+
+WINDOWNAME_TO_SEARCH=$1
+CURRENT_WORKSPACE=$(xdotool get_desktop)
+
+HEX_ID=$(wmctrl -lx | grep -i ${WINDOWNAME_TO_SEARCH} | awk '{print $1}')
+WINDOW_ID=$(printf "%d" ${HEX_ID})
+
+# remember if it was maximized
+WINDOW_STAGE=$(xprop -id ${WINDOW_ID=} _NET_WM_STATE | awk '{ print $3 }')
+
+# Un-maximize current window so that it can be moved
+wmctrl -ir ${WINDOW_ID=} -b remove,maximized_vert,maximized_horz
+
+xdotool set_desktop_for_window ${WINDOW_ID} ${CURRENT_WORKSPACE} && xdotool windowactivate ${WINDOW_ID}
+
+# Maximize if it was before the move
+if [ "${WINDOW_STAGE=}" = "_NET_WM_STATE_MAXIMIZED_HORZ," ]; then
+    wmctrl -ir ${WINDOW_ID=} -b add,maximized_vert,maximized_horz
+fi
+