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

Obtain info on current workspace etc.

asked Jun 25 '15

Alois Mahdal gravatar image

How do I just get info about current settings like current workspace?

For example, from a script I want to decide based on name of the current desktop,

The background is that I have $mod+b for web browser, but I have 2 profiles: home and work. I also have a dedicated set of home and work worplaces. So I want to use a browser launcher that will choose the browser profile based on which workspace I am on. (I'm OK with the fact that the window may get moved later).

So is there a generic way (ie a i3-msg command) for getting info?

2 answers

Sort by » oldest newest most voted
1

answered Jun 25 '15

Airblader gravatar image

updated Jun 25 '15

See the i3ipc documentation. To find out how to call i3-msg, use man i3-msg.

Comments

thanks, that is exactly what I needed. (can't upvote, though--karma<10)

Alois Mahdal gravatar imageAlois Mahdal (Jun 25 '15)edit
3

answered Jun 25 '15

Alois Mahdal gravatar image

updated Nov 17 '15

Airblader gravatar image

As addition to @Airblader's answer, here's the code to get focused workspace name using i3-msg and jq (an awesome command-line JSON processor):

#!/bin/sh
i3-msg -t get_workspaces \
  | jq '.[] | select(.focused==true).name' \
  | cut -d"\"" -f2

Update: Reduced (and hardened) the command pipe even more with @Airblader's help

Comments

2

You can shrink that down a lot with i3-msg -t get_workspaces | jq '.[] | select(.focused==true).name' | cut -d"\"" -f2

Airblader gravatar imageAirblader (Jun 25 '15)edit

jq has a "-r" option that'll achieve the same as the "cut", so unless I'm missing something you can do just i3-msg -t get_workspaces | jq -r '.[] | select(.focused==true).name'

Vidar gravatar imageVidar (Nov 26 '15)edit

Question Tools

1 follower

Stats

Asked: Jun 25 '15

Seen: 131 times

Last updated: Nov 17