These are a few tips and tricks I have come up with for i3
Here is a cheat sheet for the different key combinations which comes in handy when learning i3
Here is the cheat sheet
To set it as your background:
copy the desired background image file to ~/Pictures
Ensure feh is installed, if not
# pacman -S feh
Then vi ~/.config/i3/config and add the following two lines
# Set background
exec_always --no-startup-id feh - -bg-scale /home/$USER/Pictures/CheatSheet.png
Then you have to reboot for it to take affect.
Now if you’re doing something and just can’t remember the key combination, press $mod+ any unused workspace, and there is our cheat sheet. Then switch back to the workspace you were in.
i3 doesn’t have any default key combinations that start with $mod+Ctrl. So we have a blank canvas here. I feel any modifications made by the user should be as a $mod+Ctrl+something combination just to keep things organized. So here goes:
Instead of Mod+Shift+e then get the nag bar and click on “Yes, exit i3” to logout, and these lines to ~/.config/i3/config for an instant log-out
# Instant log out bindsym $mod+Crtl+l exec i3-msg exit
That’s $mod+Crtl+lower case letter L I chose the letter L for logout. Choose what you want.
dmenu ($mod+d) output is rather cluttered. i3-dmenu-desktop only lists applications that have a corresponding .desktop file. These are generally the most used apps. Add the following to ~.config/i3/conf
# enables i3-dmenu-desktop which only list apps with a .desktop file bindsym $mod+Ctrl+d exec i3-dmenu-desktop
How to open a application (or more) in a specified window.
From the i3 guide https://i3wm.org/docs/layout-saving.html
Layout saving/restoring allows you to load a JSON layout file so that you can have a base layout to start working with after powering on your computer. Dynamic use-cases also come to mind: if you frequently need a grid layout of terminals with ping/traceroute commands to diagnose network issues, you can easily automate opening these windows in just the right layout.
i3-save-tree is a tool to save the layout. It will print a JSON representation of i3’s internal layout data structures to stdout. Typically, you may want to take a quick look at the output, then save it to a file and tweak it a little bit:
Just a reminder, json syntax requires a comma at the end of each statement, and anything after // is a comment.
To do this:
install the anyevent module
# pacman -S perl-anyevent-i3
First, launch the desired app (or apps) in the desired workspace. I’ll use FirefoxNightly in workspace 8 as an example. Once FirefoxNightly is opened in workspace 8
$ i3-save-tree - -workspace 8 > ~/.config/i3/workspace_8.json
This will give the following pseudo json file.
“name”: “i3: Layout saving in i3 - Nightly”,
// “class”: “^Nightly$”,
// “instance”: “^Navigator$”,
// “title”: “^i3\:\ Layout\ saving\ in\ i3\ \-\ Nightly$”,
// “window_role”: “^browser$”
We have to modify it into a syntax correct json file.
In your favorite text editor
delete line 1 // vim:ts=4:sw=4:et
delete the line “name”: “i3: Layout saving in i3 – Nightly”,
delete the line // “title”: “^i3\:\ Layout\ saving\ in\ i3\ \-\ Nightly$”,
remove the comment ( // ) from
You should end up with this
Next create a script in ~/.config/i3
$ vi start_w8.sh
#! /bin/bash i3-msg -q "workspace 8; append_layout ~/.config/i3/workspace_8.json" # and finally we fill the containers with the programs they had (flatpak run org.mozilla.FirefoxNightly &)
save the start_w8.sh file and make it executable.
The above start_w8.sh file shows how to start FirefoxNightly, which is a flatpak.
To start regular Firefox that’s from the Arch repository, change to
Use whatever you type in to run it from the terminal plus & to run it in the background
Now, edit the ~/.config/i3/config file, and add the following:
# bind App to a specific workspace bindsym $mod+Ctrl+f exec ~/.config/i3/start_w8.sh
and Firefox will start in workspace 8. I chose $mod+Ctrl+f so I can remember f for Firefox, you can choose whatever key you want.
I have also done $mod+Ctrl+v for VLC in workspace 7
and $mod+Ctrl+c for Visual Studio Code in workspace 9
and the json files were fairly similar, I had to play around with one of them but a little trial and error got it.
Enjoy playing with i3