mirror of
https://github.com/G2-Games/welcome.sh.git
synced 2025-04-19 13:32:53 -05:00
Used bash strict mode to clean up the code a bit, couldn't get everything
This commit is contained in:
parent
decec76c61
commit
74a570a107
1 changed files with 12 additions and 10 deletions
20
welcome.sh
20
welcome.sh
|
@ -22,6 +22,7 @@ welcome () {
|
||||||
|
|
||||||
#=========Time=========#
|
#=========Time=========#
|
||||||
clock () {
|
clock () {
|
||||||
|
bksp=""
|
||||||
# Set the current hour and minute
|
# Set the current hour and minute
|
||||||
if [ "$twelvehour" = "on" ]; then
|
if [ "$twelvehour" = "on" ]; then
|
||||||
if [ $(date +%_I) -lt 10 ]; then
|
if [ $(date +%_I) -lt 10 ]; then
|
||||||
|
@ -32,7 +33,7 @@ clock () {
|
||||||
ampm=$(date +%p)
|
ampm=$(date +%p)
|
||||||
else
|
else
|
||||||
hour=$(date +%H)
|
hour=$(date +%H)
|
||||||
bksp="\b \b"
|
bksp="\b \b" # This is a hack to fix some spacing issues with AM and PM with different lengths of time
|
||||||
fi
|
fi
|
||||||
minute=$(date +%M)
|
minute=$(date +%M)
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ greeting () {
|
||||||
greet="Good"
|
greet="Good"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Change color and greeting depending on the segment of day
|
||||||
if [ $hour -le 11 ] && [ $hour -gt 6 ]; then
|
if [ $hour -le 11 ] && [ $hour -gt 6 ]; then
|
||||||
echo -en "$greet ${MORN}morning${NCOL}. "
|
echo -en "$greet ${MORN}morning${NCOL}. "
|
||||||
elif [ $hour -eq 12 ]; then
|
elif [ $hour -eq 12 ]; then
|
||||||
|
@ -69,6 +71,7 @@ battery () {
|
||||||
# Set a default to prevent errors
|
# Set a default to prevent errors
|
||||||
batlvl=0
|
batlvl=0
|
||||||
|
|
||||||
|
# Check the two usually used battery locations
|
||||||
if [[ -a "/sys/class/power_supply/BAT0/capacity" ]]; then
|
if [[ -a "/sys/class/power_supply/BAT0/capacity" ]]; 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" ]]; then
|
elif [[ -a "/sys/class/power_supply/BAT1/capacity" ]]; then
|
||||||
|
@ -109,11 +112,10 @@ updates () {
|
||||||
updates=0
|
updates=0
|
||||||
|
|
||||||
# Check for updates from different places... wonder if there's a better way
|
# Check for updates from different places... wonder if there's a better way
|
||||||
|
|
||||||
updchk () {
|
updchk () {
|
||||||
# Check for APT
|
# Check for APT
|
||||||
if command -v apt-get &> /dev/null; then
|
if command -v apt-get &> /dev/null; then
|
||||||
debian=$(apt-get -s dist-upgrade -V 2> /dev/null | grep '=>' | awk '{print$1}' | wc -l)
|
debian=$(apt-get -s dist-upgrade -V | grep '=>' || [[ $? == 1 ]] | wc -l)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for different Arch things
|
# Check for different Arch things
|
||||||
|
@ -151,7 +153,6 @@ updates () {
|
||||||
if [[ -a ~/.welcome/updates ]]; then
|
if [[ -a ~/.welcome/updates ]]; then
|
||||||
rm ~/.welcome/updates
|
rm ~/.welcome/updates
|
||||||
fi
|
fi
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pid=$(echo $$)
|
pid=$(echo $$)
|
||||||
|
@ -173,10 +174,10 @@ updates () {
|
||||||
if [ $chk -lt 1 ]; then
|
if [ $chk -lt 1 ]; then
|
||||||
echo -en "Update check timed out. "
|
echo -en "Update check timed out. "
|
||||||
else
|
else
|
||||||
if [ $updates -eq 1 ]; then
|
if [ $updates -eq 0 ]; then
|
||||||
echo -en "You have ${NORM}1${NCOL} pending update. "
|
|
||||||
elif [ $updates -eq 0 ]; then
|
|
||||||
echo -en "You have no pending updates. "
|
echo -en "You have no pending updates. "
|
||||||
|
elif [ $updates -eq 1 ]; then
|
||||||
|
echo -en "You have ${NORM}1${NCOL} pending update. "
|
||||||
else
|
else
|
||||||
echo -en "You have ~${NORM}$updates${NCOL} pending updates. "
|
echo -en "You have ~${NORM}$updates${NCOL} pending updates. "
|
||||||
fi
|
fi
|
||||||
|
@ -190,8 +191,7 @@ randcolor() {
|
||||||
# to modify it for a light one #
|
# to modify it for a light one #
|
||||||
cluma=0
|
cluma=0
|
||||||
loops=0
|
loops=0
|
||||||
while [ $(printf %.0f $cluma) -le 100 ] && [ $loops -le 10 ];
|
while [ $(printf %.0f $cluma) -le 100 ] && [ $loops -le 10 ]; do
|
||||||
do
|
|
||||||
cr=$((0 + $RANDOM % 255))
|
cr=$((0 + $RANDOM % 255))
|
||||||
crl=$(echo "$cr 0.299" | awk '{print $1 * $2}')
|
crl=$(echo "$cr 0.299" | awk '{print $1 * $2}')
|
||||||
cg=$((0 + $RANDOM % 255))
|
cg=$((0 + $RANDOM % 255))
|
||||||
|
@ -235,6 +235,8 @@ updatecheck="on" #< Check for general updates
|
||||||
flatpakupd="off" #< Check for flatpak updates, this slows startup down A LOT
|
flatpakupd="off" #< Check for flatpak updates, this slows startup down A LOT
|
||||||
goodgreeting="on" #< Display greetings like "Good afternoon," else "It's afternoon"
|
goodgreeting="on" #< Display greetings like "Good afternoon," else "It's afternoon"
|
||||||
|
|
||||||
|
# ALL the stuff above this line and below the colors line is in the config, changing it here will do nothing if the config doesn't exist!
|
||||||
|
|
||||||
source ~/.welcome/config.cfg
|
source ~/.welcome/config.cfg
|
||||||
|
|
||||||
welcome
|
welcome
|
||||||
|
|
Loading…
Reference in a new issue