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

Is there a way to define Emacs-style key binding?

asked 2013-01-11 11:57:38 +0000

Kelvin Hu gravatar image

updated 2013-01-11 11:58:52 +0000

Hi all,

I am an Emacs user, and I prefer to key binding like C-t C-f rather than Ctrl + Alt + f, I read the doc of I3, but seems there is no sections described this kind of key bindings, so, is there a way to do this, or is some hacking needed to implement this?

Thanks.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
2

answered 2013-01-11 18:04:37 +0000

joel gravatar image

updated 2013-01-11 18:07:32 +0000

Not sure if this is exactly what you're looking for, but you can try something like the following. It mimics the resize mode. I found this tip on the arch forums thread about i3.

resize {

# resize window (you can also use the mouse for that)
mode "resize" {
        # These bindings trigger as soon as you enter the resize mode

        # Pressing left will shrink the window’s width.
        # Pressing right will grow the window’s width.
        # Pressing up will shrink the window’s height.
        # Pressing down will grow the window’s height.
        bindsym h resize shrink width 10 px or 10 ppt
        bindsym j resize grow height 10 px or 10 ppt
        bindsym k resize shrink height 10 px or 10 ppt
        bindsym l resize grow width 10 px or 10 ppt

        # back to normal: Enher or Escape
        bindsym Return mode "default"
        bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"

}

launch mode {

mode "launch" {
        # c, chrome
        bindsym c exec chromium-browser, mode "default"
        # d, dock
        bindsym d exec dock, mode "default"
        # u, undock
        bindsym u exec undock, mode "default"


        # go back to normal (if we don't launch something)
        bindsym Return mode "default"
        bindsym Escape mode "default"
}
bindsym $mod+semicolon mode "launch"

}

so to launch chrome, i can do alt-; c the others (dock & undock) I use when docking my laptop at work (it runs disper to adjust what displays are used)

Edit: here is the aforementioned thread https://bbs.archlinux.org/viewtopic.p...

Also: can you nest modes? That could be useful!

edit flag offensive delete link more

Comments

Sorry, I am new to I3, so I did not notice the "mode" notion of it. I tried some code as you pasted, and it does work well. I also tried nested modes, but I3 would report en error while reloading the config file, so seems I3 does not support nested modes. And thanks for your answer.

Kelvin Hu gravatar imageKelvin Hu ( 2013-01-12 08:18:11 +0000 )edit

Thank you very much for explaining "modes"! I am also an Emacs user, and prefer to use CTRL as $mod. Now I have a mode "i3" bound to "CTRL+i", and I moved all typical i3 commands inside my i3 mode (except resizing, which would require nested modes). Everything works just fine! Thanks!

marcos gravatar imagemarcos ( 2014-09-09 08:51:44 +0000 )edit

Question Tools

Stats

Asked: 2013-01-11 11:57:38 +0000

Seen: 1,127 times

Last updated: Jan 11 '13