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

How to check which workspace is currently focused from skript

asked Oct 25 '15

kyra gravatar image

Is it possible to check which workspace is currently focused and using this information in a bash script? I did some google research but didn't come up with anything useful ..

Comments

1

You may wanna read this: http://i3wm.org/docs/ipc.html

Airblader gravatar imageAirblader (Oct 25 '15)edit

1 answer

Sort by » oldest newest most voted
2

answered Oct 25 '15

Anon1234 gravatar image

Depends on what tool you can use for parsing json. With python you can do this oneliner:

$ focused_ws=$(i3-msg -t get_workspaces | python -c 'import json,sys;ws=json.load(sys.stdin);print(list(filter(lambda x: x["focused"], ws))[0]["name"])')
$ echo $focused_ws 
1: main

Comments

exactly what I was looking for works like a charm! Thanks!

kyra gravatar imagekyra (Oct 28 '15)edit

Question Tools

1 follower

Stats

Asked: Oct 25 '15

Seen: 55 times

Last updated: Oct 25