Files
i3-dot/README.md
T
2026-10-19 23:21:54 +07:00

318 lines
11 KiB
Markdown
Executable File

# i3-stones
## Dependencies
### For i3
- i3wm
- polybar
### For sway
- wl-root
- grim
- slurp
- wl-clipboard
- sway
- swaybg
- waybar
### Others (notifications and icons)
- A Nerd Font (for icons)
- tiramisu
## For brightness and media control:
- brightnessctl (You have to add user to the following groups: video input)
- playerctl
## For screen tearing:
- Fix xorg config with appropriate driver.
- Driver:
- intel: xf86-video-intel
- sudo -e /etc/X11/xorg.conf.d/20-intel.conf
```
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
Option "TearFree" "true"
EndSection
```
- amd: xf86-video-amdgpu (`VariableRefresh` = FreeSync, fullscreen apps only under Xorg)
- sudo -e /etc/X11/xorg.conf.d/20-amdgpu.conf
```
Section "Device"
Identifier "AMD"
Driver "amdgpu"
Option "VariableRefresh" "true"
Option "TearFree" "true"
EndSection
```
## High refresh rate flicker (AMD):
- At high refresh rates (240Hz+) the vblank can be too short for the GPU to
switch VRAM clock unnoticed, so the desktop flickers under changing load.
Windows avoids it by keeping VRAM clock high; amdgpu on Linux may not.
- Check: if the `*` jumps between levels while idle, this is likely the cause.
```bash
watch -n0.2 cat /sys/class/drm/card*/device/pp_dpm_mclk
```
- Fix 1: run the desktop at a lower rate (`i3/config` uses 120Hz). Find the
output name with `xrandr` (e.g. `DisplayPort-0`) and adjust it there:
```bash
xrandr --output DisplayPort-0 --mode 1920x1080 --rate 120
```
- sway: same idea in `sway/config` (`swaymsg -t get_outputs` for the name).
Keep `adaptive_sync off` there — sway applies it to the whole desktop, which
can stutter/flicker:
```
output DP-1 mode 1920x1080@120Hz adaptive_sync off
```
- Fix 2: keep the high rate and pin VRAM clock to its top level (more idle
power, resets on reboot; top level is the last line of `pp_dpm_mclk`):
```bash
echo manual | sudo tee /sys/class/drm/card*/device/power_dpm_force_performance_level
echo 3 | sudo tee /sys/class/drm/card*/device/pp_dpm_mclk
```
- Gaming: 120Hz + FreeSync is plenty for ~60fps games (VRR covers the dips).
Cap fps a few below max refresh so VRR stays active, e.g. Dota 2 console
`fps_max 117`. Under Xorg, VRR applies to fullscreen games only; under sway
with `adaptive_sync off` games run without it.
- To turn off FreeSync for a single game (Xorg): `adaptive_sync=false %command%`
(Steam launch options).
- Login greeters (SDDM, LightDM, ...) are fullscreen and mostly static, so VRR
drops to the bottom of the range and flickers. `mesa/drirc` disables it for
any `*greeter*` executable; install system-wide (greeters don't read `~/.drirc`):
```bash
sudo cp xorg/20-amdgpu.conf /etc/X11/xorg.conf.d/
sudo cp mesa/drirc /etc/drirc
```
![stones](./screenshots/Screenshot_20240503_095414.png)
## Shader cache (Steam)
With Steam's *Shader Pre-caching* off (it re-downloads caches for every game
almost daily), Steam points Mesa at a temporary
`~/.local/share/Steam/shader_cache_temp_dir_*` and deletes it when the game
exits, so every session recompiles shaders (hitches everywhere, every time).
Steam only sets the legacy `MESA_GLSL_CACHE_DIR`, so the newer variable wins.
Set it session-wide (i3 is started by SDDM, `environment.d` doesn't reach
Steam). The cache lives in `/var/cache` so `~/.cache` cleaners don't wipe it,
with one private subdir per user: Mesa creates its dirs `0700`, so a single
shared dir can't work (and would let users poison each other's shaders).
`/etc/environment` can't expand `$USER`, so use `/etc/profile.d` (SDDM's
X11/Wayland sessions and TTY logins source it). Run as your normal user, not
from a root shell (`~` and `$USER` must be yours), with Steam closed:
```bash
sudo mkdir -p /var/cache/mesa_shader_cache
sudo chmod 1777 /var/cache/mesa_shader_cache # like /tmp: anyone creates own subdir
mv ~/.cache/mesa_shader_cache /var/cache/mesa_shader_cache/$USER # no sudo: keeps ownership
sudo sed -i '/^MESA_SHADER_CACHE_/d' /etc/environment
sudo tee /etc/profile.d/mesa-shader-cache.sh >/dev/null <<'EOF'
export MESA_SHADER_CACHE_DIR="/var/cache/mesa_shader_cache/$USER"
export MESA_SHADER_CACHE_MAX_SIZE=10G
export PRESSURE_VESSEL_FILESYSTEMS_RW=/var/cache/mesa_shader_cache
EOF
```
The last line matters: Steam runs games (native and Proton) in the Steam
Linux Runtime container, which shares `$HOME` but gives the game its own empty
`/var`. Without it the cache is written to a tmpfs inside the container and
thrown away when the game exits.
Re-login, then check it's yours and persists after playing (should print > 0):
```bash
echo $MESA_SHADER_CACHE_DIR; ls -ld $MESA_SHADER_CACHE_DIR # owner must be you
find $MESA_SHADER_CACHE_DIR -mmin -60 -type f | wc -l
```
Deleting the cache is harmless: shaders just recompile (stutter) on first use.
## Installing dependencies
Package availability differs between distros — Arch has everything below in the
official/multilib repos, no AUR needed. Gentoo's main tree is missing a few
newer tools (noted below); those need the [GURU overlay](https://wiki.gentoo.org/wiki/Project:GURU)
or manual/cargo install.
### Window manager & session (both i3 and sway)
**Arch**
```bash
sudo pacman -S i3-wm i3status i3blocks sway swaybg swaylock swayidle \
waybar polybar rofi alacritty dex snixembed \
xss-lock xorg-xset xorg-xrandr xclip scrot imagemagick i3lock \
network-manager-applet blueman gnome-keyring polkit-gnome \
pipewire wireplumber pipewire-pulse pipewire-alsa pipewire-jack \
pasystray playerctl brightnessctl \
fcitx5 fcitx5-im fcitx5-configtool
```
**Gentoo**
```bash
sudo emerge --ask \
x11-wm/i3 x11-misc/i3status x11-misc/i3blocks \
gui-wm/sway gui-apps/swaybg gui-apps/swaylock gui-apps/swayidle \
gui-apps/waybar x11-misc/polybar x11-misc/rofi x11-terms/alacritty \
x11-misc/dex x11-misc/snixembed \
x11-misc/xss-lock x11-apps/xset x11-apps/xrandr x11-misc/xclip media-gfx/scrot \
media-gfx/imagemagick x11-misc/i3lock \
net-misc/networkmanager net-misc/network-manager-applet net-wireless/blueman \
app-crypt/gnome-keyring gnome-extra/polkit-gnome \
media-video/pipewire media-video/wireplumber media-sound/playerctl \
app-i18n/fcitx app-i18n/fcitx-qt app-i18n/fcitx-gtk
```
- `brightnessctl` is **not in the main Gentoo tree** — install from the GURU
overlay (`sudo emerge --ask brightnessctl`, after enabling GURU below) or
build from source. Add your user to the `video` and `input` groups either way.
- PipeWire's PulseAudio/ALSA/JACK compatibility on Gentoo is controlled by
USE flags (`pulseaudio`/`alsa`/`jack`... check `equery u media-video/pipewire`)
rather than separate packages.
- `pasystray` (systray volume icon) is not in the main tree either; the GURU
overlay or `pavucontrol` are common substitutes.
Enable the GURU overlay once, needed by several packages below:
```bash
sudo eselect repository enable guru
sudo emerge --sync guru
```
### Wayland screenshots, clipboard, and screen sharing (sway)
These are the pieces the Print-key bindings and screen sharing/recording in
`sway/config` depend on — without `xdg-desktop-portal-wlr` specifically,
no app (browser tab share, Discord, OBS) can capture the screen at all.
**Arch**
```bash
sudo pacman -S grim slurp wl-clipboard cliphist \
xdg-desktop-portal xdg-desktop-portal-wlr xdg-desktop-portal-gtk \
wf-recorder obs-studio
```
**Gentoo**
```bash
sudo emerge --ask \
gui-apps/grim gui-apps/slurp gui-apps/wl-clipboard \
sys-apps/xdg-desktop-portal gui-libs/xdg-desktop-portal-wlr sys-apps/xdg-desktop-portal-gtk \
media-video/wf-recorder media-video/obs-studio
```
- `cliphist` (clipboard history) is not in the main tree — GURU overlay.
After installing the portal packages, restart the portal service so it picks
up the new backend:
```bash
systemctl --user restart xdg-desktop-portal
```
### AMD GPU stack (mesa/RADV/amdgpu)
**Arch**
```bash
sudo pacman -S mesa lib32-mesa vulkan-radeon lib32-vulkan-radeon \
xf86-video-amdgpu linux-firmware-amdgpu libvdpau-va-gl
```
Mesa on current Arch already bundles the VA-API driver (`radeonsi_drv_video.so`)
and there's no separate `mesa-vdpau`/`lib32-mesa-vdpau` package anymore —
`libvdpau-va-gl` is the VDPAU-to-VA-API translation layer that replaces it.
**Gentoo**
```bash
# In /etc/portage/make.conf:
# VIDEO_CARDS="amdgpu radeonsi"
sudo emerge --ask media-libs/mesa media-libs/vulkan-loader \
x11-drivers/xf86-video-amdgpu media-video/libvdpau media-libs/libvdpau-va-gl
```
Make sure `mesa` is built with `USE="vulkan"` and, for 32-bit/Steam
compatibility, `ABI_X86="32 64"` in `package.use`.
### Gaming & performance
**Arch**
```bash
sudo pacman -S gamemode lib32-gamemode mangohud lib32-mangohud
```
**Gentoo**
```bash
sudo emerge --ask games-util/gamemode
```
- `mangohud` is **not in the main Gentoo tree** — GURU overlay
(`sudo emerge --ask games-util/mangohud` after enabling GURU).
Adaptive sync (sway): the desktop runs at a fixed 240 Hz with VRR off, because
sway only renders on change and idle frame rates fall below the panel's 48 Hz
floor (out of LFC range → flicker). gamemode turns VRR on for DP-1 while a
game runs and off when it exits (install `gamemode/gamemode.ini` to
`~/.config/gamemode.ini`); `lock-now` turns it off while locked.
### GPU monitoring & tuning
**Arch**
```bash
sudo pacman -S radeontop amdgpu_top nvtop lact lm_sensors
```
**Gentoo**
```bash
sudo emerge --ask app-misc/radeontop sys-process/nvtop sys-power/lm-sensors
```
- `amdgpu_top`, `lact`, and `corectrl` (fan curves/overclocking GUIs) are not
in the main tree — GURU overlay, or install `lact`/`amdgpu_top` via `cargo`
since both are Rust tools.
### Razer peripherals (polling rate, DPI, RGB)
**Arch**
```bash
sudo pacman -S openrazer-daemon openrazer-meta polychromatic
sudo gpasswd -a $USER plugdev
```
**Gentoo**
```bash
sudo emerge --ask sys-apps/openrazer
sudo gpasswd -a $USER plugdev
```
- Gentoo ships a single unified `sys-apps/openrazer` package (driver +
daemon together) rather than split `-daemon`/`-meta` packages.
`polychromatic` (GUI) is not in the main tree — GURU overlay.
### Notifications & fonts
**Arch**
```bash
sudo pacman -S ttf-firacode-nerd
# tiramisu (notification daemon) is AUR-only on Arch: yay -S tiramisu
```
**Gentoo**
```bash
sudo emerge --ask media-fonts/nerd-fonts
```
- `tiramisu` is not in the main Gentoo tree — GURU overlay or build from
source (https://github.com/Sweets/tiramisu).
### PipeWire launcher (Gentoo only)
`sway/config` calls `gentoo-pipewire-launcher`, the community launcher script
documented on the [Gentoo PipeWire wiki page](https://wiki.gentoo.org/wiki/PipeWire) —
it's a shell script you place on your `PATH` yourself, not a portage package.
## Vim
### Vimplug
#### Neovim
```
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
```
#### Vim
```sh
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
```
### Conquer of Completion
- Requirements:
- Nodejs
### coc.nvim
```
:CocInstall coc-pairs coc-json coc-tsserver coc-snippets
```
### coc.vimtex
```
:CocInstall coc-vimtex
```