在 Linux 下备份 compton(现在很多发行版用它的分支 picom)的配置,通常只需要复制它的配置文件和相关环境即可。下面按常见情况说明。
compton 的配置文件通常位于以下之一:
~/.config/compton.conf~/.compton.conf/etc/compton.conf(系统级,较少见)如果你用的是 picom(compton 的维护分支):
~/.config/picom.conf~/.picom.conf可用以下命令查找:
ls -la ~/.config | grep -E "compton|picom"
ls -la ~ | grep -E "compton|picom"
cp ~/.config/compton.conf ./compton.conf.bak
tar czvf compton-config-backup.tar.gz ~/.config/compton.conf
或(如果是 picom):
tar czvf picom-config-backup.tar.gz ~/.config/picom.conf
ps aux | grep compton
或
ps aux | grep picom
如果你是通过命令行启动,例如:
compton --config ~/.config/compton.conf -b
建议把这条命令也记下来或写进脚本。
如果你用 systemd 管理:
ls ~/.config/systemd/user/ | grep compton
备份示例:
cp ~/.config/systemd/user/compton.service ./compton.service.bak
#!/bin/bash
BACKUP_DIR=~/compton-backup-$(date +%Y%m%d)
mkdir -p $BACKUP_DIR
[ -f ~/.config/compton.conf ] && cp ~/.config/compton.conf $BACKUP_DIR/
[ -f ~/.config/picom.conf ] && cp ~/.config/picom.conf $BACKUP_DIR/
[ -f ~/.config/systemd/user/compton.service ] && cp ~/.config/systemd/user/compton.service $BACKUP_DIR/
echo "备份完成:$BACKUP_DIR"
cp compton.conf.bak ~/.config/compton.conf
若修改后未生效,可重启 compton:
pkill compton
compton --config ~/.config/compton.conf -b
如果你愿意,可以告诉我:
我可以给你更精确的备份方案。