-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·85 lines (71 loc) · 2.65 KB
/
setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
# Thanks to: https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# cf actual_file link_file
cf() {
SRC="$SCRIPT_DIR/$1"
DST="$HOME/$2"
if [[ $1 =~ ^/ ]]; then SRC=$1; fi
if [[ $2 =~ ^/ ]]; then DST=$2; fi
if [ -e "$SRC" ]; then
rm -f "$DST"
mkdir -p "$(dirname "$DST")"
ln -s "$SRC" "$DST"
fi
}
cfp() {
SRC="$SCRIPT_DIR/$1"
DST="$HOME/$2"
if [[ $1 =~ ^/ ]]; then SRC=$1; fi
if [[ $2 =~ ^/ ]]; then DST=$2; fi
if [ -e "$SRC" ]; then
rm -f "$DST"
mkdir -p "$(dirname "$DST")"
cp -f "$SRC" "$DST"
chmod 755 "$DST"
fi
}
if [ "${EUID:-$(id -u)}" -eq 0 ]; then # run as root
cfp sys/start-river-alan /usr/local/bin/start-river-alan
cfp sys/greetd.toml /etc/greetd/config.toml
cfp sys/radico8-player.service /etc/systemd/user/radico8-player.service
cfp sys/foot-server.service /etc/systemd/user/foot-server.service
cfp sys/wl-gammarelay-rs.service /etc/systemd/user/wl-gammarelay-rs.service
cfp sys/rivertile.service /etc/systemd/user/rivertile.service
cfp sys/foot-server.service /etc/systemd/user/foot-server.service
cfp sys/keyd.conf /etc/keyd/default.conf
cfp sys/pipewire-input-denoise.conf /etc/pipewire/pipewire.conf.d/99-input-denoising.conf
cfp sys/shells /etc/shells
systemctl daemon-reload
else # run as user
cf usr/zshrc .zshrc
cf usr/zshenv .zshenv
cf usr/aliases .aliases
cf usr/tmuxconf .tmux.conf
cf usr/local_aliases .local_aliases
cf usr/local_gitconfig .local_gitconfig
cf usr/gitignore .gitignore
cf usr/git-templates .git-templates
cf usr/kak .config/kak
cf usr/kak-lsp .config/kak-lsp
cf usr/mpv.conf .config/mpv/mpv.conf
cf usr/gitconfig .config/git/config
cf usr/riverconfig .config/river/init
cf usr/foot.ini .config/foot/foot.ini
cf usr/ssh-config .ssh/config
cf usr/mimeapps.list .config/mimeapps.list
cf usr/alacritty.yml .config/alacritty/alacritty.yml
# cf usr/search-ignore .config/fd/ignore
cf usr/himalaya.toml .config/himalaya/config.toml
cf usr/doc doc
cf ~/sync/alan/diary/concards-data .local/share/concards
cf ~/sync/alan/diary/ttrack .local/share/ttrack
# Ripgrep config can't recognize environment variables in its configuration.
# Putting the config here is my best solution.
cat << EOF > $HOME/.rgconfig
--no-heading
--no-follow
--hidden
EOF
systemctl daemon-reload --user
fi