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

Buggy behaviour for "xdotool search --pid <pid>" #14

Open
tuffnerdstuff opened this issue Dec 7, 2012 · 14 comments · May be fixed by #267
Open

Buggy behaviour for "xdotool search --pid <pid>" #14

tuffnerdstuff opened this issue Dec 7, 2012 · 14 comments · May be fixed by #267

Comments

@tuffnerdstuff
Copy link

input: xdotool search --pid <program_pid>
output Can't consume 1 args; are only 0 available. This is a bug.
version: xdotool version 2.20110530.1
system: Arch Linux (3.6.8-1-ARCH)
I wanted to use xdotool in a shell-script to wait for X applications to be visible. Therefore I issued a command like this:

xdotool search --onlyvisible --sync --pid 1234

The output was this: Can't consume 1 args; are only 0 available. This is a bug.

I narrowed down the issue to the --pid option, which causes the aforementioned error message.

@lemzwerg
Copy link

I got exactly the same problem. Given the usefulness of this option, I would value this as a high-priority bug.

@worenga
Copy link

worenga commented Sep 6, 2013

A workaround seems to be to also provide the --name parameter for the given pid

@jordansissel
Copy link
Owner

I'll see what I can do.

@jordansissel
Copy link
Owner

Searching by pid works for me on master:

% ./xdotool search --pid 2593
Can't consume 1 args; are only 0 available. This is a bug.
54525953
54527731
54525955

The only bug is that it warns you about consuming args. I'll fix that.

jordansissel added a commit that referenced this issue Sep 6, 2013
in #14.

Tests showing no more warning:

  # find all windows with pid 2593
  % ./xdotool search --pid 2593
  54525953
  54527731
  54525955

  # find all windows with pid 2593 *and* name matches 'tmux'
  % ./xdotool search --all --name --pid 2593 tmux
  54525955

  # find all visible windows with pid 2593
  % ./xdotool search --onlyvisible --pid 2593
  54525955
@jordansissel
Copy link
Owner

Fixed the warning! :)

@javierabreu
Copy link

Ubuntu Gnome 14.04
xdotool version 3.20140217.1
Bug is still present

xdotool search --pid 7558
Can't consume 1 args; are only 0 available. This is a bug.

Ugly workaround:

xdotool search --any --pid 7558 --name "dummy_name_bug_workaround_1gqbvy4o5y8bw3ov5"

@aboettger
Copy link

This is a distribution-specific problem. The latest version on GitHub works.

@PlasmaPower
Copy link

It seems to still happen to some degree in the latest version. Example:

$ xdotool version
xdotool version 3.20150503.1
$ xdotool search --pid $$
$ xdotool search --any --pid $$ --name "nonexistantname"
48234503

@cosmoharrigan
Copy link

Search by process ID does not work with the latest version:

$ xdotool --version
xdotool version 3.20160112.1

@hilbix
Copy link

hilbix commented Dec 20, 2016

$ ./xdotool.static version
xdotool version 3.20161220.1

search --pid still has a bug. Just muting the warning about the bug does not make the bug go away.

$ ./xdotool.static search --onlyvisible --pid 31981 windowactivate %@
Defaulting to search window name, class, and classname
./xdotool.static: Unknown command: %@
Run './xdotool.static help' if you want a command list
$

does nothing, while

$ ./xdotool.static search --any --onlyvisible --pid 31981 --name "this_window_name_does_not_exist_sqr13rkckf_this_window_name_does_not_exist_sqr13rkckf_this_window_name_does_not_exist_sqr13rkckf_this_window_name_does_not_exist_sqr13rkckf_this_window_name_does_not_exist_sqr13rkckf" windowactivate %@
$

works as expected (and no output whatsoever and the window is activated).

To others: Please note that --pid needs the WindowManager option _NET_WM_PID to be set by the application, which is not the default. For more on this, see http://stackoverflow.com/a/13482052/490291

@anthonybakermpls
Copy link

anthony@bluegreen:~/Data/Code$ xdotool search --pid 15188
Segmentation fault (core dumped)

even if the _NET_WM_PID isn't set it would be nice if we didn't crash.

@Hibou57
Copy link

Hibou57 commented Sep 8, 2017

@javierabreu, there is a simpler work around, redirecting standard error to /dev/null: xdotool … 2>/dev/null.

@Hibou57
Copy link

Hibou57 commented Sep 8, 2017

By the way, there are other strange behaviours with options.

This one works:

search --all --onlyvisible --pid 23507 --class surf

This one does not work, complaining “xdotool: Unknown command: --pid”:

search --all --onlyvisible --class surf --pid 23507

@ipaqmaster
Copy link

Tried to search --pid 12345 with xdotool 3.20211022.1 today and while that works I've noticed if you pass additional arguments to do something with the resulting window, matched by pid, xdotool throws Defaulting to search window name, class, classname, and role instead of treating the --pid argument as a valid solo search parameter.

One shouldn't need to call a nested $(xdotool search --pid $(ps filter for pid by name)) as an argument to xdotool just to return a window ID it can action upon. --pid should be a valid searching parameter on its own.

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 a pull request may close this issue.