mirror of
https://github.com/G2-Games/welcome.sh.git
synced 2025-06-23 17:22:54 -05:00
Compare commits
No commits in common. "4e5b2a848e21c3f5817d6ea5208e77ec5e2a5282" and "a863f8ddc6718fa9aff2354dac6daff107a35903" have entirely different histories.
4e5b2a848e
...
a863f8ddc6
2 changed files with 107 additions and 136 deletions
251
install.sh
251
install.sh
|
@ -1,5 +1,6 @@
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
|
||||||
getVersion () {
|
getVersion () {
|
||||||
local ver
|
|
||||||
ver=$(grep version ~/.welcome/welcome.sh 2> /dev/null | sed 's/.*=//')
|
ver=$(grep version ~/.welcome/welcome.sh 2> /dev/null | sed 's/.*=//')
|
||||||
|
|
||||||
if [ -z "$ver" ]; then
|
if [ -z "$ver" ]; then
|
||||||
|
@ -10,8 +11,7 @@ getVersion () {
|
||||||
echo "$ver"
|
echo "$ver"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Universal read command for bash and zsh
|
univRead () { # Universal read command for bash and zsh
|
||||||
univRead () {
|
|
||||||
echo -en "$1"
|
echo -en "$1"
|
||||||
echo -en "\n[\e[36mY/n\e[0m]"
|
echo -en "\n[\e[36mY/n\e[0m]"
|
||||||
if [[ "$environment" = "bash" ]]; then
|
if [[ "$environment" = "bash" ]]; then
|
||||||
|
@ -22,42 +22,96 @@ univRead () {
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
uninstall () {
|
tput sc
|
||||||
# Check if the user actually wishes to uninstall the script
|
if ! [[ $1 == "auto" ]] && [[ -z "$1" ]]; then
|
||||||
univRead "Do you want to \e[31muninstall \e[35mwelcome.sh\e[0m?"
|
echo "Checking for latest release..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
latestver=$(curl -Ls https://github.com/G2-Games/welcome.sh/releases/latest/download/welcome.sh | grep version | sed 's/.*=//')
|
||||||
|
oldver=$(grep version ~/.welcome/welcome.sh 2> /dev/null | sed 's/.*=//' | sed 's/[.][.]*//g') && if [[ -z "$oldver" ]]; then oldver=0; fi
|
||||||
|
|
||||||
|
version="${1:-$latestver}"
|
||||||
|
|
||||||
|
if [[ $1 == "auto" ]] && [[ ${latestver//./} -le $oldver ]]; then
|
||||||
|
exit 0
|
||||||
|
elif [[ $1 == "auto" ]]; then
|
||||||
|
version=$latestver
|
||||||
|
fi
|
||||||
|
|
||||||
|
vernum=${version//./}
|
||||||
|
bashrc=~/.bashrc
|
||||||
|
zshrc=~/.zshrc
|
||||||
|
originaldir=$PWD
|
||||||
|
environment=$(ps -o args= -p $$ | grep -Em 1 -o '\w{0,5}sh' | head -1)
|
||||||
|
|
||||||
|
# Check if the environment is bash or zsh
|
||||||
|
if [[ "$environment" != "bash" ]] && [[ "$environment" != "zsh" ]]; then
|
||||||
|
printf "\e[31;5mERROR:\e[0m \e[31;3mThis script can only be installed in Bash or Zsh.\e[0m\n"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! grep -qs 'bash ~/.welcome/welcome.sh' $bashrc && ! grep -qs 'zsh ~/.welcome/welcome.sh' $zshrc && ! grep -qs 'bash /home/$USER/.welcome/welcome.sh' $bashrc && ! grep -qs 'zsh /home/$USER/.welcome/welcome.sh' $zshrc; then
|
||||||
|
tput rc
|
||||||
|
echo "Welcome! Installing v$version in $environment..."
|
||||||
|
tput sc
|
||||||
|
|
||||||
|
cd ~/ || exit 1
|
||||||
|
mkdir -p ~/.welcome
|
||||||
|
curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v"${version}"/welcome.sh --output ~/.welcome/welcome.sh
|
||||||
|
if [[ $vernum -ge 100 ]]; then
|
||||||
|
curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v"${version}"/config.cfg --output ~/.welcome/config.cfg
|
||||||
|
fi
|
||||||
|
chmod +x ~/.welcome/welcome.sh
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "$environment" = "bash" ]]; then
|
||||||
|
echo "Installing to bashrc"
|
||||||
|
echo 'bash ~/.welcome/welcome.sh' >> $bashrc
|
||||||
|
elif [[ "$environment" = "zsh" ]]; then
|
||||||
|
echo "Installing to zshrc"
|
||||||
|
echo 'zsh ~/.welcome/welcome.sh' >> $zshrc
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$originaldir" || exit 1
|
||||||
|
tput rc && tput el && tput ed
|
||||||
|
echo -e "\e[36mInstalled! \e[0m"
|
||||||
|
else
|
||||||
|
tput rc
|
||||||
|
tput sc
|
||||||
|
mkdir -p ~/.welcome
|
||||||
|
if ! [[ $1 == "auto" ]]; then
|
||||||
|
echo -e "\e[35mwelcome.sh\e[0m already installed!"
|
||||||
|
else
|
||||||
|
echo -e "\e[32mUpdate available for \e[35mwelcome.sh!\e[0m"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $vernum -gt $oldver ]]; then
|
||||||
|
|
||||||
|
# Pull the new configuration version from github
|
||||||
|
newCfgVer=$(curl -Ls https://github.com/G2-Games/welcome.sh/releases/download/v"${version}"/config.cfg | grep version | cut -d= -f2)
|
||||||
|
|
||||||
|
univRead "Do you want to \e[36mupdate \e[35mwelcome.sh\e[0m? (\e[36mv$(getVersion)\e[0m => \e[32mv$version\e[0m)"
|
||||||
if ! [[ $REPLY =~ ^[Yy]$ ]]; then
|
if ! [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
tput rc el ed
|
tput rc && tput el && tput ed
|
||||||
echo -e "\e[31mUninstall cancelled.\e[0m"
|
echo -e "\e[31mCancelled"
|
||||||
|
if [[ $1 != "auto" ]]; then
|
||||||
|
echo -e "\e[35mwelcome.sh\e[0m already installed!"
|
||||||
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tput rc el ed
|
if [[ $newCfgVer -gt $(grep version ~/.welcome/config.cfg 2> /dev/null | cut -d= -f2) ]]; then
|
||||||
echo "Goodbye. Uninstalling..."
|
univRead "Newer \e[36mconfig\e[0m version available. Do you want to \e[31moverwrite\e[0m your \e[36mconfig\e[0m? \nA backup will be created in the \e[36m.welcome\e[0m folder."
|
||||||
tput sc
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
rm ~/.welcome/welcome.sh 2> /dev/null
|
overcfg=1
|
||||||
rm ~/.welcome/config.cfg 2> /dev/null
|
fi
|
||||||
rm ~/.welcome/config_old.cfg 2> /dev/null
|
elif [[ $oldver -lt 100 ]]; then
|
||||||
rm -r ~/.welcome
|
overcfg=1
|
||||||
|
else
|
||||||
#remove all lines that match the string
|
overcfg=0
|
||||||
lines=$(grep -sn 'bash ~/.welcome/welcome.sh' "$bashrc" | sed -e 's/:.*//g' && grep -sn 'bash /home/$USER/.welcome/welcome.sh' "$bashrc" | sed -e 's/:.*//g')
|
fi
|
||||||
lines=$(printf '%s\n' "$lines" | sed '1!G;h;$!d' | sed ':a;N;$!ba;s/\n/ /g')
|
|
||||||
for i in $lines; do
|
|
||||||
sed "${i}d" "$bashrc" > file.tmp && mv file.tmp "$bashrc"
|
|
||||||
done
|
|
||||||
|
|
||||||
lines=$(grep -sn 'zsh ~/.welcome/welcome.sh' "$zshrc" | sed -e 's/:.*//g' && grep -sn 'zsh /home/$USER/.welcome/welcome.sh' "$zshrc" | sed -e 's/:.*//g')
|
|
||||||
lines=$(printf '%s\n' "$lines" | sed '1!G;h;$!d' | sed ':a;N;$!ba;s/\n/ /g')
|
|
||||||
for i in $lines; do
|
|
||||||
sed "${i}d" "$zshrc" > file.tmp && mv file.tmp "$zshrc"
|
|
||||||
done
|
|
||||||
|
|
||||||
tput rc && tput el && tput ed
|
tput rc && tput el && tput ed
|
||||||
echo -e "\e[36mUninstalled! \e[0m"
|
|
||||||
}
|
|
||||||
|
|
||||||
update () {
|
|
||||||
tput rc el ed
|
|
||||||
echo "Updating..."
|
echo "Updating..."
|
||||||
tput sc
|
tput sc
|
||||||
mkdir -p ~/.welcome
|
mkdir -p ~/.welcome
|
||||||
|
@ -85,115 +139,40 @@ update () {
|
||||||
done
|
done
|
||||||
echo 'zsh ~/.welcome/welcome.sh' >> $zshrc
|
echo 'zsh ~/.welcome/welcome.sh' >> $zshrc
|
||||||
|
|
||||||
tput rc el ed
|
tput rc && tput el && tput ed
|
||||||
echo -e "\e[32mUpdated to v$version! \e[0m"
|
echo -e "\e[32mUpdated to v$version! \e[0m"
|
||||||
}
|
|
||||||
|
|
||||||
tput sc
|
|
||||||
if [[ -z "$1" ]] && [[ $1 != "auto" ]]; then
|
|
||||||
echo "Checking for latest release..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! [[ $(command -v curl) ]]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
latestver=$(curl -Ls https://github.com/G2-Games/welcome.sh/releases/latest/download/welcome.sh | grep version | cut -d= -f2)
|
|
||||||
oldver=$(grep version ~/.welcome/welcome.sh 2> /dev/null | cut -d= -f2 | sed 's/[.][.]*//g') && if [[ -z "$oldver" ]]; then oldver=0; fi
|
|
||||||
|
|
||||||
version="${1:-$latestver}"
|
|
||||||
|
|
||||||
if [[ $1 == "auto" ]] && [[ ${latestver//./} -le $oldver ]]; then
|
|
||||||
exit 0
|
exit 0
|
||||||
elif [[ $1 == "auto" ]]; then
|
|
||||||
version=$latestver
|
|
||||||
fi
|
|
||||||
|
|
||||||
vernum=${version//./}
|
|
||||||
bashrc=~/.bashrc
|
|
||||||
zshrc=~/.zshrc
|
|
||||||
originaldir=$PWD
|
|
||||||
environment=$(ps -o args= -p $$ | grep -Em 1 -o '\w{0,5}sh' | head -1)
|
|
||||||
|
|
||||||
# Check if the environment is bash or zsh
|
|
||||||
if [[ "$environment" != "bash" ]] && [[ "$environment" != "zsh" ]]; then
|
|
||||||
tput rc
|
|
||||||
printf "\e[31;5mERROR:\e[0m \e[31;3mThis script can only be installed in Bash or Zsh.\e[0m\n"
|
|
||||||
printf "\e[32mYou appear to be using %s, which is not a valid shell for\n\
|
|
||||||
this script!\e[0m Please use \e[3mBash \e[0mor \e[3mZsh.\e[0m\n" "${environment}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if already installed
|
|
||||||
if ! grep -qs 'bash ~/.welcome/welcome.sh' $bashrc && ! grep -qs 'zsh ~/.welcome/welcome.sh' $zshrc && ! grep -qs 'bash /home/$USER/.welcome/welcome.sh' $bashrc && ! grep -qs 'zsh /home/$USER/.welcome/welcome.sh' $zshrc; then
|
|
||||||
#==== Execute if first time installing...====#
|
|
||||||
|
|
||||||
tput rc
|
|
||||||
echo "Welcome! Installing v$version in $environment..."
|
|
||||||
tput sc
|
|
||||||
|
|
||||||
cd ~/ || exit 1
|
|
||||||
mkdir -p ~/.welcome
|
|
||||||
curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v"${version}"/welcome.sh --output ~/.welcome/welcome.sh
|
|
||||||
if [[ $vernum -ge 100 ]]; then
|
|
||||||
curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v"${version}"/config.cfg --output ~/.welcome/config.cfg
|
|
||||||
fi
|
|
||||||
chmod +x ~/.welcome/welcome.sh
|
|
||||||
|
|
||||||
if [[ "$environment" = "bash" ]]; then
|
|
||||||
echo "Installing to bashrc"
|
|
||||||
echo 'bash ~/.welcome/welcome.sh' >> $bashrc
|
|
||||||
elif [[ "$environment" = "zsh" ]]; then
|
|
||||||
echo "Installing to zshrc"
|
|
||||||
echo 'zsh ~/.welcome/welcome.sh' >> $zshrc
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$originaldir" || exit 1
|
# Check if the user actually wishes to uninstall the script
|
||||||
tput rc el ed
|
univRead "Do you want to \e[31muninstall \e[35mwelcome.sh\e[0m?"
|
||||||
echo -e "\e[36mInstalled! \e[0m"
|
|
||||||
else
|
|
||||||
#==== Execute if already installed...====#
|
|
||||||
|
|
||||||
tput rc sc el ed
|
|
||||||
mkdir -p ~/.welcome
|
|
||||||
if ! [[ $1 == "auto" ]]; then
|
|
||||||
echo -e "\e[35mwelcome.sh\e[0m already installed!"
|
|
||||||
else
|
|
||||||
echo -e "\e[32mUpdate available for \e[35mwelcome.sh!\e[0m"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $vernum -gt $oldver ]]; then
|
|
||||||
# Pull the new configuration version from github
|
|
||||||
newCfgVer=$(curl -Ls https://github.com/G2-Games/welcome.sh/releases/download/v"${version}"/config.cfg | grep version | cut -d= -f2)
|
|
||||||
|
|
||||||
univRead "Do you want to \e[36mupdate \e[35mwelcome.sh\e[0m? (\e[36mv$(getVersion)\e[0m => \e[32mv$version\e[0m)"
|
|
||||||
if ! [[ $REPLY =~ ^[Yy]$ ]]; then
|
if ! [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
tput rc sc el ed
|
tput rc && tput el && tput ed
|
||||||
echo -e "\e[31mUpdate cancelled.\e[0m"
|
echo -e "\e[31mCancelled. \e[0m"
|
||||||
update=0
|
|
||||||
else
|
|
||||||
update=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $newCfgVer -gt $(grep version ~/.welcome/config.cfg 2> /dev/null | cut -d= -f2) ]]; then
|
|
||||||
univRead "Newer \e[36mconfig\e[0m version available. Do you want to \e[31moverwrite\e[0m your \e[36mconfig\e[0m? \nA backup will be created in the \e[36m.welcome\e[0m folder."
|
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
||||||
overcfg=1
|
|
||||||
fi
|
|
||||||
elif [[ $oldver -lt 100 ]]; then
|
|
||||||
overcfg=1
|
|
||||||
else
|
|
||||||
overcfg=0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ update -gt 0 ]]; then
|
|
||||||
update
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [[ $1 == "auto" ]]; then
|
tput rc && tput el && tput ed
|
||||||
uninstall
|
echo "Goodbye. Uninstalling..."
|
||||||
exit 0
|
tput sc
|
||||||
fi
|
rm ~/.welcome/welcome.sh 2> /dev/null
|
||||||
|
rm ~/.welcome/config.cfg 2> /dev/null
|
||||||
|
rm ~/.welcome/config_old.cfg 2> /dev/null
|
||||||
|
rm -r ~/.welcome
|
||||||
|
|
||||||
|
#remove all lines that match the string
|
||||||
|
lines=$(grep -sn 'bash ~/.welcome/welcome.sh' $bashrc | sed -e 's/:.*//g' && grep -sn 'bash /home/$USER/.welcome/welcome.sh' $bashrc | sed -e 's/:.*//g')
|
||||||
|
lines=$(printf '%s\n' "$lines" | sed '1!G;h;$!d' | sed ':a;N;$!ba;s/\n/ /g')
|
||||||
|
for i in $lines; do
|
||||||
|
sed "${i}d" $bashrc > file.tmp && mv file.tmp $bashrc
|
||||||
|
done
|
||||||
|
|
||||||
|
lines=$(grep -sn 'zsh ~/.welcome/welcome.sh' $zshrc | sed -e 's/:.*//g' && grep -sn 'zsh /home/$USER/.welcome/welcome.sh' $zshrc | sed -e 's/:.*//g')
|
||||||
|
lines=$(printf '%s\n' "$lines" | sed '1!G;h;$!d' | sed ':a;N;$!ba;s/\n/ /g')
|
||||||
|
for i in $lines; do
|
||||||
|
sed "${i}d" $zshrc > file.tmp && mv file.tmp $zshrc
|
||||||
|
done
|
||||||
|
|
||||||
|
tput rc && tput el && tput ed
|
||||||
|
echo -e "\e[36mUninstalled! \e[0m"
|
||||||
fi
|
fi
|
||||||
|
|
58
welcome.sh
58
welcome.sh
|
@ -2,17 +2,11 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
|
||||||
|
version=1.0.5
|
||||||
export LC_NUMERIC="en_US.UTF-8" &> /dev/null #Fix for locales that use , instead of . as a decimal delimiter
|
export LC_NUMERIC="en_US.UTF-8" &> /dev/null #Fix for locales that use , instead of . as a decimal delimiter
|
||||||
|
|
||||||
# Define "global" variables
|
|
||||||
environment=$(ps -o args= -p $$ | grep -Em 1 -o '\w{0,5}sh' | head -1)
|
|
||||||
version=1.1.0
|
|
||||||
|
|
||||||
#========Welcome=======#
|
#========Welcome=======#
|
||||||
welcome () {
|
welcome () {
|
||||||
msg="Welcome" # Default
|
msg="Welcome" # Default
|
||||||
greetingsLength=${#greetings[@]}
|
|
||||||
greetingsNumber=$((RANDOM % greetingsLength))
|
|
||||||
|
|
||||||
if command -v whoami &>/dev/null ; then
|
if command -v whoami &>/dev/null ; then
|
||||||
usr=$(whoami)
|
usr=$(whoami)
|
||||||
|
@ -23,7 +17,7 @@ welcome () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$randgreeting" = "on" ]; then
|
if [ "$randgreeting" = "on" ]; then
|
||||||
msg=${greetings[$greetingsNumber]}
|
msg=${greetings[$(($RANDOM % $(echo ${#greetings[@]})))]}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print the welcome message
|
# Print the welcome message
|
||||||
|
@ -35,7 +29,7 @@ clock () {
|
||||||
bksp=""
|
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
|
||||||
hour="\b$(date +%_I)"
|
hour="\b$(date +%_I)"
|
||||||
else
|
else
|
||||||
hour="$(date +%_I)"
|
hour="$(date +%_I)"
|
||||||
|
@ -62,13 +56,13 @@ greeting () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change color and greeting depending on the segment of day
|
# 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
|
||||||
echo -en "It's ${AFTN}noon${NCOL}. "
|
echo -en "It's ${AFTN}noon${NCOL}. "
|
||||||
elif [ "$hour" -le 17 ] && [ "$hour" -gt 12 ]; then
|
elif [ $hour -le 17 ] && [ $hour -gt 12 ]; then
|
||||||
echo -en "$greet ${AFTN}afternoon${NCOL}. "
|
echo -en "$greet ${AFTN}afternoon${NCOL}. "
|
||||||
elif [ "$hour" -le 19 ] && [ "$hour" -gt 17 ]; then
|
elif [ $hour -le 19 ] && [ $hour -gt 17 ]; then
|
||||||
echo -en "$greet ${EVEN}evening${NCOL}. "
|
echo -en "$greet ${EVEN}evening${NCOL}. "
|
||||||
else
|
else
|
||||||
echo -en "It's ${NIGH}night${NCOL}. "
|
echo -en "It's ${NIGH}night${NCOL}. "
|
||||||
|
@ -93,13 +87,13 @@ battery () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change color depending on level
|
# Change color depending on level
|
||||||
if [[ $batlvl -ge 100 ]]; then
|
if [ $batlvl -ge 100 ]; then
|
||||||
echo -en "The battery is ${FULL}fully charged${NCOL}. "
|
echo -en "The battery is ${FULL}fully charged${NCOL}. "
|
||||||
elif [[ $batlvl -gt 0 ]]; then
|
elif [ $batlvl -gt 0 ]; then
|
||||||
echo -en "The battery level is "
|
echo -en "The battery level is "
|
||||||
if [[ $batlvl -le 15 ]]; then
|
if [ $batlvl -le 15 ]; then
|
||||||
echo -en "${CRIT}$batlvl%${NCOL}. "
|
echo -en "${CRIT}$batlvl%${NCOL}. "
|
||||||
if [[ "$rechargenotif" = "on" ]]; then
|
if [ "$rechargenotif" = "on" ]; then
|
||||||
echo -en "- ${NORM}You should probably recharge${NCOL}. "
|
echo -en "- ${NORM}You should probably recharge${NCOL}. "
|
||||||
fi
|
fi
|
||||||
elif [ $batlvl -le 30 ]; then
|
elif [ $batlvl -le 30 ]; then
|
||||||
|
@ -157,25 +151,24 @@ updates () {
|
||||||
if command -v flatpak &> /dev/null && [ "$flatpakupd" = "on" ]; then
|
if command -v flatpak &> /dev/null && [ "$flatpakupd" = "on" ]; then
|
||||||
flatpak=$(flatpak remote-ls --updates 2> /dev/null | wc -l)
|
flatpak=$(flatpak remote-ls --updates 2> /dev/null | wc -l)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add all update counts together
|
# Add all update counts together
|
||||||
updates=$((debian + arch + fedora + flatpak + brew))
|
updates=$(($debian + $arch + $fedora + $flatpak + $brew))
|
||||||
echo $updates >| ~/.welcome/updates
|
echo $updates >| ~/.welcome/updates
|
||||||
pkill -P "${pid}" sleep # When update checking is finished, kill the sleep function running under this bash process
|
pkill -P $pid sleep # When update checking is finished, kill the sleep function running under this bash process
|
||||||
sleep 5
|
sleep 5
|
||||||
if [[ -a ~/.welcome/updates ]]; then
|
if [[ -a ~/.welcome/updates ]]; then
|
||||||
rm ~/.welcome/updates
|
rm ~/.welcome/updates
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
pid=$$ # Grab the PID of the process
|
pid=$(echo $$) # Grab the PID of the process
|
||||||
updchk & # Check for updates Asynchronously
|
updchk & # Check for updates Asynchronously
|
||||||
|
|
||||||
set +e # Allow nonzero exit status for killing sleep
|
set +e # Allow nonzero exit status for killing sleep
|
||||||
exec 3>&2 # These exec commands simply supress the output of the "kill" command
|
exec 3>&2 # These exec commands simply supress the output of the "kill" command
|
||||||
exec 2> /dev/null
|
exec 2> /dev/null
|
||||||
sleep 5
|
sleep 5
|
||||||
chk=$?
|
chk=$(echo $?)
|
||||||
exec 2>&3 # And then re-enable it
|
exec 2>&3 # And then re-enable it
|
||||||
exec 3>&-
|
exec 3>&-
|
||||||
set -e # Return to disallowing nonzero exit status
|
set -e # Return to disallowing nonzero exit status
|
||||||
|
@ -189,9 +182,9 @@ 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 0 ]; then
|
if [ $updates -eq 0 ]; then
|
||||||
echo -en "You have no pending updates. "
|
echo -en "You have no pending updates. "
|
||||||
elif [ "${updates}" -eq 1 ]; then
|
elif [ $updates -eq 1 ]; then
|
||||||
echo -en "You have ${NORM}1${NCOL} pending update. "
|
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. "
|
||||||
|
@ -206,12 +199,12 @@ 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 ]; do
|
while [ $(printf %.0f $cluma) -le 100 ] && [ $loops -le 10 ]; 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))
|
||||||
cgl=$(echo "$cg 0.587" | awk '{print $1 * $2}')
|
cgl=$(echo "$cg 0.587" | awk '{print $1 * $2}')
|
||||||
cb=$((0 + RANDOM % 255))
|
cb=$((0 + $RANDOM % 255))
|
||||||
cbl=$(echo "$cb 0.114" | awk '{print $1 * $2}')
|
cbl=$(echo "$cb 0.114" | awk '{print $1 * $2}')
|
||||||
cluma=$(echo "$crl $cgl $cbl" | awk '{print $1 + $2 + $3}')
|
cluma=$(echo "$crl $cgl $cbl" | awk '{print $1 + $2 + $3}')
|
||||||
loops=$((loops+1))
|
loops=$((loops+1))
|
||||||
|
@ -258,9 +251,7 @@ welcome
|
||||||
greeting
|
greeting
|
||||||
clock
|
clock
|
||||||
battery
|
battery
|
||||||
if [ "$updatecheck" = "on" ]; then
|
if [ "$updatecheck" = "on" ];then updates; fi
|
||||||
updates
|
|
||||||
fi
|
|
||||||
echo # Properly line break at the end
|
echo # Properly line break at the end
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
|
@ -269,13 +260,14 @@ date=$(date +%s)
|
||||||
lastdate=$(cat ~/.welcome/udm 2>/dev/null)
|
lastdate=$(cat ~/.welcome/udm 2>/dev/null)
|
||||||
|
|
||||||
if [[ $((date - lastdate)) -ge 86400 ]]; then
|
if [[ $((date - lastdate)) -ge 86400 ]]; then
|
||||||
|
environment=$(ps -o args= -p $$ | grep -Em 1 -o '\w{0,5}sh' | head -1)
|
||||||
if [[ "$environment" = "bash" ]]; then
|
if [[ "$environment" = "bash" ]]; then
|
||||||
bash install.sh auto
|
bash install.sh auto
|
||||||
elif [[ "$environment" = "zsh" ]]; then
|
elif [[ "$environment" = "zsh" ]]; then
|
||||||
zsh install.sh auto
|
zsh install.sh auto
|
||||||
fi
|
fi
|
||||||
date +%s >| ~/.welcome/udm 2>/dev/null
|
echo $(date +%s) >| ~/.welcome/udm 2>/dev/null
|
||||||
elif ! [[ -f ~/.welcome/udm ]]; then
|
elif ! [[ -f ~/.welcome/udm ]]; then
|
||||||
touch ~/.welcome/udm
|
touch ~/.welcome/udm
|
||||||
date +%s >| ~/.welcome/udm 2>/dev/null
|
echo $(date +%s) >| ~/.welcome/udm 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue