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 Oct 16 '14

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.

1 answer

Sort by » oldest newest most voted
0

answered Oct 16 '14

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.

Comments

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

AlexJ136 gravatar imageAlexJ136 (Oct 16 '14)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 (Oct 17 '14)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 (Oct 21 '14)edit

Question Tools

Stats

Asked: Oct 16 '14

Seen: 527 times

Last updated: Oct 16 '14