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 · 13 comments

Comments

Projects
None yet
@tuffnerdstuff

tuffnerdstuff commented Dec 7, 2012

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

This comment has been minimized.

Show comment
Hide comment
@lemzwerg

lemzwerg Dec 22, 2012

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

lemzwerg commented Dec 22, 2012

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

@worenga

This comment has been minimized.

Show comment
Hide comment
@worenga

worenga Sep 6, 2013

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

worenga commented Sep 6, 2013

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

@jordansissel

This comment has been minimized.

Show comment
Hide comment
@jordansissel

jordansissel Sep 6, 2013

Owner

I'll see what I can do.

Owner

jordansissel commented Sep 6, 2013

I'll see what I can do.

@jordansissel

This comment has been minimized.

Show comment
Hide comment
@jordansissel

jordansissel Sep 6, 2013

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.

Owner

jordansissel commented Sep 6, 2013

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

- consume regexp argument only if present. This fixes a warning reported
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

This comment has been minimized.

Show comment
Hide comment
@jordansissel

jordansissel Sep 6, 2013

Owner

Fixed the warning! :)

Owner

jordansissel commented Sep 6, 2013

Fixed the warning! :)

@javierabreu

This comment has been minimized.

Show comment
Hide comment
@javierabreu

javierabreu May 7, 2014

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"

javierabreu commented May 7, 2014

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

This comment has been minimized.

Show comment
Hide comment
@aboettger

aboettger May 29, 2014

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

aboettger commented May 29, 2014

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

@PlasmaPower

This comment has been minimized.

Show comment
Hide comment
@PlasmaPower

PlasmaPower May 3, 2015

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

PlasmaPower commented May 3, 2015

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

This comment has been minimized.

Show comment
Hide comment
@cosmoharrigan

cosmoharrigan Jan 12, 2016

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

$ xdotool --version
xdotool version 3.20160112.1

cosmoharrigan commented Jan 12, 2016

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

$ xdotool --version
xdotool version 3.20160112.1
@hilbix

This comment has been minimized.

Show comment
Hide comment
@hilbix

hilbix 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

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

This comment has been minimized.

Show comment
Hide comment
@anthonybakermpls

anthonybakermpls Feb 26, 2017

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.

anthonybakermpls commented Feb 26, 2017

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

This comment has been minimized.

Show comment
Hide comment
@Hibou57

Hibou57 Sep 8, 2017

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

Hibou57 commented Sep 8, 2017

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

@Hibou57

This comment has been minimized.

Show comment
Hide comment
@Hibou57

Hibou57 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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment