#i3 #window-manager #config-file

app i3-bindings

Simple tool that reads the i3 config files and shows a table with the bindings defined therein

2 stable releases

1.0.1 Jun 9, 2020

#438 in Configuration

MIT license

32KB
221 lines

i3-bindings

Crates.io

CI_build_and_release

Simple tool that reads the i3 config files and shows a table with the bindings defined therein. See the Example below for an example of how the printed table looks like.

If you would like to add some new functionality, or help me make my code mode idiomatic, then issues and PRs are more than welcome πŸ˜„

Functionality

  • print the keybindings as a table
  • optionally print them as a csv to stdout (so that can be easily piped to other software [eg. BurntSushi/xsv])
  • sort bindings by different criteria
  • only show keybindings in a given category
  • optionally wait for input after printing (useful if you want to do something like alacritty -e i3-bindings -b to open a temporary terminal that shows your bindings)

Installation

For the moment you can install this in your PC by cloning the repo and running:

cargo install --path .

Or you can check the release page and see if there is any precompiled executable available for your system, which you can directly download and place it somewhere in your path.

Usage

See i3-bindings --help for a help message about the available options. However, in most cases you'll be fine with just running i3-bindings and leave everything with default values.

This is the help message printed by the tool:

Utility that reads your i3 config file and prints a formatted version to the console

USAGE:
    i3-bindings [FLAGS] [OPTIONS]

FLAGS:
    -b, --block
        --csv                 whether to provide the output in csv (if not a table will be displayed)
    -h, --help                Prints help information
        --print-categories
    -V, --version             Prints version information

OPTIONS:
    -c, --config-path <config-path>
            Sets a custom config file. If not specified then the following paths will be checked (in order)
            ~/.config/i3/config, ~/.i3/config, /etc/i3/config
    -e, --exclusive-category <exclusive-category>
    -s, --sort-dim <sort-dim>
             [default: binding]  [possible values: command, type, binding, no-sort]

How to use format config file

If you want, you can specify categories in your config file so that when printing the table bindings are logically grouped. However this is not required.

Categories: for categories to be printed as in the example below, you need to add comments in your i3 config that specify the category for a group of bindings. All bindings below the comment will have the specified category until a new one is specified. The default category is default.

For example:

# Category: Layout

#Split in horizontal orientation
bindsym $mod+Mod1+h split h

#Split in vertical orientation
bindsym $mod+Mod1+v split v

# Category: Some other category
...etc...

Note that all comments in the file are completely ignored except for those about a Category: (which are used to define categories) as well as the comments on the same line as a binding (which are shown as part of the command in the table).

Example

When executed, the tool will read your i3 config file and, by default, print a table like the following to stdout. If you prefer to see a screenshot example then you can see one here, which shows how it looks like when printing bindings for my "Applications" category on the terminal emulator I use (Alacritty).

╔════════════╦══════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
β•‘Category    β•‘Actual Binding                                                                                                    β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•«β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘Applicationsβ•‘ Symbol  $mod+$alt+b    alacritty -e i3-bindings --block                                                          β•‘
β•‘            β•‘ Symbol  $mod+$alt+c    $EDITOR ~/.config/i3/config                                                               β•‘
β•‘            β•‘ Symbol  $mod+$alt+d    dolphin                                                                                   β•‘
β•‘            β•‘ Symbol  $mod+$alt+e    $EDITOR                                                                                   β•‘
β•‘            β•‘ Symbol  $mod+$alt+g    chromium                                                                                  β•‘
β•‘            β•‘ Symbol  $mod+$alt+q    fish -c ask-and-run-command-in-new-term                                                   β•‘
β•‘            β•‘ Symbol  $mod+$alt+r    alacritty -e ranger                                                                       β•‘
β•‘            β•‘ Symbol  $mod+$alt+s    spotify-wrapper                                                                           β•‘
β•‘            β•‘ Code    $mod+34        picom   #34 - [                                                                           β•‘
β•‘            β•‘ Code    $mod+35        killall picom    #35 - ]                                                                  β•‘
β•‘            β•‘ Code    $mod+Shift+35  ~/.config/polybar/launch.sh                                                               β•‘
β•‘            β•‘ Symbol  Ctrl+Print     scrot '%Y%m%d_%H%M%S.png' -e 'mv $f ~/Pictures/Screenshots/'                              β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•«β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘Audio       β•‘ Symbol  XF86AudioLowerVolume   pactl set-sink-volume 0 -2%                                                       β•‘
β•‘            β•‘ Symbol  XF86AudioMicMute       pactl set-source-mute 1 toggle                                                    β•‘
β•‘            β•‘ Symbol  XF86AudioMute          pactl set-sink-mute 0 toggle                                                      β•‘
β•‘            β•‘ Symbol  XF86AudioNext          playerctl next                                                                    β•‘
β•‘            β•‘ Symbol  XF86AudioPlay          playerctl play-pause                                                              β•‘
β•‘            β•‘ Symbol  XF86AudioPrev          playerctl previous                                                                β•‘
β•‘            β•‘ Symbol  XF86AudioRaiseVolume   pactl set-sink-volume 0 +2%                                                       β•‘
β•‘            β•‘ Symbol  XF86KbdBrightnessDown  sudo /home/andrea/.shellscripts/increase-keyboard-backlight.fish -1               β•‘
β•‘            β•‘ Symbol  XF86KbdBrightnessUp    sudo /home/andrea/.shellscripts/increase-keyboard-backlight.fish 1                β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•«β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘Display     β•‘ Symbol  XF86MonBrightnessDown  fish -c "increase-display-backlight-by -7"                                        β•‘
β•‘            β•‘ Symbol  XF86MonBrightnessUp    fish -c "increase-display-backlight-by 7"                                         β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•«β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘Layout      β•‘ Symbol  $mod+Mod1+h  split h                                                                                     β•‘
β•‘            β•‘ Symbol  $mod+Mod1+v  split v                                                                                     β•‘
β•‘            β•‘ Symbol  $mod+e       layout toggle split                                                                         β•‘
β•‘            β•‘ Symbol  $mod+equal   gaps inner all plus 5                                                                       β•‘
β•‘            β•‘ Symbol  $mod+f       fullscreen toggle                                                                           β•‘
β•‘            β•‘ Symbol  $mod+m       focus child                                                                                 β•‘
β•‘            β•‘ Symbol  $mod+minus   gaps inner all minus 5                                                                      β•‘
β•‘            β•‘ Symbol  $mod+s       layout stacking                                                                             β•‘
β•‘            β•‘ Symbol  $mod+space   floating toggle                                                                             β•‘
β•‘            β•‘ Symbol  $mod+u       focus parent                                                                                β•‘
β•‘            β•‘ Symbol  $mod+w       layout tabbed                                                                               β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•«β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘Main        β•‘ Symbol  $mod+Return   alacritty                                                                                  β•‘
β•‘            β•‘ Symbol  $mod+d        --no-startup-id rofi -show combi                                                           β•‘
β•‘            β•‘ Symbol  $mod+n        --no-startup-id systemsettings5                                                            β•‘
β•‘            β•‘ Symbol  Ctrl+Shift+q  kill                                                                                       β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•«β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘Move Focus  β•‘ Symbol  $mod+Down         focus down                                                                             β•‘
β•‘            β•‘ Symbol  $mod+Left         focus left                                                                             β•‘
β•‘            β•‘ Symbol  $mod+Right        focus right                                                                            β•‘
β•‘            β•‘ Symbol  $mod+Shift+Down   move down                                                                              β•‘
β•‘            β•‘ Symbol  $mod+Shift+Left   move left                                                                              β•‘
β•‘            β•‘ Symbol  $mod+Shift+Right  move right                                                                             β•‘
β•‘            β•‘ Symbol  $mod+Shift+Up     move up                                                                                β•‘
β•‘            β•‘ Symbol  $mod+Shift+h      move left                                                                              β•‘
β•‘            β•‘ Symbol  $mod+Shift+j      move down                                                                              β•‘
β•‘            β•‘ Symbol  $mod+Shift+k      move up                                                                                β•‘
β•‘            β•‘ Symbol  $mod+Shift+l      move right                                                                             β•‘
β•‘            β•‘ Symbol  $mod+Up           focus up                                                                               β•‘
β•‘            β•‘ Symbol  $mod+h            focus left                                                                             β•‘
β•‘            β•‘ Symbol  $mod+j            focus down                                                                             β•‘
β•‘            β•‘ Symbol  $mod+k            focus up                                                                               β•‘
β•‘            β•‘ Symbol  $mod+l            focus right                                                                            β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•«β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘Resize      β•‘ Symbol  $mod+r  mode "default"                                                                                   β•‘
β•‘            β•‘ Symbol  $mod+r  mode "resize"                                                                                    β•‘
β•‘            β•‘ Symbol  Down    resize grow height 8 px or 2 ppt                                                                 β•‘
β•‘            β•‘ Symbol  Escape  mode "default"                                                                                   β•‘
β•‘            β•‘ Symbol  Left    resize shrink width 8 px or 2 ppt                                                                β•‘
β•‘            β•‘ Symbol  Right   resize grow width 8 px or 2 ppt                                                                  β•‘
β•‘            β•‘ Symbol  Up      resize shrink height 8 px or 2 ppt                                                               β•‘
β•‘            β•‘ Symbol  h       resize shrink width 8 px or 2 ppt                                                                β•‘
β•‘            β•‘ Symbol  j       resize grow height 8 px or 2 ppt                                                                 β•‘
β•‘            β•‘ Symbol  k       resize shrink height 8 px or 2 ppt                                                               β•‘
β•‘            β•‘ Symbol  l       resize grow width 8 px or 2 ppt                                                                  β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•«β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘Session     β•‘ Symbol  $mod+Shift+e  "i3-nagbar -t warning -m 'Do you really want to exit i3?' -b 'Yes, exit i3' 'i3-msg exit'" β•‘
β•‘            β•‘ Symbol  $mod+Shift+r  restart                                                                                    β•‘
β•‘            β•‘ Symbol  Ctrl+$alt+l   ~/.shellscripts/lock-screen.fish                                                           β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•«β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘Workspaces  β•‘ Symbol  $mod+0           workspace 10                                                                            β•‘
β•‘            β•‘ Symbol  $mod+1           workspace 1                                                                             β•‘
β•‘            β•‘ Symbol  $mod+2           workspace 2                                                                             β•‘
β•‘            β•‘ Symbol  $mod+3           workspace 3                                                                             β•‘
β•‘            β•‘ Symbol  $mod+4           workspace 4                                                                             β•‘
β•‘            β•‘ Symbol  $mod+5           workspace 5                                                                             β•‘
β•‘            β•‘ Symbol  $mod+6           workspace 6                                                                             β•‘
β•‘            β•‘ Symbol  $mod+7           workspace 7                                                                             β•‘
β•‘            β•‘ Symbol  $mod+8           workspace 8                                                                             β•‘
β•‘            β•‘ Symbol  $mod+9           workspace 9                                                                             β•‘
β•‘            β•‘ Symbol  $mod+Shift+0     move container to workspace 10                                                          β•‘
β•‘            β•‘ Symbol  $mod+Shift+1     move container to workspace 1                                                           β•‘
β•‘            β•‘ Symbol  $mod+Shift+2     move container to workspace 2                                                           β•‘
β•‘            β•‘ Symbol  $mod+Shift+3     move container to workspace 3                                                           β•‘
β•‘            β•‘ Symbol  $mod+Shift+4     move container to workspace 4                                                           β•‘
β•‘            β•‘ Symbol  $mod+Shift+5     move container to workspace 5                                                           β•‘
β•‘            β•‘ Symbol  $mod+Shift+6     move container to workspace 6                                                           β•‘
β•‘            β•‘ Symbol  $mod+Shift+7     move container to workspace 7                                                           β•‘
β•‘            β•‘ Symbol  $mod+Shift+8     move container to workspace 8                                                           β•‘
β•‘            β•‘ Symbol  $mod+Shift+9     move container to workspace 9                                                           β•‘
β•‘            β•‘ Symbol  $mod+Shift+m     move workspace to output left                                                           β•‘
β•‘            β•‘ Symbol  $mod+Shift+n     move workspace to output left                                                           β•‘
β•‘            β•‘ Symbol  Ctrl+$mod+Left   workspace prev                                                                          β•‘
β•‘            β•‘ Symbol  Ctrl+$mod+Right  workspace next                                                                          β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Similar projects

These are some project with a similar functionality, in case you want to check them out

Dependencies

~6–8.5MB
~127K SLoC