refractor: on chezmoi

Add multiple variables in chezmoi.toml, apply a more detailed ignore rule

Use of chezmoi scripts

Use Neogit for default git GUI (TUI)

Integrate chezmoi with age
This commit is contained in:
js0ny 2025-11-08 07:24:43 +00:00
parent 5921775239
commit 2a1127bf10
38 changed files with 988 additions and 129 deletions

View file

@ -1,17 +1,117 @@
{{/*
vim:ft=gotmpl
*/}}
{{/* https://github.com/twpayne/dotfiles/blob/master/home/.chezmoi.toml.tmpl */}}
{{/* Variable Definitions */}}
{{- $ephemeral := false -}}
{{- $headless := false -}}
{{- $personal := false -}}
{{- $nix := false -}}
{{- $work := false -}}
{{- $wheel := false -}}
{{- $username := promptStringOnce . "username" "What is your username" -}}
{{- $email := promptStringOnce . "email" "What is your email address" -}}
{{- $hostname := .chezmoi.hostname -}}
{{- $wheel := false -}}
{{- $diffCmd := "diff" -}}
{{- $encryptionProvider := "gpg" -}}
{{/* darwin hostname hack */}}
{{- $hostname := .chezmoi.hostname -}}
{{- if eq .chezmoi.os "darwin" -}}
{{- $hostname := output "scutil" "--get" "LocalHostName" | trim -}}
{{- end -}}
sourceDir = "~/.dotfiles"
{{/* Wheel group detection */}}
{{- $wheel = or
(and
(eq .chezmoi.os "linux")
(output "groups" | regexMatch "\\b(sudo|wheel|admin)\\b")
)
(and
(eq .chezmoi.os "darwin")
(output "groups" | regexMatch "\\b(admin|wheel)\\b")
)
(and
(eq .chezmoi.os "windows")
(output "powershell.exe" "-NoProfile" "-Command" "net localgroup administrators | Select-String $env:USERNAME")
)
-}}
{{ $email := promptStringOnce . "email" "What is your email address" -}}
{{ $username := promptStringOnce . "username" "What is your username" -}}
{{/*
Determining nix package manager
If under nix, some dotfiles should be managed via home-manager
If under nixOS, most scripts that require root access should not be run, as they are managed by nixOS
*/}}
{{/* nixOS */}}
{{ if eq .chezmoi.os "linux" }}
{{ if eq .chezmoi.osRelease.id "nixos"}}
{{ $nix = true }}
{{ end }}
{{/* nix on other linux distros */}}
{{ if isExecutable "/nix/var/nix/profiles/default/bin/nix-env" }}
{{ $nix = true }}
{{ end }}
{{ end }}
{{ if eq .chezmoi.os "darwin" }}
{{/* nix-darwin */}}
{{ if isExecutable "/run/current-system/sw/bin/darwin-rebuild" }}
{{ $nix = true }}
{{ end }}
{{ end }}
{{/*
Determining headless
*/}}
{{/* detect GitHub codespaces, VSCode remote containers, Docker containers, Multipass VMs, and Vagrant boxes */}}
{{- if or (env "CODESPACES") (env "REMOTE_CONTAINERS_IPC") (eq .chezmoi.username "root" "vagrant" "vscode") -}}
{{- $ephemeral = true -}}
{{- $headless = true -}}
{{- end -}}
{{ if not .headless }}
{{ if eq .chezmoi.os "linux" }}
{{/* Fedora Server */}}
{{ if eq .chezmoi.osRelease.variantID "server" }}
{{ $headless = true }}
{{ end }}
{{/* Treat all Debian hosts as headless */}}
{{ if eq .chezmoi.osRelease.id "debian" }}
{{ $headless = true }}
{{ end }}
{{ end }}
{{ end }}
{{/*
Determining diff command, fallback to diff
*/}}
{{- if lookPath "delta" -}}
{{- $diffCmd = "delta" -}}
{{- else if lookPath "git-delta" -}}
{{- $diffCmd = "git-delta" -}}
{{- end -}}
{{/*
Determining encryption provider, fallback to gpg
*/}}
{{- if lookPath "age" -}}
{{- $encryptionProvider = "age" -}}
{{- else if lookPath "rage" -}}
{{- $encryptionProvider = "rage" -}}
{{- end -}}
sourceDir = "~/.dotfiles"
encryption = {{ $encryptionProvider | quote }}
[data]
email = {{ $email | quote }}
username = {{ $username | quote }}
headless = {{ $headless }}
nix = {{ $nix }}
wheel = {{ $wheel }}
[diff]
command = {{ $diffCmd | quote }}
[age]
identities = ["~/.ssh/agekey.txt"]
recipients = ["age1mcvqpg39t32ll684r4m2l8j0l9zag6endg0h6zjw8svkgdwc4pjqkk5fvj"]

View file

@ -0,0 +1,7 @@
# Condition: work && nowheel
[".local/bin/ghostty"]
type = "file"
url = {{ gitHubLatestReleaseAssetURL "pkgforge-dev/ghostty-appimage" (printf "Ghostty-*-x86_64.AppImage") | quote }}
executable = true
refreshPeriod = "336h"
exact = true

View file

@ -0,0 +1,19 @@
[".config/zsh/plugins/zsh-autosuggestions"]
type = "git-repo"
url = "https://github.com/zsh-users/zsh-autosuggestions"
refreshPeriod = "336h"
[".config/zsh/plugins/zsh-syntax-highlighting"]
type = "git-repo"
url = "https://github.com/zsh-users/zsh-syntax-highlighting"
refreshPeriod = "336h"
[".config/zsh/plugins/zsh-history-substring-search"]
type = "git-repo"
url = "https://github.com/zsh-users/zsh-history-substring-search"
refreshPeriod = "336h"
[".config/zsh/plugins/zsh-completions"]
type = "git-repo"
url = "https://github.com/zsh-users/zsh-completions"
refreshPeriod = "336h"

View file

@ -1,63 +1,127 @@
{{/*
vim:ft=gotmpl
*/}}
.chezmoiscripts/todo/**
{{/* Todos */}}
.chezmoiscripts/todo/**
{{/* Secret Directory, always ignored, access via templates */}}
secrets/**
{{ if ne .chezmoi.os "linux" }}
.config/awesome
.config/dunst
.config/fcitx5
.config/hypr
.config/keyd
.config/mako
.config/readline
.config/rofi
.config/swaylock
.config/waybar
.config/wlogout
.config/krunnerrc
.config/systemd
.config/user-dirs.dirs
.config/user-dirs.locale
.config/libvirt
.local/share/kio/
{{ end }}
{{/* Install appimages only on non-wheel linux systems */}}
{{ if eq .chezmoi.os "linux" }}
{{ if .wheel }}
.local/bin/ghostty
{{ end }}
{{ end }}
{{ if eq .chezmoi.os "linux" }}
{{ if ne .chezmoi.osRelease.id "arch" }}
.config/*-flags.conf
{{ end }}
{{ if eq .chezmoi.osRelease.id "nixos" }}
.config/bash
.config/bat
.config/doom
.config/dunst
.config/fastfetch
.config/fcitx5
.config/fish
.config/zsh
.config/lsd
.config/keyd
.config/readline
.config/krunnerrc
.bashrc
.local/share/kio
{{ end }}
{{ end }}
{{/* Headless */}}
{{ if .headless }}
{{/* Linux */}}
.config/awesome
.config/dunst
.config/fcitx5
.config/hypr
.config/keyd
.config/mako
.config/rofi
.config/swaylock
.config/waybar
.config/wlogout
.config/krunnerrc
.config/user-dirs.locale
.local/share/kio/
.local/share/fonts/**
.chezmoiexternals/linux-fonts.toml
{{/* Windows */}}
Appdata/Roaming/komorebi
.glzr
{{ end }}
{{ if ne .chezmoi.os "darwin" }}
.chezmoiscripts/darwin/**
Library
.config/karabiner
.config/sketchybar
.config/skhd
.config/yabai
.config/powershell
{{ end }}
{{/* Managed by home-manager */}}
{{ if .nix }}
.bashrc
.chezmoiscripts/linux/**
.chezmoiscripts/unixlike/**
.chezmoiexternals/**
.config/systemd
.config/zsh/**
.config/bash
.config/lsd
.config/keyd
.config/fish
.config/readline
.config/bat
.config/krunnerrc
.config/fcitx5
.local/share/**
{{ end }}
{{ if ne .chezmoi.os "windows" }}
.gitconfig
.glzr
.wslconfig
.wslgconfig
Appdata/
{{ end }}
{{/* Linux */}}
{{ if ne .chezmoi.os "linux" }}
.chezmoiscripts/linux/**
.config/awesome
.config/dunst
.config/fcitx5
.config/hypr
.config/keyd
.config/mako
.config/readline
.config/rofi
.config/swaylock
.config/waybar
.config/wlogout
.config/krunnerrc
.config/systemd
.config/user-dirs.dirs
.config/user-dirs.locale
.config/libvirt
.local/share/kio/
.local/share/fonts/**
.chezmoiexternals/linux-*
.local/bin/**
{{ end }}
{{/* ArchLinux */}}
{{ if eq .chezmoi.os "linux" }}
{{ if ne .chezmoi.osRelease.id "arch" }}
.config/*-flags.conf
{{ end }}
{{ end }}
{{/* nixOS */}}
{{ if eq .chezmoi.os "linux" }}
{{ if eq .chezmoi.osRelease.id "nixos" }}
{{/* Only runs scripts in .chezmoiscripts/+nixos/** */}}
.chezmoiscripts/linux/**
.chezmoiscripts/darwin/**
.chezmoiscripts/unixlike/**
{{ end }}
{{ end }}
{{/* macOS */}}
{{ if ne .chezmoi.os "darwin" }}
.chezmoiscripts/darwin/**
Library
.config/karabiner
.config/sketchybar
.config/skhd
.config/yabai
.config/powershell
{{ end }}
{{/* Windows */}}
{{ if ne .chezmoi.os "windows" }}
.chezmoiscripts/windows/**
.gitconfig
.glzr {{/* GlazeWM */}}
.wslconfig
.wslgconfig
Appdata/
{{ end }}
{{/* Unix-like Scripts */}}
{{ if eq .chezmoi.os "windows" }}
.chezmoiscripts/unixlike/**
.chezmoiscripts/+nixos/**
{{ end}}

View file

@ -1,3 +0,0 @@
#!/bin/sh
# curl -fsSL https://install.determinate.systems/nix | sh -s -- install

View file

@ -0,0 +1,15 @@
#!/bin/sh
echo "Use TouchID to authenticate before running sudo commands."
echo "WARNING: This operation modifies critical system files."
echo "If something goes wrong, you may need to boot into macOS Recovery Mode to restore your system."
echo "To continue, type EXACTLY 'yes' and press Enter."
read -p "Do you want to continue? (yes/no): " response
if [ "$response" != "yes" ]; then
echo "Operation cancelled."
exit 0 # Exit with success status code
fi
echo ""
sudo cp ~/.dotfiles/misc/mac/etc/pam.d/sudo /etc/pam.d/sudo

View file

@ -0,0 +1,17 @@
#!/bin/sh
src=~/.dotfiles/misc/firefox/search.json.mozlz4
dest=~/.mozilla/firefox/*.default/search.json.mozlz4
if ! cmp -s "$src" "$dest" 2>/dev/null; then
cp "$src" "$dest"
fi
{{ if .wheel }}
src=~/.dotfiles/misc/firefox/policies.json
dest=/etc/firefox/policies/policies.json
if ! cmp -s "$src" "$dest" 2>/dev/null; then
sudo cp "$src" "$dest"
fi
{{ end }}

View file

@ -0,0 +1,3 @@
#!/bin/sh
fc-cache -fv

View file

@ -1,11 +0,0 @@
#!/bin/sh
if command -v bat > /dev/null 2>&1; then
mkdir -p "$(bat --config-dir)/themes"
wget -P "$(bat --config-dir)/themes" https://github.com/catppuccin/bat/raw/main/themes/Catppuccin%20Latte.tmTheme
wget -P "$(bat --config-dir)/themes" https://github.com/catppuccin/bat/raw/main/themes/Catppuccin%20Frappe.tmTheme
wget -P "$(bat --config-dir)/themes" https://github.com/catppuccin/bat/raw/main/themes/Catppuccin%20Macchiato.tmTheme
wget -P "$(bat --config-dir)/themes" https://github.com/catppuccin/bat/raw/main/themes/Catppuccin%20Mocha.tmTheme
fi

View file

@ -1,3 +0,0 @@
#!/usr/bin/env bash
curl https://raw.githubusercontent.com/SpaceAceMonkey/dotenv-for-fish/refs/heads/main/dotenv.fish -o "$CHEZMOI_SOURCE_DIR/dot_config/fish/functions/dotenv.fish"

View file

@ -1,12 +0,0 @@
#!/bin/bash
curl -L https://github.com/lxgw/LxgwWenKai/releases/download/v1.520/lxgw-wenkai-v1.520.zip -o /tmp/lxgw-wenkai.zip
unzip /tmp/lxgw-wenkai.zip -d ~/.local/share/fonts/
curl -L https://github.com/lxgw/LxgwNeoXiHei/releases/download/v1.223/LXGWNeoXiHeiPlus.ttf -o /tmp/lxgw-xihei.zip
unzip /tmp/lxgw-xihei.zip -d ~/.local/share/fonts/
curl -L https://github.com/subframe7536/maple-font/releases/download/v7.7/MapleMono-NF-CN-unhinted.zip -o /tmp/maple-mono.zip
unzip /tmp/maple-mono.zip -d ~/.local/share/fonts/
fc-cache -fv

View file

@ -1,10 +0,0 @@
#!/bin/sh
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
test -d "$XDG_CONFIG_HOME/zsh/plugins/zsh-autosuggestions" || git clone --depth 1 https://github.com/zsh-users/zsh-autosuggestions.git "$XDG_CONFIG_HOME/zsh/plugins/zsh-autosuggestions"
test -d "$XDG_CONFIG_HOME/zsh/plugins/zsh-syntax-highlighting" || git clone --depth 1 https://github.com/zsh-users/zsh-syntax-highlighting.git "$XDG_CONFIG_HOME/zsh/plugins/zsh-syntax-highlighting"
test -d "$XDG_CONFIG_HOME/zsh/plugins/zsh-history-substring-search" || git clone --depth 1 https://github.com/zsh-users/zsh-history-substring-search.git "$XDG_CONFIG_HOME/zsh/plugins/zsh-history-substring-search"
test -d "$XDG_CONFIG_HOME/zsh/plugins/zsh-completions" || git clone --depth 1 https://github.com/zsh-users/zsh-completions.git "$XDG_CONFIG_HOME/zsh/plugins/zsh-completions"

View file

@ -2,6 +2,8 @@
XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
{{ if .wheel }}
if [ -f /etc/zshenv ]; then
sudo cp "$CHEZMOI_SOURCE_DIR/dot_config/zsh/global.zshenv" /etc/zshenv
fi
@ -10,4 +12,10 @@ if [ -f /etc/zsh/zshenv ]; then
sudo cp "$CHEZMOI_SOURCE_DIR/dot_config/zsh/global.zshenv" /etc/zsh/zshenv
fi
{{ else }}
cp "$CHEZMOI_SOURCE_DIR/dot_config/zsh/global.zshenv" "$HOME/.zshenv"
{{ end }}
mkdir -p $XDG_STATE_HOME/zsh

View file

@ -0,0 +1,75 @@
# vim:ft=gotmpl
# $DOTFILES/common/gitconfig.example
# Date: 2024-12-22
# Author: js0ny
# Location:
# Windows: %USERPROFILE%\.gitconfig
# *nix: ~/.config/git/config
# Linking: (Note that this file is an example, only copy this then edit)
# cp $DOTFILES/common/gitconfig.example ~/.config/git/config
[user]
name = {{ .username }}
email = {{ .email }}
[alias]
cl = clone
clnh = clone --depth 1 # Clone with no history
cma = commit -am # Add and commit
logs = log --oneline --graph --decorate --all # Show logs
last = log -1 HEAD # Show last commit
undo = reset --hard HEAD # Undo the last commit
[core]
editor = nvim
pager = delta
# autocrlf:
# true: Keep crlf in Windows, lf in *nix
# input: Keep lf in all platforms
autocrlf = input
safecrlf = true
excludesfile = $XDG_CONFIG_HOME/git/ignore
quotePath = false # zh-CN: 解决中文路径问题
eol = lf
[core]
{{- if eq .chezmoi.os "windows" }}
editor = vim
{{- else }}
editor = nvim
{{- end }}
pager = delta
[interactive]
diffFilter = delta --color-only
[delta]
navigate = true
dark = true
features = catppuccin-mocha # Colorscheme
[diff]
tool = nvimdiff
[difftool]
prompt = false
[difftool "nvimdiff"]
cmd = "nvim -d \"$LOCAL\" \"$REMOTE\""
[merge]
tool = nvimdiff
[mergetool]
prompt = false
[mergetool "nvimdiff"]
cmd = "nvim -d \"$LOCAL\" \"$MERGED\" \"$REMOTE\""
[color]
ui = auto
[pull]
ff = only
[init]
defaultBranch = master
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
# Force ssh
# Don't use ssh in GitHub since ssh-agent doesn't work in non-interactive environment
# While GitHub holds many plugins, it's better to use https
# This prevents from Neovide `publickey` error when installing plugins
# [url "git@github.com:"]
# insteadOf = https://github.com/
[url "git@codeberg.org:"]
insteadOf = https://codeberg.org/

View file

@ -0,0 +1,13 @@
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB3TGRYbW9hK3J6RFdnV2pS
UmxVUjFOQ3FTRlF4QU5pOXBqbUlsejB5VHo4CkFnUHh2anVYOWg0UnJMSUhxV2N3
V2dvOFFWRy9HVzRocFlJL2lSWHU1SkEKLS0tIGJxM2EzTTl3cjJxaUhGcHJNSUYx
T0o0WjdoRyt2VE91WTdUS2ZMLzBiM3MKRgj7WcvuTJov2eGBbPAJp8pODpoluwif
f7Fo4xf+QWd0KS9Zkqespha1LK8MSD+C9MUhfrYjP+5mfRO7bEbcc6aH/YmkiA9m
rYZ/kd9TWH2ibFZCyu+MsfpTQhJJj7a7OV+jmgMo34V2jJjTRWOCDgB58kBfy1Pk
fzzNUrrvmt92Eg4MFccSsSEE1ib0oOKa03xx7p0uYGkM1Zbsrhdd+OaMyfY+XT5a
0F95ht+zwjR98i0lnQiGdVYFM7KNZBqgdNJBIKybUZSlpbDlw04fr+/GJwWXlHAx
2zh5hMv95i4ZsKX6qV3dVUEXZ+PHLR+OlH8lgpwSIU+6Bz6qe9OMGUppHcwJX5aw
/ajM/BySPMKxjp+JKDIXeifd510D0kfkFLLUxxkR4p5sDcgl8Z6sDhLL5nOVwWDd
FcDeatJ4R5zqrK+SMQ==
-----END AGE ENCRYPTED FILE-----

View file

@ -17,7 +17,7 @@
#
# If this option is set to mouse or keyboard, the monitor option
# will be ignored.
follow = none
follow = keyboard
### Geometry ###

View file

@ -1,3 +1,4 @@
# vim:ft=gotmpl
# $DOTFILES/common/gitconfig.example
# Date: 2024-12-22
# Author: js0ny

View file

@ -1 +1 @@
{{ includeTemplate "dot_config/git/_gitconfig.shared.tmpl" . }}
{{ template "gitconfig" . }}

View file

@ -1,6 +0,0 @@
# IPython config cache
*/db/
*/log/
*/pid/
*/security/
*/history.sqlite

View file

@ -0,0 +1,543 @@
// This config is in the KDL format: https://kdl.dev
// "/-" comments out the following node.
// Check the wiki for a full description of the configuration:
// https://github.com/YaLTeR/niri/wiki/Configuration:-Introduction
/// Startup Applications
// Window Manager Related
spawn-at-startup "waybar" // Status Bar
spawn-at-startup "dunst" // Notifications
// User Programs
spawn-at-startup "fcitx5" // Input Method
// spawn-at-startup "/nix/store/9kzgpx4vrnmdqc9513wb7d59khacmzvz-polkit-kde-agent-1-6.5.0/libexec/polkit-kde-authentication-agent-1"
spawn-at-startup "/nix/store/0k1mgbhysrwfgnrgnavq704c3nap1irn-xdg-desktop-portal-kde-6.4.3/libexec/xdg-desktop-portal-kde"
spawn-at-startup "/nix/store/rglb6biq8kdbnqa1sfcc77w0isqr88yh-hyprpolkitagent-0.1.3/libexec/hyprpolkitagent"
prefer-no-csd
screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png"
input {
keyboard {
xkb { }
numlock
}
// Next sections include libinput settings.
// Omitting settings disables them, or leaves them at their default values.
touchpad {
// off
tap
// dwt
// dwtp
// drag false
// drag-lock
natural-scroll
// accel-speed 0.2
// accel-profile "flat"
// scroll-method "two-finger"
// disabled-on-external-mouse
}
mouse {
// off
// natural-scroll
// accel-speed 0.2
// accel-profile "flat"
// scroll-method "no-scroll"
}
trackpoint {
// off
// natural-scroll
// accel-speed 0.2
// accel-profile "flat"
// scroll-method "on-button-down"
// scroll-button 273
// middle-emulation
}
// Uncomment this to make the mouse warp to the center of newly focused windows.
// warp-mouse-to-focus
// Focus windows and outputs automatically when moving the mouse into them.
// Setting max-scroll-amount="0%" makes it work only on windows already fully on screen.
// focus-follows-mouse max-scroll-amount="0%"
}
// You can configure outputs by their name, which you can find
// by running `niri msg outputs` while inside a niri instance.
// The built-in laptop monitor is usually called "eDP-1".
// Find more information on the wiki:
// https://github.com/YaLTeR/niri/wiki/Configuration:-Outputs
// Remember to uncomment the node by removing "/-"!
/-output "eDP-1" {
// Uncomment this line to disable this output.
// off
// Resolution and, optionally, refresh rate of the output.
// The format is "<width>x<height>" or "<width>x<height>@<refresh rate>".
// If the refresh rate is omitted, niri will pick the highest refresh rate
// for the resolution.
// If the mode is omitted altogether or is invalid, niri will pick one automatically.
// Run `niri msg outputs` while inside a niri instance to list all outputs and their modes.
mode "1920x1080@120.030"
// You can use integer or fractional scale, for example use 1.5 for 150% scale.
scale 2
// Transform allows to rotate the output counter-clockwise, valid values are:
// normal, 90, 180, 270, flipped, flipped-90, flipped-180 and flipped-270.
transform "normal"
// Position of the output in the global coordinate space.
// This affects directional monitor actions like "focus-monitor-left", and cursor movement.
// The cursor can only move between directly adjacent outputs.
// Output scale and rotation has to be taken into account for positioning:
// outputs are sized in logical, or scaled, pixels.
// For example, a 3840×2160 output with scale 2.0 will have a logical size of 1920×1080,
// so to put another output directly adjacent to it on the right, set its x to 1920.
// If the position is unset or results in an overlap, the output is instead placed
// automatically.
position x=1280 y=0
}
layout {
gaps 16
center-focused-column "never"
// You can customize the widths that "switch-preset-column-width" (Mod+R) toggles between.
preset-column-widths {
// Proportion sets the width as a fraction of the output width, taking gaps into account.
// For example, you can perfectly fit four windows sized "proportion 0.25" on an output.
// The default preset widths are 1/3, 1/2 and 2/3 of the output.
proportion 0.33333
proportion 0.5
proportion 0.66667
// Fixed sets the width in logical pixels exactly.
// fixed 1920
}
// You can also customize the heights that "switch-preset-window-height" (Mod+Shift+R) toggles between.
// preset-window-heights { }
// You can change the default width of the new windows.
default-column-width { proportion 0.5; }
// If you leave the brackets empty, the windows themselves will decide their initial width.
// default-column-width {}
// By default focus ring and border are rendered as a solid background rectangle
// behind windows. That is, they will show up through semitransparent windows.
// This is because windows using client-side decorations can have an arbitrary shape.
//
// If you don't like that, you should uncomment `prefer-no-csd` below.
// Niri will draw focus ring and border *around* windows that agree to omit their
// client-side decorations.
//
// Alternatively, you can override it with a window rule called
// `draw-border-with-background`.
// You can change how the focus ring looks.
focus-ring {
// Uncomment this line to disable the focus ring.
// off
// How many logical pixels the ring extends out from the windows.
width 4
// Colors can be set in a variety of ways:
// - CSS named colors: "red"
// - RGB hex: "#rgb", "#rgba", "#rrggbb", "#rrggbbaa"
// - CSS-like notation: "rgb(255, 127, 0)", rgba(), hsl() and a few others.
// Color of the ring on the active monitor.
active-color "#7fc8ff"
// Color of the ring on inactive monitors.
inactive-color "#505050"
// You can also use gradients. They take precedence over solid colors.
// Gradients are rendered the same as CSS linear-gradient(angle, from, to).
// The angle is the same as in linear-gradient, and is optional,
// defaulting to 180 (top-to-bottom gradient).
// You can use any CSS linear-gradient tool on the web to set these up.
// Changing the color space is also supported, check the wiki for more info.
//
// active-gradient from="#80c8ff" to="#bbddff" angle=45
// You can also color the gradient relative to the entire view
// of the workspace, rather than relative to just the window itself.
// To do that, set relative-to="workspace-view".
//
// inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"
}
// You can also add a border. It's similar to the focus ring, but always visible.
border {
// The settings are the same as for the focus ring.
// If you enable the border, you probably want to disable the focus ring.
off
width 4
active-color "#ffc87f"
inactive-color "#505050"
// Color of the border around windows that request your attention.
urgent-color "#9b0000"
// active-gradient from="#ffbb66" to="#ffc880" angle=45 relative-to="workspace-view"
// inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"
}
// You can enable drop shadows for windows.
shadow {
// Uncomment the next line to enable shadows.
// on
// By default, the shadow draws only around its window, and not behind it.
// Uncomment this setting to make the shadow draw behind its window.
//
// Note that niri has no way of knowing about the CSD window corner
// radius. It has to assume that windows have square corners, leading to
// shadow artifacts inside the CSD rounded corners. This setting fixes
// those artifacts.
//
// However, instead you may want to set prefer-no-csd and/or
// geometry-corner-radius. Then, niri will know the corner radius and
// draw the shadow correctly, without having to draw it behind the
// window. These will also remove client-side shadows if the window
// draws any.
//
// draw-behind-window true
// You can change how shadows look. The values below are in logical
// pixels and match the CSS box-shadow properties.
// Softness controls the shadow blur radius.
softness 30
// Spread expands the shadow.
spread 5
// Offset moves the shadow relative to the window.
offset x=0 y=5
// You can also change the shadow color and opacity.
color "#0007"
}
// Struts shrink the area occupied by windows, similarly to layer-shell panels.
// You can think of them as a kind of outer gaps. They are set in logical pixels.
// Left and right struts will cause the next window to the side to always be visible.
// Top and bottom struts will simply add outer gaps in addition to the area occupied by
// layer-shell panels and regular gaps.
struts {
// left 64
// right 64
// top 64
// bottom 64
}
}
// You can also set this to null to disable saving screenshots to disk.
// screenshot-path null
// Animation settings.
// The wiki explains how to configure individual animations:
// https://github.com/YaLTeR/niri/wiki/Configuration:-Animations
animations {
// Uncomment to turn off all animations.
// off
// Slow down all animations by this factor. Values below 1 speed them up instead.
// slowdown 3.0
}
// Window rules let you adjust behavior for individual windows.
// Find more information on the wiki:
// https://github.com/YaLTeR/niri/wiki/Configuration:-Window-Rules
// Work around WezTerm's initial configure bug
// by setting an empty default-column-width.
// Open the Firefox picture-in-picture player as floating by default.
window-rule {
// This app-id regular expression will work for both:
// - host Firefox (app-id is "firefox")
// - Flatpak Firefox (app-id is "org.mozilla.firefox")
match app-id=r#"firefox$"# title="^Picture-in-Picture$"
open-floating true
}
// Example: block out two password managers from screen capture.
// (This example rule is commented out with a "/-" in front.)
/-window-rule {
match app-id=r#"^org\.keepassxc\.KeePassXC$"#
match app-id=r#"^org\.gnome\.World\.Secrets$"#
block-out-from "screen-capture"
// Use this instead if you want them visible on third-party screenshot tools.
// block-out-from "screencast"
}
// Example: enable rounded corners for all windows.
// (This example rule is commented out with a "/-" in front.)
/-window-rule {
geometry-corner-radius 12
clip-to-geometry true
}
binds {
// Keys consist of modifiers separated by + signs, followed by an XKB key name
// in the end. To find an XKB name for a particular key, you may use a program
// like wev.
//
// "Mod" is a special modifier equal to Super when running on a TTY, and to Alt
// when running as a winit window.
//
// Most actions that you can bind here can also be invoked programmatically with
// `niri msg action do-something`.
// Mod-Shift-/, which is usually the same as Mod-?,
// shows a list of important hotkeys.
Mod+Shift+Slash { show-hotkey-overlay; }
// Suggested binds for running programs: terminal, app launcher, screen locker.
Mod+Return hotkey-overlay-title="Open a Terminal: ghostty" { spawn "ghostty"; }
Mod+D hotkey-overlay-title="Run an Application: rofi" { spawn "rofi" "-show" "drun" "-icon-theme" "Papirus" "-show-icons"; }
Alt+Space hotkey-overlay-title="Run an Application: rofi" { spawn "rofi" "-show" "drun" "-icon-theme" "Papirus" "-show-icons"; }
Mod+Shift+W hotkey-overlay-title="Search open Window: rofi" { spawn "rofi" "-show" "window" "-icon-theme" "Papirus" "-show-icons"; }
// Mod+Alt+L hotkey-overlay-title="Lock the Screen: swaylock" { spawn "swaylock"; }
Mod+E hotkey-overlay-title="Run file explorer" { spawn "dolphin"; }
Mod+Shift+E hotkey-overlay-title="Run terminal explorer" { spawn "kitty" "bash" "-c" "yazi"; }
// You can also use a shell. Do this if you need pipes, multiple commands, etc.
// Note: the entire command goes as a single argument in the end.
// Mod+T { spawn "bash" "-c" "notify-send hello && exec alacritty"; }
// Example volume keys mappings for PipeWire & WirePlumber.
// The allow-when-locked=true property makes them work even when the session is locked.
XF86AudioRaiseVolume allow-when-locked=true { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.1+"; }
XF86AudioLowerVolume allow-when-locked=true { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.1-"; }
XF86AudioMute allow-when-locked=true { spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SINK@" "toggle"; }
XF86AudioMicMute allow-when-locked=true { spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SOURCE@" "toggle"; }
// Open/close the Overview: a zoomed-out view of workspaces and windows.
// You can also move the mouse into the top-left hot corner,
// or do a four-finger swipe up on a touchpad.
Mod+Tab { toggle-overview; }
Mod+Q { close-window; }
Mod+Left { focus-column-left; }
Mod+Down { focus-window-down; }
Mod+Up { focus-window-up; }
Mod+Right { focus-column-right; }
Mod+H { focus-column-left; }
Mod+J { focus-window-down; }
Mod+K { focus-window-up; }
Mod+L { focus-column-right; }
Mod+Shift+Left { move-column-left; }
Mod+Shift+Down { move-window-down; }
Mod+Shift+Up { move-window-up; }
Mod+Shift+Right { move-column-right; }
Mod+Shift+H { move-column-left; }
Mod+Shift+J { move-window-down; }
Mod+Shift+K { move-window-up; }
Mod+Shift+L { move-column-right; }
// Alternative commands that move across workspaces when reaching
// the first or last window in a column.
// Mod+J { focus-window-or-workspace-down; }
// Mod+K { focus-window-or-workspace-up; }
// Mod+Ctrl+J { move-window-down-or-to-workspace-down; }
// Mod+Ctrl+K { move-window-up-or-to-workspace-up; }
Mod+Home { focus-column-first; }
Mod+End { focus-column-last; }
Mod+Ctrl+Home { move-column-to-first; }
Mod+Ctrl+End { move-column-to-last; }
Mod+Alt+Left { focus-monitor-left; }
Mod+Alt+Down { focus-monitor-down; }
Mod+Alt+Up { focus-monitor-up; }
Mod+Alt+Right { focus-monitor-right; }
Mod+Alt+H { focus-monitor-left; }
Mod+Alt+J { focus-monitor-down; }
Mod+Alt+K { focus-monitor-up; }
Mod+Alt+L { focus-monitor-right; }
Mod+Shift+Ctrl+Left { move-column-to-monitor-left; }
Mod+Shift+Ctrl+Down { move-column-to-monitor-down; }
Mod+Shift+Ctrl+Up { move-column-to-monitor-up; }
Mod+Shift+Ctrl+Right { move-column-to-monitor-right; }
Mod+Shift+Ctrl+H { move-column-to-monitor-left; }
Mod+Shift+Ctrl+J { move-column-to-monitor-down; }
Mod+Shift+Ctrl+K { move-column-to-monitor-up; }
Mod+Shift+Ctrl+L { move-column-to-monitor-right; }
// Alternatively, there are commands to move just a single window:
// Mod+Shift+Ctrl+Left { move-window-to-monitor-left; }
// ...
// And you can also move a whole workspace to another monitor:
// Mod+Shift+Ctrl+Left { move-workspace-to-monitor-left; }
// ...
Mod+Page_Down { focus-workspace-down; }
Mod+Page_Up { focus-workspace-up; }
Mod+U { focus-workspace-down; }
Mod+I { focus-workspace-up; }
Mod+Ctrl+Page_Down { move-column-to-workspace-down; }
Mod+Ctrl+Page_Up { move-column-to-workspace-up; }
Mod+Ctrl+U { move-column-to-workspace-down; }
Mod+Ctrl+I { move-column-to-workspace-up; }
// Alternatively, there are commands to move just a single window:
// Mod+Ctrl+Page_Down { move-window-to-workspace-down; }
// ...
Mod+Shift+Page_Down { move-workspace-down; }
Mod+Shift+Page_Up { move-workspace-up; }
Mod+Shift+U { move-workspace-down; }
Mod+Shift+I { move-workspace-up; }
// You can bind mouse wheel scroll ticks using the following syntax.
// These binds will change direction based on the natural-scroll setting.
//
// To avoid scrolling through workspaces really fast, you can use
// the cooldown-ms property. The bind will be rate-limited to this value.
// You can set a cooldown on any bind, but it's most useful for the wheel.
Mod+WheelScrollDown cooldown-ms=150 { focus-workspace-down; }
Mod+WheelScrollUp cooldown-ms=150 { focus-workspace-up; }
Mod+Ctrl+WheelScrollDown cooldown-ms=150 { move-column-to-workspace-down; }
Mod+Ctrl+WheelScrollUp cooldown-ms=150 { move-column-to-workspace-up; }
Mod+WheelScrollRight { focus-column-right; }
Mod+WheelScrollLeft { focus-column-left; }
Mod+Ctrl+WheelScrollRight { move-column-right; }
Mod+Ctrl+WheelScrollLeft { move-column-left; }
// Usually scrolling up and down with Shift in applications results in
// horizontal scrolling; these binds replicate that.
Mod+Shift+WheelScrollDown { focus-column-right; }
Mod+Shift+WheelScrollUp { focus-column-left; }
Mod+Ctrl+Shift+WheelScrollDown { move-column-right; }
Mod+Ctrl+Shift+WheelScrollUp { move-column-left; }
// Similarly, you can bind touchpad scroll "ticks".
// Touchpad scrolling is continuous, so for these binds it is split into
// discrete intervals.
// These binds are also affected by touchpad's natural-scroll, so these
// example binds are "inverted", since we have natural-scroll enabled for
// touchpads by default.
// Mod+TouchpadScrollDown { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.02+"; }
// Mod+TouchpadScrollUp { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.02-"; }
// You can refer to workspaces by index. However, keep in mind that
// niri is a dynamic workspace system, so these commands are kind of
// "best effort". Trying to refer to a workspace index bigger than
// the current workspace count will instead refer to the bottommost
// (empty) workspace.
//
// For example, with 2 workspaces + 1 empty, indices 3, 4, 5 and so on
// will all refer to the 3rd workspace.
Mod+1 { focus-workspace 1; }
Mod+2 { focus-workspace 2; }
Mod+3 { focus-workspace 3; }
Mod+4 { focus-workspace 4; }
Mod+5 { focus-workspace 5; }
Mod+6 { focus-workspace 6; }
Mod+7 { focus-workspace 7; }
Mod+8 { focus-workspace 8; }
Mod+9 { focus-workspace 9; }
Mod+Shift+1 { move-column-to-workspace 1; }
Mod+Shift+2 { move-column-to-workspace 2; }
Mod+Shift+3 { move-column-to-workspace 3; }
Mod+Shift+4 { move-column-to-workspace 4; }
Mod+Shift+5 { move-column-to-workspace 5; }
Mod+Shift+6 { move-column-to-workspace 6; }
Mod+Shift+7 { move-column-to-workspace 7; }
Mod+Shift+8 { move-column-to-workspace 8; }
Mod+Shift+9 { move-column-to-workspace 9; }
// Alternatively, there are commands to move just a single window:
// Mod+Ctrl+1 { move-window-to-workspace 1; }
// Switches focus between the current and the previous workspace.
// Mod+Tab { focus-workspace-previous; }
// The following binds move the focused window in and out of a column.
// If the window is alone, they will consume it into the nearby column to the side.
// If the window is already in a column, they will expel it out.
Mod+BracketLeft { consume-or-expel-window-left; }
Mod+BracketRight { consume-or-expel-window-right; }
// Consume one window from the right to the bottom of the focused column.
Mod+Comma { consume-window-into-column; }
// Expel the bottom window from the focused column to the right.
Mod+Period { expel-window-from-column; }
Mod+R { switch-preset-column-width; }
Mod+Shift+R { switch-preset-window-height; }
Mod+Ctrl+R { reset-window-height; }
Mod+F { maximize-column; }
Mod+Shift+F { fullscreen-window; }
// Expand the focused column to space not taken up by other fully visible columns.
// Makes the column "fill the rest of the space".
Mod+Ctrl+F { expand-column-to-available-width; }
Mod+C { center-column; }
// Center all fully visible columns on screen.
Mod+Ctrl+C { center-visible-columns; }
// Finer width adjustments.
// This command can also:
// * set width in pixels: "1000"
// * adjust width in pixels: "-5" or "+5"
// * set width as a percentage of screen width: "25%"
// * adjust width as a percentage of screen width: "-10%" or "+10%"
// Pixel sizes use logical, or scaled, pixels. I.e. on an output with scale 2.0,
// set-column-width "100" will make the column occupy 200 physical screen pixels.
Mod+Minus { set-column-width "-10%"; }
Mod+Equal { set-column-width "+10%"; }
// Finer height adjustments when in column with other windows.
Mod+Shift+Minus { set-window-height "-10%"; }
Mod+Shift+Equal { set-window-height "+10%"; }
// Move the focused window between the floating and the tiling layout.
Mod+V { toggle-window-floating; }
Mod+Shift+V { switch-focus-between-floating-and-tiling; }
// Toggle tabbed column display mode.
// Windows in this column will appear as vertical tabs,
// rather than stacked on top of each other.
Mod+W { toggle-column-tabbed-display; }
Mod+Shift+S { screenshot; }
Print { screenshot; }
Ctrl+Print { screenshot-screen; }
Alt+Print { screenshot-window; }
// Applications such as remote-desktop clients and software KVM switches may
// request that niri stops processing the keyboard shortcuts defined here
// so they may, for example, forward the key presses as-is to a remote machine.
// It's a good idea to bind an escape hatch to toggle the inhibitor,
// so a buggy application can't hold your session hostage.
//
// The allow-inhibiting=false property can be applied to other binds as well,
// which ensures niri always processes them, even when an inhibitor is active.
Mod+Escape allow-inhibiting=false { toggle-keyboard-shortcuts-inhibit; }
Ctrl+Alt+Delete { quit; }
}

View file

@ -75,7 +75,7 @@
},
"dock": "bottom",
"env": {
"EDITOR": "zed --wait"
"EDITOR": "zeditor"
},
"shell": {
"program": "fish"

View file

@ -8,3 +8,4 @@
# 这个文件只存储只在交互式会话中调用的环境变量。
export IPYTHONDIR="$XDG_CONFIG_HOME"/ipython
export OPENROUTER_API_KEY={{- "secrets/OPENROUTER_API_KEY.age" | include | decrypt -}}

View file

@ -0,0 +1,8 @@
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBrc2VLbklFMHgyZWRPanlx
cTQxZzFQQjByL1h1YW5nN2dNV3VwTjh2N240CjdoaUZTU25hYVZjeG9tRkQ1c2VF
clQ0bUpmMzhZOVlYWVNxS0JGOEFvYVEKLS0tIHFqUmF6T2NweDMwbzVtOW5ybUFi
RG8xd3pzc2JVUVVtNGdpNkM1V0xpdlkKNKv83oM/a39dlPhpTi3upVxFRkaINyIZ
VwpduNnlRolPgoEhjEZ5u8opDvy765vGUrAVXCo7AG4z++rsF1+Ok/xirJ7K8c9M
AmTG6oiDlNX8z5g9mnlfPKpRr4lmdMkPKW9/TYa2sWxm4g==
-----END AGE ENCRYPTED FILE-----

View file

@ -14,10 +14,6 @@
"install_url": "https://addons.mozilla.org/firefox/downloads/latest/side-view/latest.xpi",
"installation_mode": "force_installed"
},
"langpack-zh-CN@firefox.mozilla.org": {
"install_url": "https://releases.mozilla.org/pub/firefox/releases/144.0/linux-x86_64/xpi/zh-CN.xpi",
"installation_mode": "normal_installed"
},
"uBlock0@raymondhill.net": {
"install_url": "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi",
"installation_mode": "force_installed"

View file

@ -1,12 +1,13 @@
{
"n": "cmd:cmd_nextMsg",
"e": "cmd:cmd_previousMsg",
"j": "cmd:cmd_nextMsg",
"k": "cmd:cmd_previousMsg",
"o": "cmd:cmd_openMessage",
"f": "cmd:cmd_forward",
"#": "cmd:cmd_delete",
"r": "cmd:cmd_reply",
"a": "cmd:cmd_replyall",
"A": "cmd:cmd_replyall",
"x": "cmd:cmd_archive",
"a": "cmd:cmd_archive",
"c": "func:MsgNewMessage",
"u": "tbkeys:closeMessageAndRefresh"
}

View file

@ -1,5 +1,8 @@
{pkgs, ...}: let
nvimAlias = {"v" = "nvim";};
nvimAlias = {
"v" = "nvim";
"g" = "nvim +Neogit";
};
in {
programs.neovim = {
enable = true;

View file

@ -4,4 +4,34 @@
rofimoji
rofi-power-menu
];
# The default desktop entry does not have `categories` field, add it manually.
xdg.desktopEntries = {
"rofi" = {
name = "Rofi";
genericName = "Launcher";
comment = "A versatile window switcher, application launcher, and dmenu replacement";
icon = "rofi";
type = "Application";
terminal = false;
categories = [
"System"
"Utility"
];
exec = "rofi -show";
};
"rofi-theme-selector" = {
name = "Rofi Theme Selector";
genericName = "Theme Selector";
comment = "Select a theme for Rofi";
icon = "rofi";
type = "Application";
terminal = false;
categories = [
"System"
"Utility"
];
exec = "rofi-theme-selector";
};
};
}

View file

@ -1,6 +1,5 @@
{pkgs}: let
commonAliases = {
g = "lazygit";
ni = "touch";
cls = "clear";
aic = "aichat -s";
@ -8,6 +7,7 @@
nrs = "sudo nixos-rebuild switch --flake ~/.dotfiles/nixcfgs";
clip = "wl-copy";
paste = "wl-paste";
ipy = "nix run 'nixpkgs#python313Packages.ipython'"; # IPython
};
darwinAliases = {
reboot = "sudo reboot";

3
readme.md Normal file
View file

@ -0,0 +1,3 @@
# dotfiles
Managed by [chezmoi](https://www.chezmoi.io/) and [home-manager](https://github.com/nix-community/home-manager)

View file

@ -1,3 +0,0 @@
* dotfiles
Migrating to ~chezmoi~.