The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
0

Dzen2 instead of i3bar

asked 2014-10-16 14:44:06 +0000

AlexJ136 gravatar image

I'd like to use Dzen2 instead of i3bar. I'm comfortable with using i3-msg to display workspace information on a Dzen2 instance, but I'd also like to display the title of the active window.

I understand that the window title information is contained in the JSON dump returned by running "i3-msg -t get_tree", but I'm not sure of a reliable way to retrieve the title of the active window from this dump. I'm thinking I'll use a python script to do it, but I don't understand the structure of the i3 tree well enough.

Any guidance on how to retrieve this information is much appreciated.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2014-10-16 16:46:25 +0000

ANOKNUSA gravatar image

You could use xdotool, which can be found in many distribution repositories. The NETWM_NAME property of the currently focused window can be grabbed with

xdotool getwindowname $(xdotool getwindowfocus)

Otherwise you'd need to write a script to parse the JSON tree output.

edit flag offensive delete link more

Comments

I had to run `xdotool getwindowfocus | xargs xdotool getwindowname`, which works great. Thanks for pointing me at xdotool.

AlexJ136 gravatar imageAlexJ136 ( 2014-10-16 21:28:27 +0000 )edit

I didn't consider that my line works in Bash/Zsh, and not necessarily any other shells. :P Good to see you got it working.

ANOKNUSA gravatar imageANOKNUSA ( 2014-10-17 04:04:50 +0000 )edit

You also can use `xdotool getwindowfocus getwindowname`. This utilizes the command chaining feature of `xdotool`. You could also use `getactivewindow` instead of `getwindowfocus` as the man page states that it may be more reliable.

Adaephon gravatar imageAdaephon ( 2014-10-21 13:14:00 +0000 )edit

Question Tools

Stats

Asked: 2014-10-16 14:44:06 +0000

Seen: 527 times

Last updated: Oct 16 '14