My i3 config: Revamped
I've written before on how I use i3. I've been doing it that way for a long-long time, so I felt it was safe to write about it, as I thought it'd be like that forever. Nothing lasts forever though and I have found a better way of doing things. I loved my i3 config, but it had some downsides, mainly that the syntax that has to be used is terrible for a couple of things.
To be able to alter a keybinding, you'll have to read through the list of keybindings you've added to your i3 config. If you have a couple, that's fine. If you have 50+, it becomes a chore to read through them. As I've said before, this is due to the syntax needed, which is very specific and contains way too much "clutter":
<i3 keybinding flag> <key combination> <i3 execute command> <command to execute>
So to start Firefox, that'd be:
bindsym Mod4+w exec --no-startup-id firefox
I had heard of SXHKD before, but I didn't see the point of using it. i3 has keybindings by default, so why use an external application for this? Well, turns out SXHKD has a very clean syntax!
<command to execute>
Which then would be:
super + w
That's it. In my opinion that's way easier to read.
Another thing that is not great, is the way you autostart programs with the i3 config file. To start Dunst on log in, you'd need to do the following:
exec_always --no-startup-id dunst
This isn't so bad. However, when you have 10+ programs to launch, it also looks messy.
Autostart Bash script
So I followed Matt from The Linux Cast's example, and used a Bash script to autostart my programs. In this script it's a matter of listing all the programs one under the other and appending them with an ampersand.
The i3 config file is only 9 lines long and devoid of clutter. The SXHKD file is a lot longer, but with the clean syntax is easy to read through and it's easy to find what I'm looking for and is easy to edit, just like the autostart Bash file.
I can't promise this is how I'll be using i3 forever, but I am sure it'll be for a while. Below I'll add the current versions of the i3 config and autostart files mentioned in this post. You can find up to date versions of these, the SXHKD file (named keybindings in the .config/i3/ folder) and other files on my dotfiles.
- i3 config:
exec_always --no-startup-id ~/.config/i3/autostart
gaps inner 15
gaps outer 15
for_window [class="^.*"] border pixel 0
for_window [class="secrets"] floating enable
for_window [class="firefox" urgent="latest"] focus
for_window [class="floatterm"] floating enable, resize set 800 600, move \
bindsym Mod4+1 workspace 1 # this file requires a bindsym or fails
The first line executes all my autostart programs. The next three set the modifier key you press to move floating windows and set the gaps. The lines after this are some window rules and the last line is needed, because if the i3 files does not have a bindsym line, it doesn't work.
- Autostart Bash script:
xset r rate 200 60 &
unclutter -b &
parcellite -d -n &
setxkbmap -option caps:none &
batsignal -b -i &
picom --config ~/.config/picom/picom.conf &
feh --no-fehbg --bg-scale ~/Pictures/forest.png &
sxhkd -c $HOME/.config/i3/keybindings &