Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not move the desktop window #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

wmwnuk
Copy link

@wmwnuk wmwnuk commented Jan 22, 2023

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

@jc00ke
Copy link
Owner

jc00ke commented Jan 22, 2023

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.

@wmwnuk
Copy link
Author

wmwnuk commented Jan 25, 2023

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.

@jc00ke
Copy link
Owner

jc00ke commented Jan 27, 2023

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

@riton
Copy link

riton commented Feb 5, 2023

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

@wmwnuk
Copy link
Author

wmwnuk commented Feb 6, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants