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

xdotool search doesn't work anymore #67

Open
illnerb opened this issue May 18, 2015 · 7 comments
Open

xdotool search doesn't work anymore #67

illnerb opened this issue May 18, 2015 · 7 comments

Comments

@illnerb
Copy link

illnerb commented May 18, 2015

I used the following Code in a bash script to copy the url from firefox to the clipboard:

xdotool search "Mozilla Firefox" windowactivate --sync key --clearmodifiers ctrl+l ctrl+c

This code worked fine a few weeks ago. But now I get this error:

Defaulting to search window name, class, and classname
XGetWindowProperty[_NET_WM_DESKTOP] failed (code=1)

The following code still works for me:

WID=$(xdotool search "Mozilla Firefox" | head -1)
xdotool windowactivate --sync $WID
xdotool key --clearmodifiers ctrl+l ctrl+c

xdotool version 3.20150503.1

@Ganton
Copy link

Ganton commented Jun 5, 2015

This bug is probably related to that one?
https://code.google.com/p/semicomplete/issues/detail?id=66

@phil294
Copy link
Contributor

phil294 commented Oct 19, 2017

this is still very much relevant. --desktop 0 doesnt help always, for example xdotool search --desktop 0 --pid 19966 windoactivate returns Defaulting to search window name, class, and classname.

@Lupccs
Copy link

Lupccs commented Aug 20, 2018

I think it has something to do with either

xdotool mousemove --screen 2 --polar 0 0
a command with I added to the autostart, or - more likely

sudo apt install adobe-flashplugin browser-plugin-freshplayer-pepperflash

The mentioned problem began after I made this two chages. Reverting to previous situation (and removing, re-creating and re-synchronizing a chromium profile ) made xdotool work perfectly. I came to this conclusion before that command worked only on the chromium profile that didn't had anything to do with flash.

@phil294
Copy link
Contributor

phil294 commented Jul 25, 2022

Since it's now the third time I think I have googled for this error, I have investigated this a bit and think I know what's going on here. xdotool seems to work correctly. With an example:

xdotool search --name Signal windowactivate sometimes yields the mentioned error. This is because the search actually returns multiple window ids, out of which the first is being used for windowactivate.

$ xdotool search --name Signal
> 92274691
> 92274689
> 90177538
> 65011724

However, 92274691 does not exist, I think it's because it is unmapped. You can try to map it with xdotool windowmap 92274691 but that might not work. In other words, Signal has multiple windows going, but only one of them is the actual user interface. You can show their respective names with xdotool getwindowname ID: In my case, they are

signal-desktop
signal-desktop
Signal
...twindowname 65011724

with the last one being the name of my terminal session which displays the name of the currently executing command. This one shows getwindowname right now, but while doing the search thing, it contains Signal as well. These are all caught because search --name does a case insensitive regex search (in other words, a simple "contains" check).

The reason why --desktop your-current-desktop-number sometimes works is because it might limit the search to the one window you are looking for.

The proper solution to all of this is either using more specific search params, iterating the resulting ids or use --onlyvisible: xdotool search --onlyvisible --name Signal windowactivate

Edit:

I think I missed something here: visible/invisible is only half the truth, as the search can also yield windows that are on no desktop id. For example, for Firefox, there is always a window which returns

xdotool getwindowgeometry [win id]
Window 94372128
  Position: -99,-99 (screen: 0)
  Geometry: 1x1

and

xdotool get_desktop_for_window [win id]
XGetWindowProperty[_NET_WM_DESKTOP] failed (code=1)
-1

However, as there is no search --onlyonexistingdesktops option, I think the only proper solution to finding the desired is as follows:

xdotool search --onlyvisible --desktop "$(xdotool get_desktop)" --name ...

@anirbanchakrabarty
Copy link

same type of issue over here.using FC38. xdotool mouseove does not work ;hence does not click.i used it in fc9 fine. in fc 38 i get error as follows: Crash Annotation GraphicsCriticalError: |[0][GFX1-]: vaapitest: ERROR (t=0.752664) [GFX1-]: vaapitest: ERROR
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: vaapitest: ERROR (t=0.752664) |[1][GFX1-]: vaapitest: VA-API test failed: failed to initialise VAAPI connection.
(t=0.752699) [GFX1-]: vaapitest: VA-API test failed: failed to initialise VAAPI connection.

@paul1149
Copy link

paul1149 commented Mar 21, 2024

I'm having a similar problem. I'm on MX Linux 23 (debian 12) with KDE desktop environment. I wrote a script yesterday which toggles Thunderbird being active or hidden as a panel icon. The script worked perfectly, then suddenly it would hide Thunderbird but not activate it. The script:

#!/usr/bin/sh

visible=$(xdotool search --name --onlyvisible "Mozilla Thunderbird")

if [ $visible -ne "0" ]  ; then
	echo Thunderbird is visible, will hide
	xdotool windowminimize $visible
else
	hidden=$(xdotool search --name "Mozilla Thunderbird")
#	echo $hidden
	echo Thunderbird is hidden, will activate
	xdotool windowactivate $hidden
fi

Here is the output:

./thunderbird_toggle.sh: 5: [: -ne: unexpected operator
Thunderbird is hidden, will activate
XGetWindowProperty[_NET_WM_DESKTOP] failed (code=1)

The only thing I can think of is that in the interim I accidentally hit Meta-t, which under KDE is custom tile the desktop. I had never done that before and didn't know it existed. Could that have changed some desktop issue under the hood?

@anirbanchakrabarty
Copy link

anirbanchakrabarty commented Mar 21, 2024 via email

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

No branches or pull requests

6 participants