From 9060e5c6e13c7af5c74d5db959673ea46ddee921 Mon Sep 17 00:00:00 2001 From: Jacoby6000 Date: Tue, 16 Jul 2024 18:28:49 -0500 Subject: [PATCH] Use relative paths and readlink for portability --- files/applets/bin/appasroot.sh | 2 +- files/applets/bin/apps.sh | 2 +- files/applets/bin/battery.sh | 2 +- files/applets/bin/brightness.sh | 2 +- files/applets/bin/mpd.sh | 2 +- files/applets/bin/powermenu.sh | 2 +- files/applets/bin/quicklinks.sh | 2 +- files/applets/bin/screenshot.sh | 2 +- files/applets/bin/volume.sh | 2 +- files/applets/shared/colors.rasi | 2 +- files/applets/shared/theme.bash | 2 +- files/launchers/type-1/launcher.sh | 2 +- files/launchers/type-1/shared/colors.rasi | 2 +- files/launchers/type-2/launcher.sh | 2 +- files/launchers/type-2/shared/colors.rasi | 2 +- files/launchers/type-3/launcher.sh | 2 +- files/launchers/type-3/shared/colors.rasi | 2 +- files/launchers/type-4/launcher.sh | 2 +- files/launchers/type-4/shared/colors.rasi | 2 +- files/launchers/type-5/launcher.sh | 2 +- files/launchers/type-6/launcher.sh | 2 +- files/launchers/type-7/launcher.sh | 2 +- files/powermenu/type-1/powermenu.sh | 2 +- files/powermenu/type-1/shared/colors.rasi | 2 +- files/powermenu/type-2/powermenu.sh | 2 +- files/powermenu/type-2/shared/colors.rasi | 2 +- files/powermenu/type-3/powermenu.sh | 2 +- files/powermenu/type-3/shared/colors.rasi | 2 +- files/powermenu/type-4/powermenu.sh | 2 +- files/powermenu/type-4/shared/colors.rasi | 2 +- files/powermenu/type-5/powermenu.sh | 2 +- files/powermenu/type-6/powermenu.sh | 2 +- setup.sh | 35 +++++++++++++++++------ 33 files changed, 58 insertions(+), 41 deletions(-) diff --git a/files/applets/bin/appasroot.sh b/files/applets/bin/appasroot.sh index f0e6944..41bd193 100755 --- a/files/applets/bin/appasroot.sh +++ b/files/applets/bin/appasroot.sh @@ -6,7 +6,7 @@ ## Applets : Run Applications as Root # Import Current Theme -source "$HOME"/.config/rofi/applets/shared/theme.bash +source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash theme="$type/$style" # Theme Elements diff --git a/files/applets/bin/apps.sh b/files/applets/bin/apps.sh index 01d1e4d..efb3e92 100755 --- a/files/applets/bin/apps.sh +++ b/files/applets/bin/apps.sh @@ -6,7 +6,7 @@ ## Applets : Favorite Applications # Import Current Theme -source "$HOME"/.config/rofi/applets/shared/theme.bash +source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash theme="$type/$style" # Theme Elements diff --git a/files/applets/bin/battery.sh b/files/applets/bin/battery.sh index ef0dba6..50555db 100755 --- a/files/applets/bin/battery.sh +++ b/files/applets/bin/battery.sh @@ -6,7 +6,7 @@ ## Applets : Battery # Import Current Theme -source "$HOME"/.config/rofi/applets/shared/theme.bash +source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash theme="$type/$style" # Battery Info diff --git a/files/applets/bin/brightness.sh b/files/applets/bin/brightness.sh index 2c90a12..b5bc571 100755 --- a/files/applets/bin/brightness.sh +++ b/files/applets/bin/brightness.sh @@ -6,7 +6,7 @@ ## Applets : Brightness # Import Current Theme -source "$HOME"/.config/rofi/applets/shared/theme.bash +source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash theme="$type/$style" # Brightness Info diff --git a/files/applets/bin/mpd.sh b/files/applets/bin/mpd.sh index ce6a9e9..f53da26 100755 --- a/files/applets/bin/mpd.sh +++ b/files/applets/bin/mpd.sh @@ -6,7 +6,7 @@ ## Applets : MPD (music) # Import Current Theme -source "$HOME"/.config/rofi/applets/shared/theme.bash +source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash theme="$type/$style" # Theme Elements diff --git a/files/applets/bin/powermenu.sh b/files/applets/bin/powermenu.sh index 8ed9106..ce11289 100755 --- a/files/applets/bin/powermenu.sh +++ b/files/applets/bin/powermenu.sh @@ -6,7 +6,7 @@ ## Applets : Power Menu # Import Current Theme -source "$HOME"/.config/rofi/applets/shared/theme.bash +source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash theme="$type/$style" # Theme Elements diff --git a/files/applets/bin/quicklinks.sh b/files/applets/bin/quicklinks.sh index 11a38a8..0cf4881 100755 --- a/files/applets/bin/quicklinks.sh +++ b/files/applets/bin/quicklinks.sh @@ -6,7 +6,7 @@ ## Applets : Quick Links # Import Current Theme -source "$HOME"/.config/rofi/applets/shared/theme.bash +source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash theme="$type/$style" # Theme Elements diff --git a/files/applets/bin/screenshot.sh b/files/applets/bin/screenshot.sh index 5e5286b..d7a6879 100755 --- a/files/applets/bin/screenshot.sh +++ b/files/applets/bin/screenshot.sh @@ -6,7 +6,7 @@ ## Applets : Screenshot # Import Current Theme -source "$HOME"/.config/rofi/applets/shared/theme.bash +source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash theme="$type/$style" # Theme Elements diff --git a/files/applets/bin/volume.sh b/files/applets/bin/volume.sh index a194592..1110aa8 100755 --- a/files/applets/bin/volume.sh +++ b/files/applets/bin/volume.sh @@ -6,7 +6,7 @@ ## Applets : Volume # Import Current Theme -source "$HOME"/.config/rofi/applets/shared/theme.bash +source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash theme="$type/$style" # Volume Info diff --git a/files/applets/shared/colors.rasi b/files/applets/shared/colors.rasi index 103ad63..66a0a2e 100644 --- a/files/applets/shared/colors.rasi +++ b/files/applets/shared/colors.rasi @@ -15,4 +15,4 @@ /* Import color-scheme from `colors` directory */ -@import "~/.config/rofi/colors/onedark.rasi" +@import "../../../colors/onedark.rasi" diff --git a/files/applets/shared/theme.bash b/files/applets/shared/theme.bash index 4807020..0697a72 100755 --- a/files/applets/shared/theme.bash +++ b/files/applets/shared/theme.bash @@ -1,4 +1,4 @@ ## Current Theme -type="$HOME/.config/rofi/applets/type-1" +type="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../type-1 style='style-1.rasi' diff --git a/files/launchers/type-1/launcher.sh b/files/launchers/type-1/launcher.sh index 85b7df4..e39e904 100755 --- a/files/launchers/type-1/launcher.sh +++ b/files/launchers/type-1/launcher.sh @@ -11,7 +11,7 @@ ## style-6 style-7 style-8 style-9 style-10 ## style-11 style-12 style-13 style-14 style-15 -dir="$HOME/.config/rofi/launchers/type-1" +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" theme='style-1' ## Run diff --git a/files/launchers/type-1/shared/colors.rasi b/files/launchers/type-1/shared/colors.rasi index 103ad63..66a0a2e 100644 --- a/files/launchers/type-1/shared/colors.rasi +++ b/files/launchers/type-1/shared/colors.rasi @@ -15,4 +15,4 @@ /* Import color-scheme from `colors` directory */ -@import "~/.config/rofi/colors/onedark.rasi" +@import "../../../colors/onedark.rasi" diff --git a/files/launchers/type-2/launcher.sh b/files/launchers/type-2/launcher.sh index 3422cd7..e39e904 100755 --- a/files/launchers/type-2/launcher.sh +++ b/files/launchers/type-2/launcher.sh @@ -11,7 +11,7 @@ ## style-6 style-7 style-8 style-9 style-10 ## style-11 style-12 style-13 style-14 style-15 -dir="$HOME/.config/rofi/launchers/type-2" +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" theme='style-1' ## Run diff --git a/files/launchers/type-2/shared/colors.rasi b/files/launchers/type-2/shared/colors.rasi index 103ad63..66a0a2e 100644 --- a/files/launchers/type-2/shared/colors.rasi +++ b/files/launchers/type-2/shared/colors.rasi @@ -15,4 +15,4 @@ /* Import color-scheme from `colors` directory */ -@import "~/.config/rofi/colors/onedark.rasi" +@import "../../../colors/onedark.rasi" diff --git a/files/launchers/type-3/launcher.sh b/files/launchers/type-3/launcher.sh index ae97b5f..1d6e6ec 100755 --- a/files/launchers/type-3/launcher.sh +++ b/files/launchers/type-3/launcher.sh @@ -10,7 +10,7 @@ ## style-1 style-2 style-3 style-4 style-5 ## style-6 style-7 style-8 style-9 style-10 -dir="$HOME/.config/rofi/launchers/type-3" +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" theme='style-10' ## Run diff --git a/files/launchers/type-3/shared/colors.rasi b/files/launchers/type-3/shared/colors.rasi index 103ad63..66a0a2e 100644 --- a/files/launchers/type-3/shared/colors.rasi +++ b/files/launchers/type-3/shared/colors.rasi @@ -15,4 +15,4 @@ /* Import color-scheme from `colors` directory */ -@import "~/.config/rofi/colors/onedark.rasi" +@import "../../../colors/onedark.rasi" diff --git a/files/launchers/type-4/launcher.sh b/files/launchers/type-4/launcher.sh index 6572cda..fba55bc 100755 --- a/files/launchers/type-4/launcher.sh +++ b/files/launchers/type-4/launcher.sh @@ -10,7 +10,7 @@ ## style-1 style-2 style-3 style-4 style-5 ## style-6 style-7 style-8 style-9 style-10 -dir="$HOME/.config/rofi/launchers/type-4" +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" theme='style-1' ## Run diff --git a/files/launchers/type-4/shared/colors.rasi b/files/launchers/type-4/shared/colors.rasi index 103ad63..66a0a2e 100644 --- a/files/launchers/type-4/shared/colors.rasi +++ b/files/launchers/type-4/shared/colors.rasi @@ -15,4 +15,4 @@ /* Import color-scheme from `colors` directory */ -@import "~/.config/rofi/colors/onedark.rasi" +@import "../../../colors/onedark.rasi" diff --git a/files/launchers/type-5/launcher.sh b/files/launchers/type-5/launcher.sh index e9d0a3a..a1cfb8c 100755 --- a/files/launchers/type-5/launcher.sh +++ b/files/launchers/type-5/launcher.sh @@ -9,7 +9,7 @@ # ## style-1 style-2 style-3 style-4 style-5 -dir="$HOME/.config/rofi/launchers/type-5" +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" theme='style-1' ## Run diff --git a/files/launchers/type-6/launcher.sh b/files/launchers/type-6/launcher.sh index c0b4d33..fba55bc 100755 --- a/files/launchers/type-6/launcher.sh +++ b/files/launchers/type-6/launcher.sh @@ -10,7 +10,7 @@ ## style-1 style-2 style-3 style-4 style-5 ## style-6 style-7 style-8 style-9 style-10 -dir="$HOME/.config/rofi/launchers/type-6" +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" theme='style-1' ## Run diff --git a/files/launchers/type-7/launcher.sh b/files/launchers/type-7/launcher.sh index aa45aa9..fba55bc 100755 --- a/files/launchers/type-7/launcher.sh +++ b/files/launchers/type-7/launcher.sh @@ -10,7 +10,7 @@ ## style-1 style-2 style-3 style-4 style-5 ## style-6 style-7 style-8 style-9 style-10 -dir="$HOME/.config/rofi/launchers/type-7" +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" theme='style-1' ## Run diff --git a/files/powermenu/type-1/powermenu.sh b/files/powermenu/type-1/powermenu.sh index dd978af..facf578 100755 --- a/files/powermenu/type-1/powermenu.sh +++ b/files/powermenu/type-1/powermenu.sh @@ -10,7 +10,7 @@ ## style-1 style-2 style-3 style-4 style-5 # Current Theme -dir="$HOME/.config/rofi/powermenu/type-1" +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" theme='style-1' # CMDs diff --git a/files/powermenu/type-1/shared/colors.rasi b/files/powermenu/type-1/shared/colors.rasi index 103ad63..66a0a2e 100644 --- a/files/powermenu/type-1/shared/colors.rasi +++ b/files/powermenu/type-1/shared/colors.rasi @@ -15,4 +15,4 @@ /* Import color-scheme from `colors` directory */ -@import "~/.config/rofi/colors/onedark.rasi" +@import "../../../colors/onedark.rasi" diff --git a/files/powermenu/type-2/powermenu.sh b/files/powermenu/type-2/powermenu.sh index 23d0795..0b60b25 100755 --- a/files/powermenu/type-2/powermenu.sh +++ b/files/powermenu/type-2/powermenu.sh @@ -11,7 +11,7 @@ ## style-6 style-7 style-8 style-9 style-10 # Current Theme -dir="$HOME/.config/rofi/powermenu/type-2" +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" theme='style-1' # CMDs diff --git a/files/powermenu/type-2/shared/colors.rasi b/files/powermenu/type-2/shared/colors.rasi index 103ad63..66a0a2e 100644 --- a/files/powermenu/type-2/shared/colors.rasi +++ b/files/powermenu/type-2/shared/colors.rasi @@ -15,4 +15,4 @@ /* Import color-scheme from `colors` directory */ -@import "~/.config/rofi/colors/onedark.rasi" +@import "../../../colors/onedark.rasi" diff --git a/files/powermenu/type-3/powermenu.sh b/files/powermenu/type-3/powermenu.sh index 8c1e47f..ab4f91c 100755 --- a/files/powermenu/type-3/powermenu.sh +++ b/files/powermenu/type-3/powermenu.sh @@ -10,7 +10,7 @@ ## style-1 style-2 style-3 style-4 style-5 # Current Theme -dir="$HOME/.config/rofi/powermenu/type-3" +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" theme='style-1' # CMDs diff --git a/files/powermenu/type-3/shared/colors.rasi b/files/powermenu/type-3/shared/colors.rasi index 103ad63..66a0a2e 100644 --- a/files/powermenu/type-3/shared/colors.rasi +++ b/files/powermenu/type-3/shared/colors.rasi @@ -15,4 +15,4 @@ /* Import color-scheme from `colors` directory */ -@import "~/.config/rofi/colors/onedark.rasi" +@import "../../../colors/onedark.rasi" diff --git a/files/powermenu/type-4/powermenu.sh b/files/powermenu/type-4/powermenu.sh index 17f20c7..18a815f 100755 --- a/files/powermenu/type-4/powermenu.sh +++ b/files/powermenu/type-4/powermenu.sh @@ -10,7 +10,7 @@ ## style-1 style-2 style-3 style-4 style-5 # Current Theme -dir="$HOME/.config/rofi/powermenu/type-4" +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" theme='style-5' # CMDs diff --git a/files/powermenu/type-4/shared/colors.rasi b/files/powermenu/type-4/shared/colors.rasi index 103ad63..66a0a2e 100644 --- a/files/powermenu/type-4/shared/colors.rasi +++ b/files/powermenu/type-4/shared/colors.rasi @@ -15,4 +15,4 @@ /* Import color-scheme from `colors` directory */ -@import "~/.config/rofi/colors/onedark.rasi" +@import "../../../colors/onedark.rasi" diff --git a/files/powermenu/type-5/powermenu.sh b/files/powermenu/type-5/powermenu.sh index 561e30c..66443aa 100755 --- a/files/powermenu/type-5/powermenu.sh +++ b/files/powermenu/type-5/powermenu.sh @@ -10,7 +10,7 @@ ## style-1 style-2 style-3 style-4 style-5 # Current Theme -dir="$HOME/.config/rofi/powermenu/type-5" +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" theme='style-1' # CMDs diff --git a/files/powermenu/type-6/powermenu.sh b/files/powermenu/type-6/powermenu.sh index ad93faf..afa8e7f 100755 --- a/files/powermenu/type-6/powermenu.sh +++ b/files/powermenu/type-6/powermenu.sh @@ -10,7 +10,7 @@ ## style-1 style-2 style-3 style-4 style-5 # Current Theme -dir="$HOME/.config/rofi/powermenu/type-6" +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" theme='style-1' # CMDs diff --git a/setup.sh b/setup.sh index 52d365c..6c244a4 100755 --- a/setup.sh +++ b/setup.sh @@ -10,38 +10,53 @@ Color_Off='\033[0m' BBlack='\033[1;30m' BRed='\033[1;31m' BGreen='\033[1;32m' BYellow='\033[1;33m' BBlue='\033[1;34m' BPurple='\033[1;35m' BCyan='\033[1;36m' BWhite='\033[1;37m' + ## Directories ---------------------------- -DIR=`pwd` -FONT_DIR="$HOME/.local/share/fonts" -ROFI_DIR="$HOME/.config/rofi" +ROFI_INSTALL_DIR=$1 +FONT_INSTALL_DIR=$2 + +if [ -z "$ROFI_INSTALL_DIR" ]; then + ROFI_INSTALL_DIR="$HOME/.config/rofi" + FONT_DIR="$HOME/.local/share/fonts" + ROFI_DIR="$HOME/.config/rofi" +else + if [ -z "$FONT_INSTALL_DIR" ]; then + FONT_DIR="$ROFI_INSTALL_DIR/fonts" + else + FONT_DIR="$FONT_INSTALL_DIR" + fi + ROFI_DIR="$ROFI_INSTALL_DIR" +fi + +DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" # Install Fonts install_fonts() { - echo -e ${BBlue}"\n[*] Installing fonts..." ${Color_Off} + echo -e ${BBlue}"\n[*] Installing fonts to $FONT_DIR ${Color_Off}" if [[ -d "$FONT_DIR" ]]; then cp -rf $DIR/fonts/* "$FONT_DIR" else mkdir -p "$FONT_DIR" cp -rf $DIR/fonts/* "$FONT_DIR" fi - echo -e ${BYellow}"[*] Updating font cache...\n" ${Color_Off} + echo -e ${BYellow}"[*] Updating font cache" ${Color_Off} fc-cache } # Install Themes install_themes() { if [[ -d "$ROFI_DIR" ]]; then - echo -e ${BPurple}"[*] Creating a backup of your rofi configs..." ${Color_Off} + echo -e ${BPurple}"[*] Creating a backup of your rofi configs in ${ROFI_DIR}.${USER}" ${Color_Off} mv "$ROFI_DIR" "${ROFI_DIR}.${USER}" fi - echo -e ${BBlue}"[*] Installing rofi configs..." ${Color_Off} + echo -e ${BBlue}"[*] Installing rofi configs in $ROFI_DIR" ${Color_Off} { mkdir -p "$ROFI_DIR"; cp -rf $DIR/files/* "$ROFI_DIR"; } if [[ -f "$ROFI_DIR/config.rasi" ]]; then - echo -e ${BGreen}"[*] Successfully Installed.\n" ${Color_Off} + echo -e ${BGreen}"[*] Successfully Installed." ${Color_Off} exit 0 else - echo -e ${BRed}"[!] Failed to install.\n" ${Color_Off} + echo -e ${BRed}"[!] Failed to install." ${Color_Off} exit 1 fi } @@ -49,7 +64,9 @@ install_themes() { # Main main() { install_fonts + echo "" install_themes + echo "" } main