More portability

This commit is contained in:
Jacoby6000 2024-07-16 21:36:51 -05:00
parent bd18d5972b
commit 2ccb022c95
19 changed files with 91 additions and 191 deletions

View File

@ -6,26 +6,10 @@
## Applets : Run Applications as Root ## Applets : Run Applications as Root
# Import Current Theme # Import Current Theme
SCRIPT_INVOCATION="$0"
INPUT_THEME="$1" INPUT_THEME="$1"
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ -z "$INPUT_THEME" ]; then
source "$SCRIPT_DIR/../shared/theme.bash" 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
# Theme Elements # Theme Elements
prompt='Applications' prompt='Applications'

View File

@ -6,26 +6,10 @@
## Applets : Favorite Applications ## Applets : Favorite Applications
# Import Current Theme # Import Current Theme
SCRIPT_INVOCATION="$0"
INPUT_THEME="$1" INPUT_THEME="$1"
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ -z "$INPUT_THEME" ]; then
source "$SCRIPT_DIR/../shared/theme.bash" 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
# Theme Elements # Theme Elements
@ -41,12 +25,12 @@ elif [[ ( "$theme" == *'type-2'* ) || ( "$theme" == *'type-4'* ) ]]; then
fi fi
# CMDs (add your apps here) # CMDs (add your apps here)
term_cmd='alacritty' term_cmd="${TERMINAL_CMD:-alacritty}"
file_cmd='thunar' file_cmd="${FILE_BROWSER_CMD:-thunar}"
text_cmd='geany' text_cmd="${TEXT_EDITOR_CMD:-geany}"
web_cmd='firefox' web_cmd="${WEB_BROWSER_CMD:-firefox}"
music_cmd='alacritty -e ncmpcpp' music_cmd="${MUSIC_CMD:-alacritty -e ncmpcpp}"
setting_cmd='xfce4-settings-manager' setting_cmd="${SETTINGS_CMD:-xfce4-settings-manager}"
# Options # Options
layout=`cat ${theme} | grep 'USE_ICON' | cut -d'=' -f2` layout=`cat ${theme} | grep 'USE_ICON' | cut -d'=' -f2`

View File

@ -6,27 +6,10 @@
## Applets : Battery ## Applets : Battery
# Import Current Theme # Import Current Theme
SCRIPT_INVOCATION="$0"
INPUT_THEME="$1" INPUT_THEME="$1"
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ -z "$INPUT_THEME" ]; then
source "$SCRIPT_DIR/../shared/theme.bash" 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
# Battery Info # Battery Info
battery="`acpi -b | cut -d',' -f1 | cut -d':' -f1`" battery="`acpi -b | cut -d',' -f1 | cut -d':' -f1`"

View File

@ -6,26 +6,10 @@
## Applets : Brightness ## Applets : Brightness
# Import Current Theme # Import Current Theme
SCRIPT_INVOCATION="$0"
INPUT_THEME="$1" INPUT_THEME="$1"
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ -z "$INPUT_THEME" ]; then
source "$SCRIPT_DIR/../shared/theme.bash" 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
# Brightness Info # Brightness Info
backlight="$(printf "%.0f\n" `light -G`)" backlight="$(printf "%.0f\n" `light -G`)"

View File

@ -6,26 +6,10 @@
## Applets : MPD (music) ## Applets : MPD (music)
# Import Current Theme # Import Current Theme
SCRIPT_INVOCATION="$0"
INPUT_THEME="$1" INPUT_THEME="$1"
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ -z "$INPUT_THEME" ]; then
source "$SCRIPT_DIR/../shared/theme.bash" 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
# Theme Elements # Theme Elements

View File

@ -6,31 +6,17 @@
## Applets : Power Menu ## Applets : Power Menu
# Import Current Theme # Import Current Theme
SCRIPT_INVOCATION="$0"
INPUT_THEME="$1" INPUT_THEME="$1"
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ -z "$INPUT_THEME" ]; then
source "$SCRIPT_DIR/../shared/theme.bash" 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
# Theme Elements # Theme Elements
prompt="`hostname`" 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 if [[ ( "$theme" == *'type-1'* ) || ( "$theme" == *'type-3'* ) || ( "$theme" == *'type-5'* ) ]]; then
list_col='1' list_col='1'

View File

@ -6,26 +6,10 @@
## Applets : Quick Links ## Applets : Quick Links
# Import Current Theme # Import Current Theme
SCRIPT_INVOCATION="$0"
INPUT_THEME="$1" INPUT_THEME="$1"
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ -z "$INPUT_THEME" ]; then
source "$SCRIPT_DIR/../shared/theme.bash" 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
# Theme Elements # Theme Elements
prompt='Quick Links' prompt='Quick Links'

View File

@ -6,27 +6,10 @@
## Applets : Screenshot ## Applets : Screenshot
# Import Current Theme # Import Current Theme
SCRIPT_INVOCATION="$0"
INPUT_THEME="$1" INPUT_THEME="$1"
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ -z "$INPUT_THEME" ]; then
source "$SCRIPT_DIR/../shared/theme.bash" 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
# Theme Elements # Theme Elements
prompt='Screenshot' prompt='Screenshot'

View File

@ -6,26 +6,10 @@
## Applets : Volume ## Applets : Volume
# Import Current Theme # Import Current Theme
SCRIPT_INVOCATION="$0"
INPUT_THEME="$1" INPUT_THEME="$1"
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ -z "$INPUT_THEME" ]; then
source "$SCRIPT_DIR/../shared/theme.bash" 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
# Volume Info # Volume Info

View File

@ -15,4 +15,4 @@
/* Import color-scheme from `colors` directory */ /* Import color-scheme from `colors` directory */
@import "../../../colors/onedark.rasi" @import "../../colors/onedark.rasi"

View File

@ -1,4 +1,26 @@
## Current Theme ## Current Theme
DEFAULT_TYPE='type-1'
DEFAULT_STYLE='style-1'
type="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../type-1 echo $SCRIPT_DIR
style='style-1.rasi'
# 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

View File

@ -27,7 +27,7 @@ fi
# CMDs # CMDs
uptime="`uptime -p | sed -e 's/up //g'`" uptime=$($dir/../../shared/uptime.sh)
host=`hostname` host=`hostname`
# Options # Options

View File

@ -28,7 +28,7 @@ fi
# CMDs # CMDs
uptime="`uptime -p | sed -e 's/up //g'`" uptime=$($dir/../../shared/uptime.sh)
host=`hostname` host=`hostname`
# Options # Options

View File

@ -27,7 +27,7 @@ fi
# CMDs # CMDs
uptime="`uptime -p | sed -e 's/up //g'`" uptime=$($dir/../../shared/uptime.sh)
host=`hostname` host=`hostname`
# Options # Options

View File

@ -27,7 +27,7 @@ fi
# CMDs # CMDs
uptime="`uptime -p | sed -e 's/up //g'`" uptime=$($dir/../../shared/uptime.sh)
host=`hostname` host=`hostname`
# Options # Options

View File

@ -28,7 +28,7 @@ fi
# CMDs # CMDs
lastlogin="`last $USER | head -n1 | tr -s ' ' | cut -d' ' -f5,6,7`" 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` host=`hostname`
# Options # Options

View File

@ -28,7 +28,7 @@ fi
# CMDs # CMDs
lastlogin="`last $USER | head -n1 | tr -s ' ' | cut -d' ' -f5,6,7`" 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` host=`hostname`
# Options # Options

21
files/shared/uptime.sh Executable file
View File

@ -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;
}
}')

View File

@ -33,26 +33,27 @@ DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
# Install Fonts # Install Fonts
install_fonts() { install_fonts() {
echo -e ${BBlue}"\n[*] Installing fonts to $FONT_DIR ${Color_Off}" echo -e ${BBlue}"\n[*] Installing fonts to $FONT_DIR ${Color_Off}"
if [[ -d "$FONT_DIR" ]]; then
cp -rf $DIR/fonts/* "$FONT_DIR" if [ ! -d "$FONT_DIR" ]; then
else
mkdir -p "$FONT_DIR" mkdir -p "$FONT_DIR"
cp -rf $DIR/fonts/* "$FONT_DIR"
fi fi
cp -rf $DIR/fonts/* "$FONT_DIR"
echo -e ${BYellow}"[*] Updating font cache" ${Color_Off} echo -e ${BYellow}"[*] Updating font cache" ${Color_Off}
fc-cache fc-cache
} }
# Install Themes # Install Themes
install_themes() { install_themes() {
if [[ -d "$ROFI_DIR" ]]; then if [ -d "$ROFI_DIR" ]; then
echo -e ${BPurple}"[*] Creating a backup of your rofi configs in ${ROFI_DIR}.${USER}" ${Color_Off} echo -e ${BPurple}"[*] Creating a backup of your rofi configs in '${ROFI_DIR}.${USER}'" ${Color_Off}
mv "$ROFI_DIR" "${ROFI_DIR}.${USER}" mv "$ROFI_DIR" "${ROFI_DIR}.${USER}"
fi 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"; } { 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} echo -e ${BGreen}"[*] Successfully Installed." ${Color_Off}
exit 0 exit 0
else else
@ -63,10 +64,10 @@ install_themes() {
# Main # Main
main() { main() {
install_fonts
echo ""
install_themes install_themes
echo "" echo ""
install_fonts
echo ""
} }
main main