move-to-next-monitor
move-to-next-monitor copied to clipboard
Do not move the desktop window
Currently the script if run on an empty desktop will move the underlying desktop window to other monitor, leaving the previous monitor without root window (so, non-clickable, and any window that would appear there, leaves it's image there and all other not fun and confusing behaviors).
I added a simple if statement that prevents this. This will work only for Xfce, as desktop window class names on other desktop environments will differ, so this might be something to think about, unless we keep this script focused on Xfce, as other DEs might have the feature this script provides built-in (Plasma does if I recall correctly, not sure about GNOME).
Oof, yeah, that sounds bad!
I'm not opposed to this, I just don't have a way to test. If someone else can test it, I'd be inclined to merge; it sounds reasonable.
I also never intended for this to work on anything else than Xfce, so as long as it does work on Xfce, I'm good.
Okay, there was still an error in the script, and somehow I missed it. I corrected the condition (correct class was 'Xfdesktop') and returning 0 haven't actually been terminating the script, so changed it to exit and now it seems fine.
Awesome, thanks @wmwnuk! If someone else can test it, then I'll accept the PR. I appreciate the contribution!
Hi,
I've tested the proposed patch on
❯ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
with xdotool 1:3.20160805.1-4
It seems that the getwindowclassname
command is not supported on this version:
❯ xdotool getwindowclassname "$(xdotool getactivewindow)"
xdotool: Unknown command: getwindowclassname
Run 'xdotool help' if you want a command list
I'm absolutely not an xdotool
power user, but
❯ xdotool getwindowname "$(xdotool getactivewindow)"
Desktop
seems to do the trick for me.
Hope this helps.
Regards
@riton Thanks for testing!
That is quite weird, it has to be something about the way xdotool is built in Ubuntu, because it is pretty much the same version I have on Slackware.
Anyway, the window name is not really reliable, because it would be "Desktop" only if your locale is English, otherwise it might be something else.
So, I resorted to using xprop and awk to extract the window class, which will not rely on the weird xdotool inconsistency. Let me know if it works for you.