diff --git a/files/applets/bin/appasroot.sh b/files/applets/bin/appasroot.sh index 75a799a..7d0cad7 100755 --- a/files/applets/bin/appasroot.sh +++ b/files/applets/bin/appasroot.sh @@ -6,26 +6,10 @@ ## Applets : Run Applications as Root # Import Current Theme +SCRIPT_INVOCATION="$0" INPUT_THEME="$1" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" -if [ -z "$INPUT_THEME" ]; then - source "$SCRIPT_DIR/../shared/theme.bash" - theme="$type/$style" -elif [[ $1 == "-h" || $1 == "--help" ]]; then - echo "Usage: $0 [theme]" - exit 0 -else - theme="$INPUT_THEME" - if [ ! -d $theme ]; - # prepend current script path if theme is not found - theme="$SCRIPT_DIR/$theme" - - if [ ! -d "$theme" ]; then - # fail if we still can't find it. - echo "Theme not found!" - exit 1 - fi -fi +source "$SCRIPT_DIR/../shared/theme.bash" # Theme Elements prompt='Applications' diff --git a/files/applets/bin/apps.sh b/files/applets/bin/apps.sh index 07cb908..45fe37d 100755 --- a/files/applets/bin/apps.sh +++ b/files/applets/bin/apps.sh @@ -6,26 +6,10 @@ ## Applets : Favorite Applications # Import Current Theme +SCRIPT_INVOCATION="$0" INPUT_THEME="$1" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" -if [ -z "$INPUT_THEME" ]; then - source "$SCRIPT_DIR/../shared/theme.bash" - theme="$type/$style" -elif [[ $1 == "-h" || $1 == "--help" ]]; then - echo "Usage: $0 [theme]" - exit 0 -else - theme="$INPUT_THEME" - if [ ! -d $theme ]; - # prepend current script path if theme is not found - theme="$SCRIPT_DIR/$theme" - - if [ ! -d "$theme" ]; then - # fail if we still can't find it. - echo "Theme not found!" - exit 1 - fi -fi +source "$SCRIPT_DIR/../shared/theme.bash" # Theme Elements @@ -41,12 +25,12 @@ elif [[ ( "$theme" == *'type-2'* ) || ( "$theme" == *'type-4'* ) ]]; then fi # CMDs (add your apps here) -term_cmd='alacritty' -file_cmd='thunar' -text_cmd='geany' -web_cmd='firefox' -music_cmd='alacritty -e ncmpcpp' -setting_cmd='xfce4-settings-manager' +term_cmd="${TERMINAL_CMD:-alacritty}" +file_cmd="${FILE_BROWSER_CMD:-thunar}" +text_cmd="${TEXT_EDITOR_CMD:-geany}" +web_cmd="${WEB_BROWSER_CMD:-firefox}" +music_cmd="${MUSIC_CMD:-alacritty -e ncmpcpp}" +setting_cmd="${SETTINGS_CMD:-xfce4-settings-manager}" # Options layout=`cat ${theme} | grep 'USE_ICON' | cut -d'=' -f2` diff --git a/files/applets/bin/battery.sh b/files/applets/bin/battery.sh index d7fdd7c..139eec3 100755 --- a/files/applets/bin/battery.sh +++ b/files/applets/bin/battery.sh @@ -6,27 +6,10 @@ ## Applets : Battery # Import Current Theme +SCRIPT_INVOCATION="$0" INPUT_THEME="$1" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" -if [ -z "$INPUT_THEME" ]; then - source "$SCRIPT_DIR/../shared/theme.bash" - theme="$type/$style" -elif [[ $1 == "-h" || $1 == "--help" ]]; then - echo "Usage: $0 [theme]" - exit 0 -else - theme="$INPUT_THEME" - if [ ! -d $theme ]; - # prepend current script path if theme is not found - theme="$SCRIPT_DIR/$theme" - - if [ ! -d "$theme" ]; then - # fail if we still can't find it. - echo "Theme not found!" - exit 1 - fi -fi - +source "$SCRIPT_DIR/../shared/theme.bash" # Battery Info battery="`acpi -b | cut -d',' -f1 | cut -d':' -f1`" diff --git a/files/applets/bin/brightness.sh b/files/applets/bin/brightness.sh index 5fe23d1..7a0f820 100755 --- a/files/applets/bin/brightness.sh +++ b/files/applets/bin/brightness.sh @@ -6,26 +6,10 @@ ## Applets : Brightness # Import Current Theme +SCRIPT_INVOCATION="$0" INPUT_THEME="$1" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" -if [ -z "$INPUT_THEME" ]; then - source "$SCRIPT_DIR/../shared/theme.bash" - theme="$type/$style" -elif [[ $1 == "-h" || $1 == "--help" ]]; then - echo "Usage: $0 [theme]" - exit 0 -else - theme="$INPUT_THEME" - if [ ! -d $theme ]; - # prepend current script path if theme is not found - theme="$SCRIPT_DIR/$theme" - - if [ ! -d "$theme" ]; then - # fail if we still can't find it. - echo "Theme not found!" - exit 1 - fi -fi +source "$SCRIPT_DIR/../shared/theme.bash" # Brightness Info backlight="$(printf "%.0f\n" `light -G`)" diff --git a/files/applets/bin/mpd.sh b/files/applets/bin/mpd.sh index af61fce..4c6db44 100755 --- a/files/applets/bin/mpd.sh +++ b/files/applets/bin/mpd.sh @@ -6,26 +6,10 @@ ## Applets : MPD (music) # Import Current Theme +SCRIPT_INVOCATION="$0" INPUT_THEME="$1" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" -if [ -z "$INPUT_THEME" ]; then - source "$SCRIPT_DIR/../shared/theme.bash" - theme="$type/$style" -elif [[ $1 == "-h" || $1 == "--help" ]]; then - echo "Usage: $0 [theme]" - exit 0 -else - theme="$INPUT_THEME" - if [ ! -d $theme ]; - # prepend current script path if theme is not found - theme="$SCRIPT_DIR/$theme" - - if [ ! -d "$theme" ]; then - # fail if we still can't find it. - echo "Theme not found!" - exit 1 - fi -fi +source "$SCRIPT_DIR/../shared/theme.bash" # Theme Elements diff --git a/files/applets/bin/powermenu.sh b/files/applets/bin/powermenu.sh index 5b97fa7..6646908 100755 --- a/files/applets/bin/powermenu.sh +++ b/files/applets/bin/powermenu.sh @@ -6,31 +6,17 @@ ## Applets : Power Menu # Import Current Theme +SCRIPT_INVOCATION="$0" INPUT_THEME="$1" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" -if [ -z "$INPUT_THEME" ]; then - source "$SCRIPT_DIR/../shared/theme.bash" - theme="$type/$style" -elif [[ $1 == "-h" || $1 == "--help" ]]; then - echo "Usage: $0 [theme]" - exit 0 -else - theme="$INPUT_THEME" - if [ ! -d $theme ]; - # prepend current script path if theme is not found - theme="$SCRIPT_DIR/$theme" - - if [ ! -d "$theme" ]; then - # fail if we still can't find it. - echo "Theme not found!" - exit 1 - fi -fi - +source "$SCRIPT_DIR/../shared/theme.bash" # Theme Elements prompt="`hostname`" -mesg="Uptime : `uptime -p | sed -e 's/up //g'`" + +uptime=$($SCRIPT_DIR/../../shared/uptime.sh) + +mesg="Uptime : $uptime" if [[ ( "$theme" == *'type-1'* ) || ( "$theme" == *'type-3'* ) || ( "$theme" == *'type-5'* ) ]]; then list_col='1' diff --git a/files/applets/bin/quicklinks.sh b/files/applets/bin/quicklinks.sh index d469ca8..9780b0e 100755 --- a/files/applets/bin/quicklinks.sh +++ b/files/applets/bin/quicklinks.sh @@ -6,26 +6,10 @@ ## Applets : Quick Links # Import Current Theme +SCRIPT_INVOCATION="$0" INPUT_THEME="$1" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" -if [ -z "$INPUT_THEME" ]; then - source "$SCRIPT_DIR/../shared/theme.bash" - theme="$type/$style" -elif [[ $1 == "-h" || $1 == "--help" ]]; then - echo "Usage: $0 [theme]" - exit 0 -else - theme="$INPUT_THEME" - if [ ! -d $theme ]; - # prepend current script path if theme is not found - theme="$SCRIPT_DIR/$theme" - - if [ ! -d "$theme" ]; then - # fail if we still can't find it. - echo "Theme not found!" - exit 1 - fi -fi +source "$SCRIPT_DIR/../shared/theme.bash" # Theme Elements prompt='Quick Links' diff --git a/files/applets/bin/screenshot.sh b/files/applets/bin/screenshot.sh index fd081bd..fd9325c 100755 --- a/files/applets/bin/screenshot.sh +++ b/files/applets/bin/screenshot.sh @@ -6,27 +6,10 @@ ## Applets : Screenshot # Import Current Theme +SCRIPT_INVOCATION="$0" INPUT_THEME="$1" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" -if [ -z "$INPUT_THEME" ]; then - source "$SCRIPT_DIR/../shared/theme.bash" - theme="$type/$style" -elif [[ $1 == "-h" || $1 == "--help" ]]; then - echo "Usage: $0 [theme]" - exit 0 -else - theme="$INPUT_THEME" - if [ ! -d $theme ]; - # prepend current script path if theme is not found - theme="$SCRIPT_DIR/$theme" - - if [ ! -d "$theme" ]; then - # fail if we still can't find it. - echo "Theme not found!" - exit 1 - fi -fi - +source "$SCRIPT_DIR/../shared/theme.bash" # Theme Elements prompt='Screenshot' diff --git a/files/applets/bin/volume.sh b/files/applets/bin/volume.sh index 9b5ccb4..830871d 100755 --- a/files/applets/bin/volume.sh +++ b/files/applets/bin/volume.sh @@ -6,26 +6,10 @@ ## Applets : Volume # Import Current Theme +SCRIPT_INVOCATION="$0" INPUT_THEME="$1" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" -if [ -z "$INPUT_THEME" ]; then - source "$SCRIPT_DIR/../shared/theme.bash" - theme="$type/$style" -elif [[ $1 == "-h" || $1 == "--help" ]]; then - echo "Usage: $0 [theme]" - exit 0 -else - theme="$INPUT_THEME" - if [ ! -d $theme ]; - # prepend current script path if theme is not found - theme="$SCRIPT_DIR/$theme" - - if [ ! -d "$theme" ]; then - # fail if we still can't find it. - echo "Theme not found!" - exit 1 - fi -fi +source "$SCRIPT_DIR/../shared/theme.bash" # Volume Info diff --git a/files/applets/shared/colors.rasi b/files/applets/shared/colors.rasi index 66a0a2e..b208bcd 100644 --- a/files/applets/shared/colors.rasi +++ b/files/applets/shared/colors.rasi @@ -15,4 +15,4 @@ /* Import color-scheme from `colors` directory */ -@import "../../../colors/onedark.rasi" +@import "../../colors/onedark.rasi" diff --git a/files/applets/shared/theme.bash b/files/applets/shared/theme.bash index 0697a72..46fe5a8 100755 --- a/files/applets/shared/theme.bash +++ b/files/applets/shared/theme.bash @@ -1,4 +1,26 @@ ## Current Theme +DEFAULT_TYPE='type-1' +DEFAULT_STYLE='style-1' -type="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../type-1 -style='style-1.rasi' +echo $SCRIPT_DIR + +# INPUT_THEME should be set by the script that sources this file, +# if the user wants to override the default theme. +if [ -z "$INPUT_THEME" ]; then + theme="$SCRIPT_DIR/../$DEFAULT_TYPE/$DEFAULT_STYLE.rasi" +elif [[ $1 == "-h" || $1 == "--help" ]]; then + echo "Usage: $SCRIPT_INVOCATION [theme]" + exit 0 +else + theme="$INPUT_THEME" + if [ ! -d $theme ]; then + # prepend current script path if theme is not found + theme="$SCRIPT_DIR/../$theme" + + if [ ! -d "$theme" ]; then + # fail if we still can't find it. + echo "Theme not found!" + exit 1 + fi + fi +fi diff --git a/files/powermenu/type-1/powermenu.sh b/files/powermenu/type-1/powermenu.sh index 73a6946..e62eca7 100755 --- a/files/powermenu/type-1/powermenu.sh +++ b/files/powermenu/type-1/powermenu.sh @@ -27,7 +27,7 @@ fi # CMDs -uptime="`uptime -p | sed -e 's/up //g'`" +uptime=$($dir/../../shared/uptime.sh) host=`hostname` # Options diff --git a/files/powermenu/type-2/powermenu.sh b/files/powermenu/type-2/powermenu.sh index c984006..e9d29b9 100755 --- a/files/powermenu/type-2/powermenu.sh +++ b/files/powermenu/type-2/powermenu.sh @@ -28,7 +28,7 @@ fi # CMDs -uptime="`uptime -p | sed -e 's/up //g'`" +uptime=$($dir/../../shared/uptime.sh) host=`hostname` # Options diff --git a/files/powermenu/type-3/powermenu.sh b/files/powermenu/type-3/powermenu.sh index a6a7ac3..b743492 100755 --- a/files/powermenu/type-3/powermenu.sh +++ b/files/powermenu/type-3/powermenu.sh @@ -27,7 +27,7 @@ fi # CMDs -uptime="`uptime -p | sed -e 's/up //g'`" +uptime=$($dir/../../shared/uptime.sh) host=`hostname` # Options diff --git a/files/powermenu/type-4/powermenu.sh b/files/powermenu/type-4/powermenu.sh index 6cd8ee5..96ca18d 100755 --- a/files/powermenu/type-4/powermenu.sh +++ b/files/powermenu/type-4/powermenu.sh @@ -27,7 +27,7 @@ fi # CMDs -uptime="`uptime -p | sed -e 's/up //g'`" +uptime=$($dir/../../shared/uptime.sh) host=`hostname` # Options diff --git a/files/powermenu/type-5/powermenu.sh b/files/powermenu/type-5/powermenu.sh index ee855ac..169dcd4 100755 --- a/files/powermenu/type-5/powermenu.sh +++ b/files/powermenu/type-5/powermenu.sh @@ -28,7 +28,7 @@ fi # CMDs lastlogin="`last $USER | head -n1 | tr -s ' ' | cut -d' ' -f5,6,7`" -uptime="`uptime -p | sed -e 's/up //g'`" +uptime=$($dir/../../shared/uptime.sh) host=`hostname` # Options diff --git a/files/powermenu/type-6/powermenu.sh b/files/powermenu/type-6/powermenu.sh index 3af3744..374c5a8 100755 --- a/files/powermenu/type-6/powermenu.sh +++ b/files/powermenu/type-6/powermenu.sh @@ -28,7 +28,7 @@ fi # CMDs lastlogin="`last $USER | head -n1 | tr -s ' ' | cut -d' ' -f5,6,7`" -uptime="`uptime -p | sed -e 's/up //g'`" +uptime=$($dir/../../shared/uptime.sh) host=`hostname` # Options diff --git a/files/shared/uptime.sh b/files/shared/uptime.sh new file mode 100755 index 0000000..884d79c --- /dev/null +++ b/files/shared/uptime.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +uptime_seconds=$(awk '{print $1}' /proc/uptime) +echo -n $(awk -v UP="$uptime_seconds" ' +BEGIN { + days = int(UP / 86400); + hours = int((UP % 86400) / 3600); + minutes = int((UP % 3600) / 60); + seconds = int(UP % 60); + if (days > 0) { + if (days == 1) { + printf "1 day, %d hours, %d minutes\n", hours, minutes; + } else { + printf "%d days, %d hours, %d minutes\n", days, hours, minutes; + } + } else if (hours > 0) { + printf "%d hours, %d minutes\n", hours, minutes; + } else { + printf "%d minutes\n", minutes; + } +}') diff --git a/setup.sh b/setup.sh index 6c244a4..3413abf 100755 --- a/setup.sh +++ b/setup.sh @@ -33,26 +33,27 @@ DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" # Install Fonts install_fonts() { echo -e ${BBlue}"\n[*] Installing fonts to $FONT_DIR ${Color_Off}" - if [[ -d "$FONT_DIR" ]]; then - cp -rf $DIR/fonts/* "$FONT_DIR" - else + + if [ ! -d "$FONT_DIR" ]; then mkdir -p "$FONT_DIR" - cp -rf $DIR/fonts/* "$FONT_DIR" fi + + cp -rf $DIR/fonts/* "$FONT_DIR" + 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 in ${ROFI_DIR}.${USER}" ${Color_Off} + if [ -d "$ROFI_DIR" ]; then + 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 in $ROFI_DIR" ${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 + if [ -f "$ROFI_DIR/config.rasi" ]; then echo -e ${BGreen}"[*] Successfully Installed." ${Color_Off} exit 0 else @@ -63,10 +64,10 @@ install_themes() { # Main main() { - install_fonts - echo "" install_themes echo "" + install_fonts + echo "" } main