Hello there!
I’m using two monitors, and I’m looking for a way to programmatically move a window to the currently active screen, meaning the monitor my mouse is currently on.
I’ve been using GitHub - noctuid/tdrop: A Glorified WM-Independent Dropdown Creator for a while to create a dropdown terminal, and it works great - moving the terminal to whichever is my active screen. However, it doesn’t fully support Wayland.
I couldn’t find a direct alternative for Wayland, but I did find GitHub - jinliu/kdotool: xdotool-like for KDE Wayland which allows me to achieve a similar effect with some small bit of shell scripting. Here’s the script I’m currently using (activated via a Plasma hotkey):
#!/usr/bin/env bash
export STATE=/home/tk/.local/state/alacritty-dropdown
export KDOTOOL=/path/to/kdetool
export ALACRITTY=alacritty
if [ -z "$($KDOTOOL search --class alacritty)" ]; then
$ALACRITTY &
sleep 0.5
$KDOTOOL search --class alacritty windowstate --add SKIP_TASKBAR windowstate --add FULLSCREEN --toggle ABOVE
echo 1 >$STATE
fi
echo "State is: $STATE"
if [[ $(<$STATE) == 1 ]]; then
echo "Setting Window Below"
$KDOTOOL search --class alacritty windowstate --toggle BELOW
echo 0 >$STATE
else
echo "Setting Window Above"
$KDOTOOL search --class alacritty windowstate --add SKIP_TASKBAR windowstate --add FULLSCREEN --toggle ABOVE
echo 1 >$STATE
fi
I managed to achieve most of what I wanted, but kdotool doesn’t yet seem to support getting/setting the active screen of a window.
Does anyone know if there is a cli application which can get/set the active screen for an application window in KDE Plasma 6? Failing that, how can I otherwise programmatically get/set the active screen for a window?
Not sure it’s relevant for this question, but my current KDE Plasma 6 version is 6.3.6
Thank you kindly for reading!