Skip to content
karasibillePublic

About

Kára's dotfiles for i3 on Arch Linux and Ubuntu: zsh, polybar, rofi, kitty, dunst, picom, with a one-command color theme switcher (Nord, Laser) and a symlink installer.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

dotfiles

Kára's configuration files, used on Arch Linux (EndeavourOS, i3) and Ubuntu.

Install

git clone git@github.com:karasibille/dotfiles.git ~/Projects/github.com/karasibille/dotfiles
cd ~/Projects/github.com/karasibille/dotfiles
./install.sh --packages --dry-run   # check what will change
./install.sh --packages             # install missing packages, then link

--packages installs what is missing from packages.txt, with pacman (and yay or paru for the AUR) on Arch, or apt on Ubuntu. It lists what has to be installed by hand: on Ubuntu, Source Code Pro, Font Awesome 7 (Ubuntu only packages 4.7), the capitaine cursors and the Nordic GTK theme. It also installs system/udev/90-backlight.rules and adds you to the video group, so that scrolling on the polybar brightness module can change it (after a new login), and enables system/systemd/resync-clock-after-resume.service (see Clock below). Without --packages, only the links are created.

On Ubuntu, ./install-fonts.sh installs Source Code Pro and Font Awesome 7 into ~/.local/share/fonts (--dry-run to check first), and Source Han Sans JP if neither it nor Noto Sans CJK JP is installed. It skips the fonts fontconfig already knows, and checks the archives against pinned checksums. ./install-themes.sh does the same for the Nordic GTK theme (~/.local/share/themes) and the capitaine cursors (~/.icons, the only user directory X11 reads cursors from).

install.sh symlinks each config into $HOME / ~/.config, only for the programs installed on the machine. It can be run again at any time: existing files are moved to <name>.bak.<date>, never overwritten.

Color themes

theme          # pick a theme (rofi, also bound to $mod+Shift+t in i3)
theme laser    # switch directly
theme --list

Each theme is a single X resources file in config/xrdb/colors/. theme generates the color files of kitty, alacritty, rofi, dunst and polybar from it (*.generated*, not versioned), points config/xrdb/current to it and reloads the running programs; i3 reads the colors from xrdb. The theme's GTK theme (theme.gtk) is sent to running GTK applications through xsettingsd when it is installed; otherwise new applications use config/gtk-3.0/settings.ini.

theme.wallpaper sets the theme's wallpaper (e.g. theme.wallpaper: ~/Pictures/wallpapers/nord.png); without it, or if the image is missing, the background is the theme's background color. Wallpapers are not versioned: copy them to each machine.

To add a theme, copy config/xrdb/colors/nord and change the colors: background, foreground and color0–color15 are required, the theme.* roles (accent, bar colors…) are optional and listed in bin/theme.

Firefox follows with the firefox-desktop-theme extension: theme writes the Firefox colors to ~/.local/state/theme/firefox.json where the extension's native host picks them up and applies them live. ./install.sh --packages clones the extension next to this repository and runs its install.sh; the .xpi of the extension is still installed by hand (the script prints the link).

Monitors

autorandr applies a saved layout when the connected screens change (udev rule of the package) and at i3 startup. Save one profile per place, once the screens are arranged (e.g. with arandr):

autorandr --save mobile     # laptop alone
autorandr --save home       # on the home dock
autorandr                   # list the profiles, the current one is marked

Monitors are matched by their EDID, not their output name (config/autorandr/settings.ini): the same screen is DP1 or DP-1-0 depending on the GPU it goes through. Profiles are per machine and not versioned (~/.config/autorandr/<name>/). After each switch, config/autorandr/postswitch restarts polybar (full bar on the primary monitor, workspaces and time on the others) and resets the wallpaper and the lock image to the new screen size.

To also switch when the lid is closed or opened: sudo systemctl enable --now autorandr-lid-listener.

Keyboard

The compose key is right Ctrl, set by i3 at startup (and $mod+Shift+r) with setxkbmap -option compose:rctrl. X forgets it whenever it detects a keyboard again: a keyboard or dock plugged in, or the laptop resuming from suspend. To keep it, set it in the system X11 keyboard configuration, which X applies to every keyboard it detects:

localectl status    # check the current layout first, and keep it below
sudo localectl set-x11-keymap us pc105 "" compose:rctrl

This writes /etc/X11/xorg.conf.d/00-keyboard.conf. Debian and Ubuntu refuse it ("Setting X11 and console keymaps is not supported in Debian"): set XKBLAYOUT and XKBOPTIONS in /etc/default/keyboard instead, then sudo udevadm trigger --subsystem-match=input --action=change. It is not done by install.sh: the layout and model are per machine, and the command replaces the whole system keyboard configuration.

Several layouts, switched by a click on the keyboard module of polybar: list them in XKB_LAYOUT, in ~/.profile.local, the first being the default:

export XKB_LAYOUT=us,fr

i3 passes it to setxkbmap -layout. X forgets it too when it detects a keyboard again; the lasting fix is the same, with us,fr as the layout.

Clock

The kernel measures how long a suspend lasted with the hardware clock (RTC). On a laptop whose RTC no longer ticks (the MSI GS63VR does not, even while running: a dead CMOS battery or a firmware bug), the clock comes back at the time the lid was closed and stays wrong until the next NTP poll of systemd-timesyncd, up to 34 minutes later. The system unit installed by --packages restarts timesyncd after each resume, once the network is back, so the clock is corrected within seconds. To check the RTC:

timedatectl                       # RTC time should match Universal time
cat /sys/class/rtc/rtc0/time      # should change from one call to the next

Screen lock

$mod+l runs lock (bin/lock): i3lock with a blurred, darkened copy of the theme's wallpaper (cached in ~/.cache/lock, built when the theme changes and at i3 startup), or the theme's background color with a solid background or without ImageMagick. LOCK_WALLPAPER sets another source image.

Automatic lock

bin/autolock, started by i3, is off unless AUTOLOCK is set in ~/.profile.local:

export AUTOLOCK=presence     # or idle
export AUTOLOCK_CHECK=20     # presence: seconds without input before a webcam check
export AUTOLOCK_IDLE=600     # always: lock after this many seconds without input

In presence mode, after AUTOLOCK_CHECK seconds without keyboard or mouse input it looks at the webcam for about a second and locks if no face is seen, then checks again every AUTOLOCK_CHECK seconds while idle. Frames stay in memory and are never saved. Faces are detected with OpenCV's YuNet model (share/autolock, MIT licensed, OpenCV >= 4.8), or its Haar cascades on older OpenCV versions. If the webcam can't be read (e.g. busy in a video call), only AUTOLOCK_IDLE applies. autolock --check tests the detection once.

Suspend with the lid closed

logind suspends when the lid is closed, except while an external monitor is connected (docked). bin/lidsuspend, started by i3, also suspends when the screen is locked and the lid has been closed for a minute, wherever the laptop is. LIDSUSPEND in ~/.profile.local sets the delay in seconds (0 disables it). It does nothing on a machine without a lid.

Hibernate

The power menu of polybar offers suspend and hibernate (both locked first by xss-lock). Hibernate only works once the machine can write its memory to swap and read it back at boot, which is per machine and not done by install.sh. With Ubuntu's swap file on the root filesystem:

free -h                                    # swap must hold the used memory: aim for the RAM size
sudo swapoff -a && sudo rm /swap.img
sudo fallocate -l 32G /swap.img && sudo chmod 600 /swap.img
sudo mkswap /swap.img && sudo swapon /swap.img
findmnt -no SOURCE /                       # the root device, e.g. /dev/mapper/ubuntu--vg-ubuntu--lv
sudo filefrag -v /swap.img | awk 'NR==4 {print $4}' | tr -d .   # the resume offset

Then add resume=<root device> resume_offset=<offset> to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub, write RESUME=<root device> to /etc/initramfs-tools/conf.d/resume, and run sudo update-grub && sudo update-initramfs -u. Reboot, then test with systemctl hibernate: the session must be back after the next boot. Secure Boot's lockdown mode forbids hibernation; disable it in the firmware or sign the kernel. Test it unplugged from any dock first: a USB-C dock can leave the resumed system without input or disk (ThinkPad L16 Gen 2 and HP G5 dock, Linux 6.17), in which case only hibernate undocked.

Ubuntu also denies hibernation by polkit (com.ubuntu.desktop.rules): systemctl hibernate answers Access denied until a rule sorted before it allows it, e.g. /etc/polkit-1/rules.d/10-enable-hibernate.rules:

polkit.addRule(function(action, subject) {
    if ((action.id == "org.freedesktop.login1.hibernate" ||
         action.id == "org.freedesktop.login1.handle-hibernate-key" ||
         action.id == "org.freedesktop.login1.hibernate-multiple-sessions") &&
        subject.active && subject.local) {
        return polkit.Result.YES;
    }
});

Machine-specific settings

These files are sourced when present and are not versioned:

File For
~/.profile.local environment variables, extra PATH
~/.zshrc.local zsh settings, aliases
~/.config/aliases/secrets/ aliases containing tokens or passwords
~/.config/autorandr/<name>/ monitor profiles (autorandr --save)
~/.p10k.zsh powerlevel10k prompt instead of fwalch (p10k configure)

Content

The repository is laid out by destination:

Directory Goes to How
home/ ~/.<name> symlinked by install.sh
config/ ~/.config/<name> symlinked by install.sh
bin/ ~/.local/bin/ symlinked by install.sh
system/ /etc copied by install.sh --packages
share/ stays here data read by bin/ (face model)
*.sh, packages.txt — installers and the package list
Config Program
home/zshrc, home/zsh_plugins.txt, config/aliases/ zsh + antidote / oh-my-zsh
home/profile login environment
config/i3/ i3 window manager
config/polybar/ status bar
config/rofi/ launcher
config/dunst/ notifications
config/kitty/, config/alacritty/ terminals
config/picom/ compositor
config/gtk-3.0/ GTK 3 theme, icons, font
config/xrdb/, home/Xresources Nord and Laser color themes
config/autorandr/ monitor profiles: options and hook
config/redshift/, config/ranger/, config/fontconfig/, home/npmrc misc
bin/theme, bin/lock, bin/autolock theme switcher, screen lock, presence lock

About

Kára's dotfiles for i3 on Arch Linux and Ubuntu: zsh, polybar, rofi, kitty, dunst, picom, with a one-command color theme switcher (Nord, Laser) and a symlink installer.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages