From 38106f68d47eb9d05e83818f8fcbd5901aba7fe4 Mon Sep 17 00:00:00 2001 From: Stephan Raabe Date: Thu, 7 Dec 2023 21:32:32 +0100 Subject: [PATCH] Add hook.sh --- .install/hook.sh | 18 +++++++++++ .install/hyprland-dotfiles.sh | 60 ++++++++++++++++++++++++++--------- .install/keyboard.sh | 1 - .install/preparation.sh | 3 ++ .install/qtile-dotfiles.sh | 60 ++++++++++++++++++++++++++--------- .install/templates/hook.sh | 3 ++ README.md | 18 +++++++++++ install.sh | 1 + 8 files changed, 133 insertions(+), 31 deletions(-) create mode 100755 .install/hook.sh create mode 100755 .install/templates/hook.sh diff --git a/.install/hook.sh b/.install/hook.sh new file mode 100755 index 0000000..e163ddc --- /dev/null +++ b/.install/hook.sh @@ -0,0 +1,18 @@ +# ------------------------------------------------------ +# Copy dotfiles +# ------------------------------------------------------ +if [ -f ~/dotfiles-versions/hook.sh ]; then +cat <<"EOF" + _ _ _ +| | | | ___ ___ | | __ +| |_| |/ _ \ / _ \| |/ / +| _ | (_) | (_) | < +|_| |_|\___/ \___/|_|\_\ + +EOF + echo "The script has detected a hook.sh script." + if gum confirm "Do you want to run the script now?"; then + source ~/dotfiles-versions/hook.sh + echo "hook.sh executed!" + fi +fi diff --git a/.install/hyprland-dotfiles.sh b/.install/hyprland-dotfiles.sh index dbfddb0..e74fd05 100644 --- a/.install/hyprland-dotfiles.sh +++ b/.install/hyprland-dotfiles.sh @@ -3,21 +3,51 @@ # ------------------------------------------------------ if [ ! $mode == "dev" ]; then - _installSymLink alacritty ~/.config/alacritty ~/dotfiles/alacritty/ ~/.config - _installSymLink vim ~/.config/vim ~/dotfiles/vim/ ~/.config - _installSymLink nvim ~/.config/nvim ~/dotfiles/nvim/ ~/.config - _installSymLink starship ~/.config/starship.toml ~/dotfiles/starship/starship.toml ~/.config/starship.toml - _installSymLink rofi ~/.config/rofi ~/dotfiles/rofi/ ~/.config - _installSymLink dunst ~/.config/dunst ~/dotfiles/dunst/ ~/.config - _installSymLink hypr ~/.config/hypr ~/dotfiles/hypr/ ~/.config - _installSymLink waybar ~/.config/waybar ~/dotfiles/waybar/ ~/.config - _installSymLink swaylock ~/.config/swaylock ~/dotfiles/swaylock/ ~/.config - _installSymLink wlogout ~/.config/wlogout ~/dotfiles/wlogout/ ~/.config - _installSymLink swappy ~/.config/swappy ~/dotfiles/swappy/ ~/.config - _installSymLink .gtkrc-2.0 ~/.gtkrc-2.0 ~/dotfiles/gtk/.gtkrc-2.0 ~/.gtkrc-2.0 - _installSymLink .Xresources ~/.Xresources ~/dotfiles/gtk/.Xresources ~/.Xresources - _installSymLink gtk-3.0 ~/.config/gtk-3.0 ~/dotfiles/gtk/gtk-3.0/ ~/.config/ - _installSymLink gtk-4.0 ~/.config/gtk-4.0 ~/dotfiles/gtk/gtk-4.0/ ~/.config/ + if [ -d ~/dotfiles-versions/$version/alacritty ]; then + _installSymLink alacritty ~/.config/alacritty ~/dotfiles/alacritty/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/vim ]; then + _installSymLink vim ~/.config/vim ~/dotfiles/vim/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/nvim ]; then + _installSymLink nvim ~/.config/nvim ~/dotfiles/nvim/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/starship ]; then + _installSymLink starship ~/.config/starship.toml ~/dotfiles/starship/starship.toml ~/.config/starship.toml + fi + if [ -d ~/dotfiles-versions/$version/rofi ]; then + _installSymLink rofi ~/.config/rofi ~/dotfiles/rofi/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/dunst ]; then + _installSymLink dunst ~/.config/dunst ~/dotfiles/dunst/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/hypr ]; then + _installSymLink hypr ~/.config/hypr ~/dotfiles/hypr/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/waybar ]; then + _installSymLink waybar ~/.config/waybar ~/dotfiles/waybar/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/swaylock ]; then + _installSymLink swaylock ~/.config/swaylock ~/dotfiles/swaylock/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/wlogout ]; then + _installSymLink wlogout ~/.config/wlogout ~/dotfiles/wlogout/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/swappy ]; then + _installSymLink swappy ~/.config/swappy ~/dotfiles/swappy/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/gtk ]; then + _installSymLink .gtkrc-2.0 ~/.gtkrc-2.0 ~/dotfiles/gtk/.gtkrc-2.0 ~/.gtkrc-2.0 + fi + if [ -d ~/dotfiles-versions/$version/gtk ]; then + _installSymLink .Xresources ~/.Xresources ~/dotfiles/gtk/.Xresources ~/.Xresources + fi + if [ -d ~/dotfiles-versions/$version/gtk ]; then + _installSymLink gtk-3.0 ~/.config/gtk-3.0 ~/dotfiles/gtk/gtk-3.0/ ~/.config/ + fi + if [ -d ~/dotfiles-versions/$version/gtk ]; then + _installSymLink gtk-4.0 ~/.config/gtk-4.0 ~/dotfiles/gtk/gtk-4.0/ ~/.config/ + fi else echo "Skipped: DEV MODE!" fi diff --git a/.install/keyboard.sh b/.install/keyboard.sh index e6cee17..25cc639 100755 --- a/.install/keyboard.sh +++ b/.install/keyboard.sh @@ -10,7 +10,6 @@ cat <<"EOF" | . \ __/ |_| | |_) | (_) | (_| | | | (_| | |_|\_\___|\__, |_.__/ \___/ \__,_|_| \__,_| |___/ - EOF echo -e "${NONE}" diff --git a/.install/preparation.sh b/.install/preparation.sh index d20378a..a697594 100644 --- a/.install/preparation.sh +++ b/.install/preparation.sh @@ -33,5 +33,8 @@ if [[ $(_isFolderEmpty ~/dotfiles-versions/$version/) == 0 ]] ;then echo "Execution of rsync -a -I --exclude-from=.install/excludes.txt . ~/dotfiles-versions/$version/ is required." exit fi +if [ ! -f ~/dotfiles-versions/hook.sh ]; then + # cp .install/templates/hook.sh ~/dotfiles-versions/ +fi echo "dotfiles $version successfully prepared in ~/dotfiles-versions/$version/" echo "" diff --git a/.install/qtile-dotfiles.sh b/.install/qtile-dotfiles.sh index bf70046..93b03d2 100644 --- a/.install/qtile-dotfiles.sh +++ b/.install/qtile-dotfiles.sh @@ -3,21 +3,51 @@ # ------------------------------------------------------ if [ ! $mode == "dev" ]; then - _installSymLink alacritty ~/.config/alacritty ~/dotfiles/alacritty/ ~/.config - _installSymLink vim ~/.config/vim ~/dotfiles/vim/ ~/.config - _installSymLink nvim ~/.config/nvim ~/dotfiles/nvim/ ~/.config - _installSymLink starship ~/.config/starship.toml ~/dotfiles/starship/starship.toml ~/.config/starship.toml - _installSymLink rofi ~/.config/rofi ~/dotfiles/rofi/ ~/.config - _installSymLink dunst ~/.config/dunst ~/dotfiles/dunst/ ~/.config - _installSymLink qtile ~/.config/qtile ~/dotfiles/qtile/ ~/.config - _installSymLink polybar ~/.config/polybar ~/dotfiles/polybar/ ~/.config - _installSymLink picom ~/.config/picom ~/dotfiles/picom/ ~/.config - _installSymLink .xinitrc ~/.xinitrc ~/dotfiles/qtile/.xinitrc ~/.xinitrc - _installSymLink swaylock ~/.config/swaylock ~/dotfiles/swaylock/ ~/.config - _installSymLink swappy ~/.config/swappy ~/dotfiles/swappy/ ~/.config - _installSymLink .gtkrc-2.0 ~/.gtkrc-2.0 ~/dotfiles/gtk/.gtkrc-2.0 ~/.gtkrc-2.0 - _installSymLink .Xresources ~/.Xresources ~/dotfiles/gtk/.Xresources ~/.Xresources - _installSymLink gtk-3.0 ~/.config/gtk-3.0 ~/dotfiles/gtk/gtk-3.0/ ~/.config/ + if [ -d ~/dotfiles-versions/$version/alacritty ]; then + _installSymLink alacritty ~/.config/alacritty ~/dotfiles/alacritty/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/vim ]; then + _installSymLink vim ~/.config/vim ~/dotfiles/vim/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/nvim ]; then + _installSymLink nvim ~/.config/nvim ~/dotfiles/nvim/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/starship ]; then + _installSymLink starship ~/.config/starship.toml ~/dotfiles/starship/starship.toml ~/.config/starship.toml + fi + if [ -d ~/dotfiles-versions/$version/rofi ]; then + _installSymLink rofi ~/.config/rofi ~/dotfiles/rofi/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/dunst ]; then + _installSymLink dunst ~/.config/dunst ~/dotfiles/dunst/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/qtile ]; then + _installSymLink qtile ~/.config/qtile ~/dotfiles/qtile/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/polybar ]; then + _installSymLink polybar ~/.config/polybar ~/dotfiles/polybar/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/picom ]; then + _installSymLink picom ~/.config/picom ~/dotfiles/picom/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/qtile ]; then + _installSymLink .xinitrc ~/.xinitrc ~/dotfiles/qtile/.xinitrc ~/.xinitrc + fi + if [ -d ~/dotfiles-versions/$version/swaylock ]; then + _installSymLink swaylock ~/.config/swaylock ~/dotfiles/swaylock/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/swappy ]; then + _installSymLink swappy ~/.config/swappy ~/dotfiles/swappy/ ~/.config + fi + if [ -d ~/dotfiles-versions/$version/gtk ]; then + _installSymLink .gtkrc-2.0 ~/.gtkrc-2.0 ~/dotfiles/gtk/.gtkrc-2.0 ~/.gtkrc-2.0 + fi + if [ -d ~/dotfiles-versions/$version/gtk ]; then + _installSymLink .Xresources ~/.Xresources ~/dotfiles/gtk/.Xresources ~/.Xresources + fi + if [ -d ~/dotfiles-versions/$version/gtk ]; then + _installSymLink gtk-3.0 ~/.config/gtk-3.0 ~/dotfiles/gtk/gtk-3.0/ ~/.config/ + fi else echo "Skipped: DEV MODE!" fi diff --git a/.install/templates/hook.sh b/.install/templates/hook.sh new file mode 100755 index 0000000..3ecfd37 --- /dev/null +++ b/.install/templates/hook.sh @@ -0,0 +1,3 @@ +#!/bin/bash +rm -rf ~/dotfiles-versions/$version/vim/ +rm -rf ~/dotfiles-versions/$version/nvim/ \ No newline at end of file diff --git a/README.md b/README.md index ede5cce..3dab424 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,24 @@ cd dotfiles-2.6 You can also use the dotfiles installer script to download and install the latest release: https://gitlab.com/stephan-raabe/installer +## Installation Hook + +The installation script will prepare the configuration files in a folder ~/dotfiles-versions/[version] before copying into the final destination in ~/dotfiles + +If you want to modify the installation files just before the copy procedure starts, you can create a file hook.sh in the folder ~/dotfiles-versions + +You can delete folders and files or update existing configurations. + +``` +#!/bin/bash +rm -rf ~/dotfiles-versions/$version/vim/ +rm -rf ~/dotfiles-versions/$version/nvim/ +``` + +This script will for example remove the vim and nvim folder before the installation. The symbolic link will not be created because the source folder doesn't exits. + +You can find a template in .install/templates/hook.sh + ## Hyprland & NVIDIA There is no official Hyprland support for Nvidia hardware. However, you might make it work properly following this page. diff --git a/install.sh b/install.sh index f437c59..b6f6241 100755 --- a/install.sh +++ b/install.sh @@ -51,6 +51,7 @@ source .install/issue.sh source .install/restore.sh source .install/vm.sh source .install/keyboard.sh +source .install/hook.sh source .install/copy.sh source .install/config-folder.sh source .install/init-pywal.sh