The i3 FAQ has migrated to https://www.reddit.com/r/i3wm/. All content here is read-only.
Ask Your Question
0

Obtain info on current workspace etc.

asked 2015-06-25 12:37:43 +0000

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?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2015-06-25 12:52:47 +0000

Airblader gravatar image

updated 2015-06-25 12:53:29 +0000

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

edit flag offensive delete link more

Comments

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

Alois Mahdal gravatar imageAlois Mahdal ( 2015-06-25 13:19:57 +0000 )edit
3

answered 2015-06-25 13:47:03 +0000

Alois Mahdal gravatar image

updated 2015-11-17 06:10:12 +0000

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

edit flag offensive delete link more

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 ( 2015-06-25 20:01:53 +0000 )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 ( 2015-11-26 18:51:45 +0000 )edit

Question Tools

1 follower

Stats

Asked: 2015-06-25 12:37:43 +0000

Seen: 131 times

Last updated: Nov 17