From 8f94be1816bd5fa26e1b2e7d0b8d6ca6ab98dde5 Mon Sep 17 00:00:00 2001 From: Banana Date: Mon, 23 Jan 2023 14:42:41 +0100 Subject: [PATCH] well the script is needed... --- bash/move-window-to-current-workspace.sh | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 bash/move-window-to-current-workspace.sh diff --git a/bash/move-window-to-current-workspace.sh b/bash/move-window-to-current-workspace.sh new file mode 100644 index 0000000..5dc0e24 --- /dev/null +++ b/bash/move-window-to-current-workspace.sh @@ -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 + -- 2.39.5