mirror of
https://github.com/G2-Games/welcome.sh.git
synced 2025-04-19 21:42:53 -05:00
Added random greetings and 12/24 hour clock toggle
This commit is contained in:
parent
a8f761e309
commit
bb426a101c
2 changed files with 79 additions and 75 deletions
17
README.md
17
README.md
|
@ -49,18 +49,21 @@ To configure settings, open `welcome.sh` in your text editor of choice and go to
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
#=========SETUP========#
|
#=========SETUP========#
|
||||||
# Select which parts you want active by commenting them out #
|
# Select which parts you want active by #
|
||||||
# For example, on a desktop, disabling the battery message #
|
# commenting them out. For example, on a #
|
||||||
# is a good idea. You can also re order them to change how #
|
# desktop, disabling the battery message #
|
||||||
# they display! #
|
# is a good idea. You can also re-order #
|
||||||
|
# them to change how they display! #
|
||||||
|
|
||||||
flatpakupd="off" # Check for flatpak updates, this slows startup down A LOT
|
randgreeting="off" #< Turn the random greetings on (eg. "Hello <user>, Hi <user>")
|
||||||
rechargenotif="off" # Notify that you should recharge if below 15%
|
twelvehour="on" #< Switch between 12 and 24 hour time (eg. 8:00pm vs 20:00)
|
||||||
|
rechargenotif="off" #< Notify that you should recharge if below 15%
|
||||||
|
flatpakupd="off" #< Check for flatpak updates, this slows startup down A LOT
|
||||||
|
|
||||||
welcome
|
welcome
|
||||||
greeting
|
greeting
|
||||||
clock
|
clock
|
||||||
#battery
|
battery
|
||||||
updates #< This makes startup slower
|
updates #< This makes startup slower
|
||||||
echo # Properly line break at the end
|
echo # Properly line break at the end
|
||||||
```
|
```
|
||||||
|
|
137
welcome.sh
137
welcome.sh
|
@ -1,34 +1,29 @@
|
||||||
# For random colors; this will only generate colors with sufficient luma to be readable on a dark background... you may have to modify it for light
|
|
||||||
randcolor() {
|
|
||||||
cluma=0
|
|
||||||
while [[ $(printf %.0f $cluma) -le 100 ]] && [[ $loops -le 10 ]];
|
|
||||||
do
|
|
||||||
cr=$((0 + $RANDOM % 255))
|
|
||||||
crl=$(echo "$cr 0.299" | awk '{print $1 * $2}')
|
|
||||||
cg=$((0 + $RANDOM % 255))
|
|
||||||
cgl=$(echo "$cg 0.299" | awk '{print $1 * $2}')
|
|
||||||
cb=$((0 + $RANDOM % 255))
|
|
||||||
cbl=$(echo "$cb 0.299" | awk '{print $1 * $2}')
|
|
||||||
cluma=$(echo "$crl $cgl $cbl" | awk '{print $1 + $2 + $3}')
|
|
||||||
loops=$((loops+1))
|
|
||||||
done
|
|
||||||
echo "\e[38;2;${cr};${cg};${cb}m"
|
|
||||||
}
|
|
||||||
|
|
||||||
#========Welcome=======#
|
#========Welcome=======#
|
||||||
welcome () {
|
welcome () {
|
||||||
|
msg="Welcome" # Default
|
||||||
|
if [ "$randgreeting" = "on" ]; then
|
||||||
|
greetings=("Welcome" "Greetings" "Hello" "Hi") # Add your own greetings!
|
||||||
|
msg=${greetings[$(($RANDOM % $(echo ${#greetings[@]})))]}
|
||||||
|
fi
|
||||||
|
|
||||||
# Print the welcome message
|
# Print the welcome message
|
||||||
echo -en "Welcome, ${USRC}${BOLD}$USER${NCOL}. "
|
echo -en "$msg, ${USRC}${BOLD}$USER${NCOL}. "
|
||||||
}
|
}
|
||||||
|
|
||||||
#=========Time=========#
|
#=========Time=========#
|
||||||
clock () {
|
clock () {
|
||||||
# Set the current hour and minute
|
# Set the current hour and minute
|
||||||
hour12=$(date +%I)
|
if [ "$twelvehour" = "on" ]; then
|
||||||
|
hour="\b$(date +%_I)"
|
||||||
|
ampm=$(date +%p)
|
||||||
|
else
|
||||||
|
hour=$(date +%H)
|
||||||
|
bksp="\b \b"
|
||||||
|
fi
|
||||||
minute=$(date +%M)
|
minute=$(date +%M)
|
||||||
|
|
||||||
# Print the time
|
# Print the time
|
||||||
echo -en "The time is ${TIME}$hour12${BLNK}:${NCOL}${TIME}$minute${NCOL}. "
|
echo -en "The time is ${TIME}$hour${BLNK}:${NCOL}${TIME}$minute $bksp${ampm}${NCOL}. "
|
||||||
}
|
}
|
||||||
|
|
||||||
#=======Greeting=======#
|
#=======Greeting=======#
|
||||||
|
@ -36,17 +31,13 @@ greeting () {
|
||||||
# Set the hour
|
# Set the hour
|
||||||
hour=$(date +%H)
|
hour=$(date +%H)
|
||||||
|
|
||||||
if [ $hour -le 11 ] && [ $hour -gt 6 ];
|
if [ $hour -le 11 ] && [ $hour -gt 6 ]; then
|
||||||
then
|
|
||||||
echo -en "It's ${MORN}morning${NCOL}. "
|
echo -en "It's ${MORN}morning${NCOL}. "
|
||||||
elif [ $hour -eq 12 ];
|
elif [ $hour -eq 12 ]; then
|
||||||
then
|
|
||||||
echo -en "It's ${AFTN}noon${NCOL}. "
|
echo -en "It's ${AFTN}noon${NCOL}. "
|
||||||
elif [ $hour -le 16 ] && [ $hour -gt 12 ];
|
elif [ $hour -le 16 ] && [ $hour -gt 12 ]; then
|
||||||
then
|
|
||||||
echo -en "It's ${AFTN}afternoon${NCOL}. "
|
echo -en "It's ${AFTN}afternoon${NCOL}. "
|
||||||
elif [ $hour -le 19 ] && [ $hour -gt 17 ];
|
elif [ $hour -le 19 ] && [ $hour -gt 17 ]; then
|
||||||
then
|
|
||||||
echo -en "It's ${EVEN}evening${NCOL}. "
|
echo -en "It's ${EVEN}evening${NCOL}. "
|
||||||
else
|
else
|
||||||
echo -en "It's ${NIGH}night${NCOL}. "
|
echo -en "It's ${NIGH}night${NCOL}. "
|
||||||
|
@ -59,29 +50,23 @@ battery () {
|
||||||
# Set a default to prevent errors
|
# Set a default to prevent errors
|
||||||
batlvl=0
|
batlvl=0
|
||||||
|
|
||||||
if [[ -a "/sys/class/power_supply/BAT0/capacity" ]];
|
if [[ -a "/sys/class/power_supply/BAT0/capacity" ]]; then
|
||||||
then
|
|
||||||
batlvl=$(cat /sys/class/power_supply/BAT0/capacity)
|
batlvl=$(cat /sys/class/power_supply/BAT0/capacity)
|
||||||
elif [[ -a "/sys/class/power_supply/BAT1/capacity" ]];
|
elif [[ -a "/sys/class/power_supply/BAT1/capacity" ]]; then
|
||||||
then
|
|
||||||
batlvl=$(cat /sys/class/power_supply/BAT1/capacity)
|
batlvl=$(cat /sys/class/power_supply/BAT1/capacity)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change color depending on level
|
# Change color depending on level
|
||||||
if [ $batlvl -eq 100 ];
|
if [ $batlvl -eq 100 ]; then
|
||||||
then
|
|
||||||
echo -en "The battery is ${FULL}fully charged${NCOL}. "
|
echo -en "The battery is ${FULL}fully charged${NCOL}. "
|
||||||
else
|
else
|
||||||
echo -en "The battery level is "
|
echo -en "The battery level is "
|
||||||
if [ $batlvl -le 15 ];
|
if [ $batlvl -le 15 ]; then
|
||||||
then
|
|
||||||
echo -en "${CRIT}$batlvl%${NCOL}. "
|
echo -en "${CRIT}$batlvl%${NCOL}. "
|
||||||
if [ "$rechargenotif" = "on" ];
|
if [ "$rechargenotif" = "on" ]; then
|
||||||
then
|
|
||||||
echo -en "- ${NORM}You should probably recharge${NCOL}. "
|
echo -en "- ${NORM}You should probably recharge${NCOL}. "
|
||||||
fi
|
fi
|
||||||
elif [ $batlvl -le 30 ];
|
elif [ $batlvl -le 30 ]; then
|
||||||
then
|
|
||||||
echo -en "${LOW}$batlvl%${NCOL}. "
|
echo -en "${LOW}$batlvl%${NCOL}. "
|
||||||
else
|
else
|
||||||
echo -en "${NORM}$batlvl%${NCOL}. "
|
echo -en "${NORM}$batlvl%${NCOL}. "
|
||||||
|
@ -100,37 +85,30 @@ updates () {
|
||||||
# Check for updates from different places...
|
# Check for updates from different places...
|
||||||
|
|
||||||
# Check for APT
|
# Check for APT
|
||||||
if command -v apt &> /dev/null;
|
if command -v apt &> /dev/null; then
|
||||||
then
|
|
||||||
debian=$(apt-get -s dist-upgrade -V | grep '=>' | awk '{print$1}' | wc -l)
|
debian=$(apt-get -s dist-upgrade -V | grep '=>' | awk '{print$1}' | wc -l)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for different Arch things
|
# Check for different Arch things
|
||||||
if command -v yay &> /dev/null;
|
if command -v yay &> /dev/null; then
|
||||||
then
|
|
||||||
arch=$(yay -Qu 2> /dev/null | wc -l)
|
arch=$(yay -Qu 2> /dev/null | wc -l)
|
||||||
elif command -v paru &> /dev/null;
|
elif command -v paru &> /dev/null; then
|
||||||
then
|
|
||||||
arch=$(paru -Quq 2> /dev/null | wc -l)
|
arch=$(paru -Quq 2> /dev/null | wc -l)
|
||||||
elif command -v pacman &> /dev/null;
|
elif command -v pacman &> /dev/null; then
|
||||||
then
|
|
||||||
arch=$(pacman -Qu 2> /dev/null | wc -l)
|
arch=$(pacman -Qu 2> /dev/null | wc -l)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for Fedora things
|
# Check for Fedora things
|
||||||
if command -v dnf &> /dev/null;
|
if command -v dnf &> /dev/null; then
|
||||||
then
|
|
||||||
fedora=$(dnf list updates 2> /dev/null | wc -l)
|
fedora=$(dnf list updates 2> /dev/null | wc -l)
|
||||||
fedora=$((fedora-1))
|
fedora=$((fedora-1))
|
||||||
elif command -v yum &> /dev/null;
|
elif command -v yum &> /dev/null; then
|
||||||
then
|
|
||||||
fedora=$(yum list updates 2> /dev/null | wc -l)
|
fedora=$(yum list updates 2> /dev/null | wc -l)
|
||||||
fedora=$((fedora-1))
|
fedora=$((fedora-1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for Flatpak
|
# Check for Flatpak
|
||||||
if command -v flatpak &> /dev/null && [ "$flatpakupd" = "on" ];
|
if command -v flatpak &> /dev/null && [ "$flatpakupd" = "on" ]; then
|
||||||
then
|
|
||||||
flatpak=$(flatpak remote-ls --updates 2> /dev/null | wc -l)
|
flatpak=$(flatpak remote-ls --updates 2> /dev/null | wc -l)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -139,29 +117,48 @@ updates () {
|
||||||
updates=$(($debian + $arch + fedora + $flatpak))
|
updates=$(($debian + $arch + fedora + $flatpak))
|
||||||
|
|
||||||
# Check the update amounts and print them out
|
# Check the update amounts and print them out
|
||||||
if [ $updates -eq 1 ];
|
if [ $updates -eq 1 ]; then
|
||||||
then
|
|
||||||
echo -en "You have ${NORM}1${NCOL} pending update. "
|
echo -en "You have ${NORM}1${NCOL} pending update. "
|
||||||
elif [ $updates -eq 0 ];
|
elif [ $updates -eq 0 ]; then
|
||||||
then
|
|
||||||
echo -en "You have no pending updates. "
|
echo -en "You have no pending updates. "
|
||||||
else
|
else
|
||||||
echo -en "You have ~${NORM}$updates${NCOL} pending updates. "
|
echo -en "You have ~${NORM}$updates${NCOL} pending updates. "
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#=====Random Color=====#
|
||||||
|
randcolor() {
|
||||||
|
# For random colors; this will only generate colors with sufficient
|
||||||
|
# perceptual luma to be readable on a dark background... you may have
|
||||||
|
# to modify it for light
|
||||||
|
cluma=0
|
||||||
|
while [[ $(printf %.0f $cluma) -le 100 ]] && [[ $loops -le 10 ]];
|
||||||
|
do
|
||||||
|
cr=$((0 + $RANDOM % 255))
|
||||||
|
crl=$(echo "$cr 0.299" | awk '{print $1 * $2}')
|
||||||
|
cg=$((0 + $RANDOM % 255))
|
||||||
|
cgl=$(echo "$cg 0.299" | awk '{print $1 * $2}')
|
||||||
|
cb=$((0 + $RANDOM % 255))
|
||||||
|
cbl=$(echo "$cb 0.299" | awk '{print $1 * $2}')
|
||||||
|
cluma=$(echo "$crl $cgl $cbl" | awk '{print $1 + $2 + $3}')
|
||||||
|
loops=$((loops+1))
|
||||||
|
done
|
||||||
|
echo "\e[38;2;${cr};${cg};${cb}m"
|
||||||
|
}
|
||||||
|
|
||||||
#=========COLORS=======#
|
#=========COLORS=======#
|
||||||
# Set colors for ease of use
|
|
||||||
NCOL='\e[0m'
|
NCOL='\e[0m'
|
||||||
CRIT='\e[31m'
|
|
||||||
LOW='\e[33m'
|
|
||||||
NORM='\e[32m'
|
|
||||||
FULL='\e[3;4;92m'
|
|
||||||
BOLD='\e[1m'
|
BOLD='\e[1m'
|
||||||
ITAL='\e[3m'
|
ITAL='\e[3m'
|
||||||
UNDR='\e[4m'
|
UNDR='\e[4m'
|
||||||
BLNK='\e[5m'
|
BLNK='\e[5m'
|
||||||
|
|
||||||
|
# Battery level colors
|
||||||
|
CRIT='\e[31m'
|
||||||
|
LOW='\e[33m'
|
||||||
|
NORM='\e[32m'
|
||||||
|
FULL='\e[3;4;92m'
|
||||||
|
|
||||||
TIME='\e[38;2;224;146;252;1m' # Clock color
|
TIME='\e[38;2;224;146;252;1m' # Clock color
|
||||||
USRC=$(randcolor) # <-----------Username color
|
USRC=$(randcolor) # <-----------Username color
|
||||||
|
|
||||||
|
@ -172,12 +169,16 @@ AFTN='\e[38;2;250;245;110m'
|
||||||
EVEN='\e[38;2;171;54;3m'
|
EVEN='\e[38;2;171;54;3m'
|
||||||
|
|
||||||
#=========SETUP========#
|
#=========SETUP========#
|
||||||
# Select which parts you want active by commenting them out
|
# Select which parts you want active by #
|
||||||
# For example, on a desktop, disabling the battery message is a good idea
|
# commenting them out. For example, on a #
|
||||||
# You can also re order them to change how they display!
|
# desktop, disabling the battery message #
|
||||||
|
# is a good idea. You can also re-order #
|
||||||
|
# them to change how they display! #
|
||||||
|
|
||||||
flatpakupd="off" # Check for flatpak updates, this slows startup down A LOT
|
randgreeting="off" #< Turn the random greetings on (eg. "Hello <user>, Hi <user>")
|
||||||
rechargenotif="off" # Notify that you should recharge if below 15%
|
twelvehour="on" #< Switch between 12 and 24 hour time (eg. 8:00pm vs 20:00)
|
||||||
|
rechargenotif="off" #< Notify that you should recharge if below 15%
|
||||||
|
flatpakupd="off" #< Check for flatpak updates, this slows startup down A LOT
|
||||||
|
|
||||||
welcome
|
welcome
|
||||||
greeting
|
greeting
|
||||||
|
|
Loading…
Reference in a new issue