--- title: "i3 configuration" description: "Moved to Sway" author: "Thurstylark" date: 2021-9-25 draft: false --- Source: https://git.thurstylark.com/vcsh/i3.git ## j4-make-config The final config that actually is read by i3 is created using j4-make-config. This is done in the [Xinitrc](Xinitrc.md). Simple usage: ``` j4-make-config -a $(hostname).config archlinux ``` This creates `~/.config/i3/config` by merging `~/.config/i3/config.base` and `~/.config/i3/$HOSTNAME.config`, and adds the 'archlinux' theme (included with j4-make-config). Optionally, you can add `-r` to tell i3 to reload the config after `j4-make-config` has completed. Since using `j4-make-config`, the command for reloading the config has been changed to the following: ``` # rebuild and reload the configuration file bindsym $mod+Shift+c exec "j4-make-config -r -a $HOSTNAME.config archlinux" ``` ### Reference https://github.com/okraits/j4-make-config ---- ## Media Keys ### Volume This differs depending on if you're using ALSA or Pulseaudio. Thus, I include these instructions in the host-specific configs instead of the base config ALSA: ``` # Alsa Volume controls bindsym XF86AudioRaiseVolume exec --no-startup-id amixer set Master 5%+ #increase sound volume bindsym XF86AudioLowerVolume exec --no-startup-id amixer set Master 5%- #decrease sound volume bindsym XF86AudioMute exec --no-startup-id amixer set Master toggle * mute sound ``` PulseAudio: ``` # PulseAudio Volume controls bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% #increase sound volume bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% #decrease sound volume bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle * mute sound ``` ### Brightness Brightness can be universal unless the utility for changing brightness differs between machines, so this snippit lives in the base config. ``` # Sreen brightness controls (requires light(1) from the AUR) bindsym XF86MonBrightnessUp exec light -A 10 * increase screen brightness bindsym XF86MonBrightnessDown exec light -U 10 * decrease screen brightness ``` ### Playhead Control This also is universal if the same tool is being used across hosts. I use `playerctl` mainly for its compatibility with Spotify's Linux client. ``` # Music Player controls bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause bindsym XF86AudioNext exec --no-startup-id playerctl next bindsym XF86AudioPrev exec --no-startup-id playerctl previous ``` ### References https://wiki.archlinux.org/index.php/Extra_keyboard_keys https://wiki.archlinux.org/index.php/Advanced_Linux_Sound_Architecture#Keyboard_volume_control https://wiki.archlinux.org/index.php/PulseAudio#Keyboard_volume_control https://wiki.archlinux.org/index.php/Backlight https://wiki.archlinux.org/index.php/Spotify#Global_media_hotkeys ---- ## Screen Locker The screen locker is already set up in [Xinitrc](Xinitrc.md), so all that is necessary in the i3 config is to set the key combination that should spawn `xautolock -locknow`. ``` # Ctrl+Alt+L to lock the screen # Locker is set in ~/.xinitrc bindsym Mod1+Control+l exec "xautolock -locknow" ``` ---- ## i3Bar This is another host-specific configuration, since `bar {}` has host-specific options apart from just the i3status config. It also includes the `j4-make-config` theme placeholder, since the theme definitions for the bar are separate from the main config. I'll only demonstrate the most complicated of my current i3bar configuration. The rest can be viewed on the git repo. ``` bar { status_command i3status -c ~/.config/i3/status/$HOSTNAME.config tray_output primary output eDP1 * Which display should i3bar be bound to? # $i3-theme-bar } ``` ---- ## i3Status Most of the i3Status configuration is pretty standard, and is well documented by [the upstream docs](https://i3wm.org/i3status/manpage.html), so I'll only document the specific directives I crafted/modified myself ### Volume This directive chooses ALSA by default, PulseAudio can be specified by adding `device = "pulse"` to the end of this directive. ``` volume master { format = "🔈%volume" * U+1F508 format_muted = "🔇" * U+1F507 } ``` ### SPVPN This is a simple pidfile watcher used with one of my [VPN](VPN.md) configurations that gets started with systemd. ``` run_watch SPVPN { pidfile = "/var/run/spvpn@*.pid" } ```