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 Mar 2 '13

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

Comments

awesome question!

bruno.braga gravatar imagebruno.braga (Mar 4 '13)edit

6 answers

Sort by » oldest newest most voted
3

answered Mar 2 '13

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.

1

answered Mar 4 '13

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")

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 (Mar 4 '13)edit

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

Michael gravatar imageMichael (Mar 5 '13)edit

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

Mario Sandler gravatar imageMario Sandler (Mar 13 '13)edit
0

answered Jun 8 '15

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...

0

answered May 10 '14

sml gravatar image

updated May 10 '14

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
0

answered Mar 2 '13

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"

Comments

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

thuswa gravatar imagethuswa (Mar 2 '13)edit
0

answered Mar 2 '13

badboy_ gravatar image

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

There is also a more fancy version: simpleswitcher

Comments

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

thuswa gravatar imagethuswa (Mar 2 '13)edit

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

oldos2er gravatar imageoldos2er (Dec 10 '13)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_ (Dec 16 '13)edit

Question Tools

3 followers

Stats

Asked: Mar 2 '13

Seen: 3,406 times

Last updated: Jun 08