move-to-next-monitor icon indicating copy to clipboard operation
move-to-next-monitor copied to clipboard

Do not move the desktop window

Open wmwnuk opened this issue 2 years ago • 5 comments

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).

wmwnuk avatar Jan 22 '23 12:01 wmwnuk

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.

jc00ke avatar Jan 22 '23 21:01 jc00ke

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.

wmwnuk avatar Jan 25 '23 16:01 wmwnuk

Awesome, thanks @wmwnuk! If someone else can test it, then I'll accept the PR. I appreciate the contribution!

jc00ke avatar Jan 27 '23 18:01 jc00ke

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 avatar Feb 05 '23 16:02 riton

@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.

wmwnuk avatar Feb 06 '23 07:02 wmwnuk