From 0b0da0b8db84670dbc5afcb8a6d33fb6e5d8f923 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Thu, 30 Dec 2021 20:35:43 +0100 Subject: [PATCH] Reworking the install script --- .gitmodules | 2 +- dunst/config/{ => dunst}/dunstrc | 0 .../config/{ => flameshot}/flameshot.ini | 0 fontconfig/config/{ => fontconfig}/fonts.conf | 0 gtk/{themes => themes.ln}/MaterialOcean | 0 install.sh | 122 ++++++++++-------- kitty/config/{ => kitty}/kitty.conf | 0 picom/config/{ => picom}/picom.conf | 0 qt5ct/install.sh | 5 +- rofi/config/{ => rofi}/config.rasi | 0 .../{ => rofi}/powermenu/powermenu.rasi | 0 rofi/config/{ => rofi}/powermenu/powermenu.sh | 0 rofi/config/{ => rofi}/theme.rasi | 0 sxhkd/config/{ => sxhkd}/sxhkdrc | 0 .../Kujira no Kora wa Sajou ni Utau.png | Bin {wallpapers => wallpapers.ln}/MadeInAbyss.jpg | Bin {wallpapers => wallpapers.ln}/Shelter.jpeg | Bin {wallpapers => wallpapers.ln}/blue-period.jpg | Bin 18 files changed, 72 insertions(+), 57 deletions(-) rename dunst/config/{ => dunst}/dunstrc (100%) rename flameshot/config/{ => flameshot}/flameshot.ini (100%) rename fontconfig/config/{ => fontconfig}/fonts.conf (100%) rename gtk/{themes => themes.ln}/MaterialOcean (100%) rename kitty/config/{ => kitty}/kitty.conf (100%) rename picom/config/{ => picom}/picom.conf (100%) rename rofi/config/{ => rofi}/config.rasi (100%) rename rofi/config/{ => rofi}/powermenu/powermenu.rasi (100%) rename rofi/config/{ => rofi}/powermenu/powermenu.sh (100%) rename rofi/config/{ => rofi}/theme.rasi (100%) rename sxhkd/config/{ => sxhkd}/sxhkdrc (100%) rename {wallpapers => wallpapers.ln}/Kujira no Kora wa Sajou ni Utau.png (100%) rename {wallpapers => wallpapers.ln}/MadeInAbyss.jpg (100%) rename {wallpapers => wallpapers.ln}/Shelter.jpeg (100%) rename {wallpapers => wallpapers.ln}/blue-period.jpg (100%) diff --git a/.gitmodules b/.gitmodules index 53b01e2..c98d312 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,5 +1,5 @@ [submodule "gtk/themes/MaterialOcean"] - path = gtk/themes/MaterialOcean + path = gtk/themes.ln/MaterialOcean url = git@github.com:material-ocean/Gtk-Theme.git [submodule "qt5ct/config"] path = qt5ct/config diff --git a/dunst/config/dunstrc b/dunst/config/dunst/dunstrc similarity index 100% rename from dunst/config/dunstrc rename to dunst/config/dunst/dunstrc diff --git a/flameshot/config/flameshot.ini b/flameshot/config/flameshot/flameshot.ini similarity index 100% rename from flameshot/config/flameshot.ini rename to flameshot/config/flameshot/flameshot.ini diff --git a/fontconfig/config/fonts.conf b/fontconfig/config/fontconfig/fonts.conf similarity index 100% rename from fontconfig/config/fonts.conf rename to fontconfig/config/fontconfig/fonts.conf diff --git a/gtk/themes/MaterialOcean b/gtk/themes.ln/MaterialOcean similarity index 100% rename from gtk/themes/MaterialOcean rename to gtk/themes.ln/MaterialOcean diff --git a/install.sh b/install.sh index cb2af80..e95810d 100755 --- a/install.sh +++ b/install.sh @@ -1,12 +1,5 @@ #!/usr/bin/env zsh set -e - -if [[ "$1" == "-h" ]]; then - echo "Usage: $0 [-i]" - echo "\t-i: Clone dependencies (oh-my-zsh, powerlevel10k...)" - exit 0 -fi - cd $(dirname $0) info() @@ -19,54 +12,23 @@ warn() printf "\r[ \033[00;31m!!\033[0m ] $*\n" } -# TODO pacman/zsh.hook location. -# for file in $(find */ -type f -not -name '*.zsh'); do -# dest=~/.$(basename $file) -# if [[ $(readlink -f $dest) == $file ]]; then -# info File already linked ($file). Skipping... -# break -# fi -# info Linking $file -# if [[ -e $dest ]]; then -# warn File $dest already exists. Moving it to ~/bak/ -# mv $dest ~/bak -f -# fi -# ln -s $(realpath $file) "$dest" -f -# done - -# TODO clean up this huge chunk -ln -s "$(realpath zsh/zshrc)" ~/.zshrc -f -ln -s "$(realpath zsh/profile)" ~/.profile -f -ln -s "$(realpath X11/xinitrc)" ~/.xinitrc -f -ln -s "$(realpath X11/Xresources)" ~/.Xresources -f -ln -s "$(realpath wallpapers)" ~/.wallpapers -f -ln -s "$(realpath dunst/config)" ~/.config/dunst -f -ln -s "$(realpath sxhkd/config)" ~/.config/sxhkd -f -ln -s "$(realpath rofi/config)" ~/.config/rofi -f -ln -s "$(realpath kitty/config)" ~/.config/kitty -f -ln -s "$(realpath picom/config)" ~/.config/picom -f -ln -s "$(realpath flameshot/config)" ~/.config/flameshot -f -ln -s "$(realpath fontconfig/config)" ~/.config/fontconfig -f -ln -s "$(realpath gtk/themes)" ~/.themes -f -ln -s "$(realpath gtk/config/gtk-3.0/settings.ini)" ~/.config/gtk-3.0/settings.ini -f -ln -s "$(realpath gtk/gtkrc-2.0)" ~/.gtkrc-2.0 -f - -./qt5ct/install.sh - -sudo ln -s "$(realpath startdwm)" /usr/bin/startdwm -f -sudo ln -s "$(realpath dwm.desktop)" /usr/share/xsessions/dwm.desktop -f -sudo ln -s "$(realpath fonts)" /usr/local/share/fonts -f -sudo ln -s /etc/fonts/conf.avail/10-scale-bitmap-fonts.conf /etc/fonts/conf.d/ - -clone() -{ - if [[ ! -d "$1" ]]; then - info "Clonning $(basename $1) ..." - git clone "$2" "$1" - fi +usage() { + echo "Usage: $0 [-i]" + echo "\t-d: Clone dependencies (oh-my-zsh, powerlevel10k...)" + echo "\t-x: Install things for an X server (fonts, dwm, redshift...)" + echo "\t-h: Show this help message." + exit 0 } -if [[ "$1" == "-i" ]]; then +dependencies() { + clone() + { + if [[ ! -d "$1" ]]; then + info "Clonning $(basename $1) ..." + git clone "$2" "$1" + fi + } + info "Installing dependencies..." local ZSH_CUSTOM=~/.oh-my-zsh/custom @@ -82,5 +44,57 @@ if [[ "$1" == "-i" ]]; then export ZSH_CUSTOM="$HOME/.oh-my-zsh/custom" eof fi -fi +} + +install() { + for topic in $(find . -mindepth 1 -maxdepth 1 -type d -not -name '.*'); do + if [[ ${topic##*.} == "ln" ]]; then + dest=~/.$(basename ${topic%.*}) + [[ -f $dest ]] \ + && warn "$dest already exists." \ + || info "Linking $dest" && ln -s $(realpath $topic) $dest + elif [[ -f $topic/Makefile ]]; then + info "Running Makefile for $topic (commented for now)" + #make -C $topic install + elif [[ -f $topic/install.sh ]]; then + info "Running install.sh for $topic" + $topic/install.sh + else + for file in $(find $topic -type f -not -name '*.zsh' -or -type d -path '*.ln' -prune); do + dest=~/.$(realpath --relative-to $topic $file) + [[ -d $file ]] && dest=${dest%.*} + + [[ $(readlink -f $dest) == $(realpath $file) ]] && break + info "Linking $file" + if [[ -e $dest ]]; then + warn "File $dest already exists. Moving it to ~/bak/" + mkdir -p ~/bak + mv $dest ~/bak -f + fi + ln -s $(realpath $file) "$dest" -f + done + # TODO support with or without X + fi + done +} + +while getopts "dx" opt; do + case $opt in + d) dependencies ;; + x) echo "Not Implemented yet." ;; + *) usage ;; + esac +done + +install + +# TODO pacman/zsh.hook location. + +# TODO clean up this huge chunk +info "toto" +sudo ln -s "$(realpath startdwm)" /usr/bin/startdwm -f +sudo ln -s "$(realpath dwm.desktop)" /usr/share/xsessions/dwm.desktop -f +sudo ln -s "$(realpath fonts)" /usr/local/share/fonts -f +sudo ln -s /etc/fonts/conf.avail/10-scale-bitmap-fonts.conf /etc/fonts/conf.d/ + info "DONE." diff --git a/kitty/config/kitty.conf b/kitty/config/kitty/kitty.conf similarity index 100% rename from kitty/config/kitty.conf rename to kitty/config/kitty/kitty.conf diff --git a/picom/config/picom.conf b/picom/config/picom/picom.conf similarity index 100% rename from picom/config/picom.conf rename to picom/config/picom/picom.conf diff --git a/qt5ct/install.sh b/qt5ct/install.sh index 06f0db6..679f5f2 100755 --- a/qt5ct/install.sh +++ b/qt5ct/install.sh @@ -2,6 +2,7 @@ set -e cd $(dirname $0) -ln -s $(realpath qt5ct/qt5ct.conf) ~/.config/qt5ct/qt5ct.conf -f +mkdir -p ~/.config/qt5ct +ln -s $(realpath qt5ct.conf) ~/.config/qt5ct/qt5ct.conf -f +ln -s $(realpath Material-Ocean/colors/Material-Ocean.conf) ~/.config/qt5ct/colors -f ln -s $(realpath Material-Ocean/colors/Material-Ocean.conf) ~/.config/qt5ct/colors -f -ln -s $(realpath Material-Ocean/colors/Material-Ocean.conf) ~/.config/qt5ct/colors -f \ No newline at end of file diff --git a/rofi/config/config.rasi b/rofi/config/rofi/config.rasi similarity index 100% rename from rofi/config/config.rasi rename to rofi/config/rofi/config.rasi diff --git a/rofi/config/powermenu/powermenu.rasi b/rofi/config/rofi/powermenu/powermenu.rasi similarity index 100% rename from rofi/config/powermenu/powermenu.rasi rename to rofi/config/rofi/powermenu/powermenu.rasi diff --git a/rofi/config/powermenu/powermenu.sh b/rofi/config/rofi/powermenu/powermenu.sh similarity index 100% rename from rofi/config/powermenu/powermenu.sh rename to rofi/config/rofi/powermenu/powermenu.sh diff --git a/rofi/config/theme.rasi b/rofi/config/rofi/theme.rasi similarity index 100% rename from rofi/config/theme.rasi rename to rofi/config/rofi/theme.rasi diff --git a/sxhkd/config/sxhkdrc b/sxhkd/config/sxhkd/sxhkdrc similarity index 100% rename from sxhkd/config/sxhkdrc rename to sxhkd/config/sxhkd/sxhkdrc diff --git a/wallpapers/Kujira no Kora wa Sajou ni Utau.png b/wallpapers.ln/Kujira no Kora wa Sajou ni Utau.png similarity index 100% rename from wallpapers/Kujira no Kora wa Sajou ni Utau.png rename to wallpapers.ln/Kujira no Kora wa Sajou ni Utau.png diff --git a/wallpapers/MadeInAbyss.jpg b/wallpapers.ln/MadeInAbyss.jpg similarity index 100% rename from wallpapers/MadeInAbyss.jpg rename to wallpapers.ln/MadeInAbyss.jpg diff --git a/wallpapers/Shelter.jpeg b/wallpapers.ln/Shelter.jpeg similarity index 100% rename from wallpapers/Shelter.jpeg rename to wallpapers.ln/Shelter.jpeg diff --git a/wallpapers/blue-period.jpg b/wallpapers.ln/blue-period.jpg similarity index 100% rename from wallpapers/blue-period.jpg rename to wallpapers.ln/blue-period.jpg