Re: [bit OT] Get focus window id?
Lukasz Grabowski <[email protected]>
| Newsgroups | gmane.comp.window-managers.openbox |
|---|---|
| Message-ID | <CAAh7rdyqowpEm35uJF9Woj5t75DZLJKgPxFAREm+BosHdrKj6Q@mail.gmail.com> |
Actually you can directly use the id given by xdotool in wmctrl.
As an example from my ~/bin, assuming that the active window is
zathura, the following will get the pdf file name which is currently
open (this file name is in the window title of zathura):
ZATHURA_WIN=$(printf '%x\n' $(xdotool getactivewindow))
FILE=`wmctrl -l | grep $ZATHURA_WIN | awk '{$1=$2=$3=""; print $0}' |
awk '{$1=$1}1'`
Best, Łukasz
2015-10-26 19:57 GMT+00:00 Sébastien <[email protected]>:
> le 2015-10-26, Ian écrivit:
>>Is there a way to determine which window has the focus, from a script?
>>I checked the old workhorse, wmctrl, but it doesn't seem capable of
>>this. There is the "-r :ACTIVE: " option, but it only works with the
>>action subcommands, not with the listing.
>
> xdotool to the rescue!
>
> Returns some kind of window id (not sure what it is):
> $ xdotool getwindowfocus
>
> Get the pid:
> $ xdotool getwindowpid $(xdotool getwindowfocus)
>
> Get the name of the program:
> cat /proc/$(xdotool getwindowpid $(xdotool getwindowfocus))/comm
>
> Hope this helps!
>
> --
> Sébastien
> _______________________________________________
> openbox mailing list
> [email protected]
> http://icculus.org/mailman/listinfo/openbox
_______________________________________________
openbox mailing list
[email protected]
http://icculus.org/mailman/listinfo/openbox