From b391e03c87b13627a6bcb459e452c6b60d3184da Mon Sep 17 00:00:00 2001 From: js0ny Date: Sat, 27 Sep 2025 14:40:01 +0100 Subject: [PATCH] chezmoi: systemd --- .chezmoiignore | 2 ++ .../systemd/user/emacs-daemon.service | 0 .../systemd/user/keyd-app.service | 0 dot_config/systemd/user/mihomo.service | 27 +++++++++++++++++++ dot_config/zsh/dot_zshrc | 15 ++++++++--- platforms/linux/zshrc | 12 --------- platforms/mac/zshrc | 19 ------------- platforms/wsl/zshrc | 22 --------------- {platforms/linux => tools}/keyd/default.conf | 0 9 files changed, 40 insertions(+), 57 deletions(-) rename {platforms/linux => dot_config}/systemd/user/emacs-daemon.service (100%) rename {platforms/linux => dot_config}/systemd/user/keyd-app.service (100%) create mode 100644 dot_config/systemd/user/mihomo.service delete mode 100644 platforms/linux/zshrc rename {platforms/linux => tools}/keyd/default.conf (100%) diff --git a/.chezmoiignore b/.chezmoiignore index 6cf6f39..0e17f10 100644 --- a/.chezmoiignore +++ b/.chezmoiignore @@ -29,4 +29,6 @@ dot_config/user-dirs.locale # ArchLinux only {{ if ne .chezmoi.osRelease.id "arch" -}} +chromium-flags.conf +electron-flags.conf {{ end -}} diff --git a/platforms/linux/systemd/user/emacs-daemon.service b/dot_config/systemd/user/emacs-daemon.service similarity index 100% rename from platforms/linux/systemd/user/emacs-daemon.service rename to dot_config/systemd/user/emacs-daemon.service diff --git a/platforms/linux/systemd/user/keyd-app.service b/dot_config/systemd/user/keyd-app.service similarity index 100% rename from platforms/linux/systemd/user/keyd-app.service rename to dot_config/systemd/user/keyd-app.service diff --git a/dot_config/systemd/user/mihomo.service b/dot_config/systemd/user/mihomo.service new file mode 100644 index 0000000..1dc1a0e --- /dev/null +++ b/dot_config/systemd/user/mihomo.service @@ -0,0 +1,27 @@ +# ~/.config/systemd/user/mihomo.service + +[Unit] +Description=mihomo Service +# This ensures the service only starts after your network is online. +After=network-online.target +Wants=network-online.target + +[Service] +# The main process to run. +# The WorkingDirectory is set to your user's home directory. +# This assumes your mihomo configuration is located at ~/.config/mihomo/ +WorkingDirectory=%h/.config/mihomo +# It's common for user-level applications to be in a directory like ~/.local/bin +# or simply in your PATH. +ExecStart=mihomo + +# This tells systemd to restart the service if it stops unexpectedly. +Restart=on-failure +# This sets the restart interval to 5 seconds. +RestartSec=5s + +[Install] +# This unit should be active when the user's session is active, +# ensuring it starts when you log in. +WantedBy=default.target + diff --git a/dot_config/zsh/dot_zshrc b/dot_config/zsh/dot_zshrc index d3451c6..c004101 100644 --- a/dot_config/zsh/dot_zshrc +++ b/dot_config/zsh/dot_zshrc @@ -1,4 +1,5 @@ # $DOTFILES/tools/zsh/common.zshrc +# vim:ft=zsh # Date: 2024-11-30 # Author: js0ny # This is the entry point for all zsh configuration files @@ -14,15 +15,22 @@ case "$(uname)" in Linux) if grep -q Microsoft /proc/version || [[ -n "$WSL_DISTRO_NAME" ]]; then # WSL-specific configuration - source "$DOTFILES/platforms/wsl/zshrc" + export IS_WSL=true + source $DOTFILES/platforms/wsl/winterop.zsh else # Native Linux configuration - source "$DOTFILES/platforms/linux/zshrc" + if [ -n "$WAYLAND_DISPLAY" ]; then + alias clip="wl-copy" + alias paste="wl-paste" + elif [ -n "$DISPLAY" ]; then + alias clip="xclip" + fi fi ;; Darwin) # macOS-specific configuration - source "$DOTFILES/platforms/mac/zshrc" + alias clip="pbcopy" + alias paste="pbpaste" ;; # CYGWIN*|MINGW*|MSYS*) # source "$DOTFILES/platform/wsl.zsh" @@ -34,4 +42,3 @@ for file in $DOTFILES/tools/zsh/mod/*.zsh; do done [ -f "/home/js0ny/.local/share/ghcup/env" ] && . "/home/js0ny/.local/share/ghcup/env" # ghcup-env -. "/home/js0ny/.deno/env" \ No newline at end of file diff --git a/platforms/linux/zshrc b/platforms/linux/zshrc deleted file mode 100644 index 6578292..0000000 --- a/platforms/linux/zshrc +++ /dev/null @@ -1,12 +0,0 @@ -# $DOTFILES/platforms/linux/zshrc -# Date: 2024-12-22 -# Author: js0ny -# Sourced by user's zshrc if is Linux 在用户的 zshrc 中被引用 -# Entry point in $DOTFILES/tools/zsh/common.zshrc (入口点) - -if [ -n "$WAYLAND_DISPLAY" ]; then - alias clip="wl-copy" - alias paste="wl-paste" -elif [ -n "$DISPLAY" ]; then - alias clip="xclip" -fi diff --git a/platforms/mac/zshrc b/platforms/mac/zshrc index 5439ba3..7fbe8a6 100644 --- a/platforms/mac/zshrc +++ b/platforms/mac/zshrc @@ -6,22 +6,3 @@ # macOS # -alias clip="pbcopy" -alias paste="pbpaste" - -# >>> conda initialize >>> -# !! Contents within this block are managed by 'conda init' !! -__conda_setup="$('/opt/homebrew/Caskroom/miniconda/base/bin/conda' 'shell.zsh' 'hook' 2>/dev/null)" -if [ $? -eq 0 ]; then - eval "$__conda_setup" -else - if [ -f "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh" ]; then - . "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh" - else - export PATH="/opt/homebrew/Caskroom/miniconda/base/bin:$PATH" - fi -fi -unset __conda_setup -# <<< conda initialize <<< - -alias start-twm="source $DOTFILES/scripts/__twm_osx_start.zsh" diff --git a/platforms/wsl/zshrc b/platforms/wsl/zshrc index 107ca41..bc2ece3 100644 --- a/platforms/wsl/zshrc +++ b/platforms/wsl/zshrc @@ -6,26 +6,4 @@ ### Variables ### export IS_WSL=true -export ARCHFLAGS="-arch x86_64" source $DOTFILES/platforms/wsl/winterop.zsh - -### Misc ### - -export PATH=/opt/bin:$PATH - -# Conda # - -# >>> conda initialize >>> -# !! Contents within this block are managed by 'conda init' !! -__conda_setup="$('$HOME/miniconda3/bin/conda' 'shell.zsh' 'hook' 2>/dev/null)" -if [ $? -eq 0 ]; then - eval "$__conda_setup" -else - if [ -f "$HOME/miniconda3/etc/profile.d/conda.sh" ]; then - . "$HOME/miniconda3/etc/profile.d/conda.sh" - else - export PATH="$HOME/miniconda3/bin:$PATH" - fi -fi -unset __conda_setup -# <<< conda initialize <<< diff --git a/platforms/linux/keyd/default.conf b/tools/keyd/default.conf similarity index 100% rename from platforms/linux/keyd/default.conf rename to tools/keyd/default.conf