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

application switcher?

asked 2013-03-02 16:35:59 +0000

thuswa gravatar image

I find my self lost among all workspaces and application windows. Is there an application switcher that can be used with i3? Or is there a way to get something similar. All I want is a list of the active application widows which I can tab through to switch to the window i want to go to next.

TIA

Albert

edit retag flag offensive close merge delete

Comments

awesome question!

bruno.braga gravatar imagebruno.braga ( 2013-03-04 14:02:11 +0000 )edit

6 answers

Sort by ยป oldest newest most voted
3

answered 2013-03-02 17:40:52 +0000

lkraav gravatar image

Not sure if this isn't a duplicate of my question: https://faq.i3wm.org/question/228/how...

Anyway, the i3-py solution there works great for me.

edit flag offensive delete link more
1

answered 2013-03-04 02:25:12 +0000

Mario Sandler gravatar image
echo -ne "i3-ipc\x0\x0\x0\x0\x4\x0\x0\x0" | 
    socat STDIO UNIX-CLIENT:`i3 --get-socketpath` | 
    tail -c +15 |
    sed -e 's/"id":/\n"id":/g' | 
    sed -ne 's/.*"name":"\([^"]\+\)".*"window":\([0-9]\+\).*/\1 \2/p' |
    dmenu -i -l 7 -b |
    sed -ne 's/.* \([0-9]*\)/[id=\1] focus/p' |
    (read cmd; i3-msg "$cmd")
edit flag offensive delete link more

Comments

neat... but neither this nor the simpleswitcher can grab a window from scratchpad... (not sure how should be the behaviour though)... they are in the list, but nothing happens.

bruno.braga gravatar imagebruno.braga ( 2013-03-04 14:03:19 +0000 )edit

Parsing JSON in shell is really fugly and fragile. I recommend not using this solution (or any other shell solution).

Michael gravatar imageMichael ( 2013-03-05 10:37:28 +0000 )edit

yes that one was a joke. i'm currently using this https://gist.github.com/anonymous/5152046

Mario Sandler gravatar imageMario Sandler ( 2013-03-13 13:31:14 +0000 )edit
0

answered 2015-06-08 21:50:51 +0000

chilicuil gravatar image

I reworked Rasi solution to avoid python and bash, it behaves exactly the same but with less dependencies (dmenu and sh)

https://github.com/minos-org/minos-to...

edit flag offensive delete link more
0

answered 2014-05-10 17:54:45 +0000

sml gravatar image

updated 2014-05-10 17:56:39 +0000

I'm using a ruby script, with this map:

bindsym $mod+g exec ~/.i3/window-jump

The advantages of this script are that it only requires dmenu, finds windows in the scratch space, and focuses by unique ID rather than title.

#!/usr/bin/ruby
require 'json'

# recursively walk tree to find all containers
# return an array of names followed by [id]
def get_containers tree
    containers = []
    # try to return only useful containers
    if (tree['nodes']+tree['floating_nodes']).empty? && tree['type'] == 2 &&
        !(tree['name'] =~ /^i3bar for output/)
        containers << tree['name'] + " [#{tree['id']}]"
    end
    (tree['nodes'] + tree['floating_nodes']).each do |node|
        containers += get_containers(node)
    end
    containers
end

IO.popen(['dmenu', '-i', '-p', 'window jump'], 'r+') do |dmenu|
    dmenu.puts(get_containers(JSON.load(`i3-msg -t get_tree`)))
    dmenu.close_write
    id = dmenu.read.split(/\[|\]/).last
    exec "i3-msg [con_id=#{id}] focus"
end
edit flag offensive delete link more
0

answered 2013-03-02 16:39:38 +0000

Rasi gravatar image
#!/bin/bash
#source ~/.config/teiler/config
DMENU_OPTS="-fn "Source\Code\Pro-12" -nb #000000 -nf #a0a0a0 -sb #0c73c2 -sf #ffffff -l 18 -p $(basename $0)"

# Present a menu with all windows
TITLE="$(i3-msg -t get_tree | python -mjson.tool | sed -n -e 's/^ \{35\}[ ]\+\"name\": \"\(.*\)\", $/\1/p' | sed '/^#[a-F0-9]\{6\}$/d' | dmenu $DMENU_OPTS)"

if [ -z "$TITLE" ] ; then
   exit 1
fi

# Escape some characters to prevent i3 to interpret them as a pattern
# "(" and ")" replaced with "\(" and "\)"
TITLE="$(echo "$TITLE" | sed 's/\([()]\)/\\\1/g')"

# Focus window
i3-msg "[title=\"$TITLE\"] focus"
edit flag offensive delete link more

Comments

thanks for your reply. I'll maybe try that approach as well in the near future.

thuswa gravatar imagethuswa ( 2013-03-02 22:18:50 +0000 )edit
0

answered 2013-03-02 16:39:05 +0000

badboy_ gravatar image

I use quickswitch (or the original one in python: quickswitch.py).

There is also a more fancy version: simpleswitcher

edit flag offensive delete link more

Comments

thanks for that one, I settled with quickswitch.py it works as expected.

thuswa gravatar imagethuswa ( 2013-03-02 22:17:34 +0000 )edit

quickswitch works well, but does anyone know how to enlarge its font?

oldos2er gravatar imageoldos2er ( 2013-12-10 20:02:51 +0000 )edit

@oldos2er: It simply uses dmenu, with the python version you can specify the command using the `-d` (or `--dmenu`) switch to quickswitch.py, my ruby version has the command hardcoded in the source.

badboy_ gravatar imagebadboy_ ( 2013-12-16 10:29:04 +0000 )edit

Question Tools

3 followers

Stats

Asked: 2013-03-02 16:35:59 +0000

Seen: 3,406 times

Last updated: Jun 08