place-dotfiles-extra.sh
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 |
#!/bin/sh
# place-dotfiles-extra.sh: simple script to symlink many of my extra dotfiles
# TODO: actually test, maybe improve
# by x1phosura
dotfiles_root="$HOME"/73h4x/dotfiles/dotfiles-extra # where dotfiles live
#dotfiles_root="$PWD" # alternative (for testing)
dest="$HOME" # usually $HOME
#display_server=x11
#display_server=wayland
# if below fails, can use:
# $ loginctl show-session $(loginctl | grep $(whoami) | awk '{print $1}') -p Type
# or similar
display_server="$XDG_SESSION_TYPE"
die() {
echo "$@"; exit 1
}
[ ! -d "$dotfiles_root" ] && \
die "ERROR: $dotfiles_root doesn't exist. Aborting..."
# TODO: change '[[' to '[', test...
#[[ "$(realpath $dotfiles_root)" = "$(realpath $dest)" ]] && \
# die " ERROR: dotfiles_root and dest are the same directory! Aborting..."
dotfiles_extra_list=".config/nano \
.config/radare2 \
.config/ranger \
.config/systemd"
dotfiles_extra_x11_list=".config/alacritty \
.config/compton \
.config/i3 \
.config/i3status \
.config/picom \
.config/polybar \
.config/redshift \
.config/rofi \
.xinitrc \
.Xresources \
.Xresources-manjaro"
dotfiles_extra_wayland_list=".config/kitty \
.config/sway \
.config/waybar \
.config/wlsunset"
# Note: directly symlink items to .config instead of symlinking .config itself
# because I don't want to preserve everything that programs create there
mkdir -p "$dest"/.config
for file in $dotfiles_extra_list; do
# TODO: only link after checking file's existence in config_dir_list
ln -svfn "$dotfiles_root/$file" "$dest"/"$file"
done
if [ "$display_server" = "x11" ]; then
for file in $dotfiles_extra_x11_list; do
# TODO: only link after checking file's existence in config_dir_list
ln -svfn "$dotfiles_root/$file" "$dest"/"$file"
done
elif [ "$display_server" = "wayland" ]; then
for file in $dotfiles_extra_wayland_list; do
# TODO: only link after checking file's existence in config_dir_list
ln -svfn "$dotfiles_root/$file" "$dest"/"$file"
done
else
echo "error: cannot tell if X11 or Wayland session. Aborting..."
fi
# link personal /bin directory (ex. contains scripts and such...)
# TODO: iterate over files in 'bin/', symlink in existing ~/bin dir
ln -svfn "$dotfiles_root"/bin "$dest"/bin
# link /etc dotfiles (some of these HAVE to be in /etc)
#sudo ln -svf "$dotfiles_root"/etc/default/tlp /etc/default/tlp # tlp dir
|