mirror of
https://github.com/G2-Games/welcome.sh.git
synced 2025-05-03 11:52:54 -05:00
Added full color support to welcome.sh along with random color generator
This commit is contained in:
parent
c258c5ce2d
commit
cf6634a9d5
1 changed files with 54 additions and 35 deletions
89
welcome.sh
89
welcome.sh
|
@ -1,44 +1,52 @@
|
||||||
#!/bin/bash
|
# 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() {
|
||||||
#====Customization=====#
|
cluma=0
|
||||||
# Set colors for ease of use
|
while [[ $(printf %.0f $cluma) -le 100 ]] && [[ $loops -le 10 ]];
|
||||||
NCOL='\e[0m'
|
do
|
||||||
CRIT='\e[31m'
|
cr=$((0 + $RANDOM % 255))
|
||||||
LOW='\e[33m'
|
crl=$(echo "$cr 0.299" | awk '{print $1 * $2}')
|
||||||
NORM='\e[32m'
|
cg=$((0 + $RANDOM % 255))
|
||||||
FULL='\e[3;4;92m'
|
cgl=$(echo "$cg 0.299" | awk '{print $1 * $2}')
|
||||||
BOLD='\e[1m'
|
cb=$((0 + $RANDOM % 255))
|
||||||
ITAL='\e[3m'
|
cbl=$(echo "$cb 0.299" | awk '{print $1 * $2}')
|
||||||
UNDR='\e[4m'
|
cluma=$(echo "$crl $cgl $cbl" | awk '{print $1 + $2 + $3}')
|
||||||
BLNK='\e[5m'
|
loops=$((loops+1))
|
||||||
USRC='\e[1;32m'
|
done
|
||||||
|
echo "\e[38;2;${cr};${cg};${cb}m"
|
||||||
NIGH='\e[0;35m'
|
}
|
||||||
MORN='\e[0;33m'
|
|
||||||
AFTN='\e[0;93m'
|
|
||||||
EVEN='\e[0;91m'
|
|
||||||
|
|
||||||
#========Welcome=======#
|
#========Welcome=======#
|
||||||
welcome () {
|
welcome () {
|
||||||
# Print the welcome message
|
# Print the welcome message
|
||||||
echo -en "Welcome, ${USRC}$USER${NCOL}. "
|
echo -en "Welcome, ${USRC}${BOLD}$USER${NCOL}. "
|
||||||
|
}
|
||||||
|
|
||||||
|
#=========Time=========#
|
||||||
|
clock () {
|
||||||
|
# Set the current hour and minute
|
||||||
|
hour12=$(date +%I)
|
||||||
|
minute=$(date +%M)
|
||||||
|
|
||||||
|
# Print the time
|
||||||
|
echo -en "The time is ${TIME}$hour12${BLNK}:${NCOL}${TIME}$minute${NCOL}. "
|
||||||
}
|
}
|
||||||
|
|
||||||
#=======Greeting=======#
|
#=======Greeting=======#
|
||||||
greeting () {
|
greeting () {
|
||||||
# Set the hour
|
# Set the hour
|
||||||
hr=$(date +%H)
|
hour=$(date +%H)
|
||||||
|
hour=17
|
||||||
|
|
||||||
if [ $hr -le 11 ] && [ $hr -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 [ $hr -eq 12 ];
|
elif [ $hour -eq 12 ];
|
||||||
then
|
then
|
||||||
echo -en "It's ${AFTN}noon${NCOL}. "
|
echo -en "It's ${AFTN}noon${NCOL}. "
|
||||||
elif [ $hr -le 16 ] && [ $hr -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 [ $hr -le 19 ] && [ $hr -gt 16 ];
|
elif [ $hour -le 19 ] && [ $hour -gt 16 ];
|
||||||
then
|
then
|
||||||
echo -en "It's ${EVEN}evening${NCOL}. "
|
echo -en "It's ${EVEN}evening${NCOL}. "
|
||||||
else
|
else
|
||||||
|
@ -82,16 +90,6 @@ battery () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#=========Time=========#
|
|
||||||
clock () {
|
|
||||||
# Set the current hour and minute
|
|
||||||
hour=$(date +%I)
|
|
||||||
minute=$(date +%M)
|
|
||||||
|
|
||||||
# Print the time
|
|
||||||
echo -en "The time is ${BOLD}$hour${BLNK}:${NCOL}${BOLD}$minute${NCOL}. "
|
|
||||||
}
|
|
||||||
|
|
||||||
#========Updates=======#
|
#========Updates=======#
|
||||||
updates () {
|
updates () {
|
||||||
# Set defaults to prevent errors
|
# Set defaults to prevent errors
|
||||||
|
@ -153,6 +151,27 @@ updates () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#=========COLORS=======#
|
||||||
|
# Set colors for ease of use
|
||||||
|
NCOL='\e[0m'
|
||||||
|
CRIT='\e[31m'
|
||||||
|
LOW='\e[33m'
|
||||||
|
NORM='\e[32m'
|
||||||
|
FULL='\e[3;4;92m'
|
||||||
|
BOLD='\e[1m'
|
||||||
|
ITAL='\e[3m'
|
||||||
|
UNDR='\e[4m'
|
||||||
|
BLNK='\e[5m'
|
||||||
|
|
||||||
|
TIME='\e[38;2;224;146;252;1m' # Clock color
|
||||||
|
USRC=$(randcolor) # <-----------Username color
|
||||||
|
|
||||||
|
# Greeting colors
|
||||||
|
NIGH='\e[38;2;200;107;209m'
|
||||||
|
MORN='\e[38;2;255;164;74m'
|
||||||
|
AFTN='\e[38;2;250;245;110m'
|
||||||
|
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 commenting them out
|
||||||
# For example, on a desktop, disabling the battery message is a good idea
|
# For example, on a desktop, disabling the battery message is a good idea
|
||||||
|
|
Loading…
Reference in a new issue