mirror of
https://github.com/Lissy93/dotfiles.git
synced 2024-11-24 16:33:14 +01:00
🌈 Shows date, weather and IP in welcome script
This commit is contained in:
parent
1f514edcb2
commit
a18855f1bc
@ -1,16 +1,31 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Script that shows a welcome message and prints system info for user
|
|
||||||
|
# Welcome script, prints time-based greeting and system info
|
||||||
# Licensed under MIT, (C) Alicia Sykes 2021: https://aliciasykes.com
|
# Licensed under MIT, (C) Alicia Sykes 2021: https://aliciasykes.com
|
||||||
|
|
||||||
|
# Determine greeting based on the time of day
|
||||||
|
h=`date +%H`
|
||||||
|
if [ $h -lt 04 ] || [[ $h -gt 22 ]]; then greeting="Good Night"
|
||||||
|
elif [ $h -lt 12 ]; then greeting="Good morning"
|
||||||
|
elif [ $h -lt 18 ]; then greeting="Good afternoon"
|
||||||
|
elif [ $h -lt 22 ]; then greeting="Good evening"
|
||||||
|
else greeting="Hello"
|
||||||
|
fi
|
||||||
|
|
||||||
# Make nice welcome message, with a first-letter capitalized username
|
COLOR_P="\033[1;36m"
|
||||||
WELCOME_MSG="Welcome $(echo "$USER" | sed 's/.*/\u&/') !"
|
COLOR_S="\033[0;36m"
|
||||||
|
|
||||||
|
# Format user's name
|
||||||
|
name=$(echo "$USER" | sed 's/.*/\u&/')
|
||||||
|
|
||||||
|
# Make welcome message
|
||||||
|
WELCOME_MSG="$greeting $name!"
|
||||||
|
|
||||||
# Print welcome message, using figlet & lolcat if availible
|
# Print welcome message, using figlet & lolcat if availible
|
||||||
if hash lolcat 2>/dev/null && hash figlet 2>/dev/null; then
|
if hash lolcat 2>/dev/null && hash figlet 2>/dev/null; then
|
||||||
echo "${WELCOME_MSG}" | figlet | lolcat
|
echo "${WELCOME_MSG}" | figlet | lolcat
|
||||||
else
|
else
|
||||||
echo "${WELCOME_MSG}"
|
echo -e "$COLOR_P${WELCOME_MSG}\033[0m\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print system information with neofetch, if it's installed
|
# Print system information with neofetch, if it's installed
|
||||||
@ -23,4 +38,23 @@ if hash neofetch 2>/dev/null; then
|
|||||||
--memory_display info
|
--memory_display info
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
timeout=0.5
|
||||||
|
|
||||||
|
echo -e "\033[1;34mToday\n------"
|
||||||
|
|
||||||
|
# Print date time
|
||||||
|
echo -e "$COLOR_S$(date '+🗓️ Date: %A, %B %d, %Y at %H:%M') \033[0m"
|
||||||
|
|
||||||
|
# Print local weather
|
||||||
|
echo -en $COLOR_S
|
||||||
|
curl -s -m $timeout "wttr.in?format=%cWeather:+%C+%t,+%p+%w"
|
||||||
|
echo -e "\033[0m"
|
||||||
|
|
||||||
|
# Print IP address
|
||||||
|
ip_address=$(ip route get 8.8.8.8 | awk -F"src " 'NR==1{split($2,a," ");print a[1]}')
|
||||||
|
ip_interface=$(ip route get 8.8.8.8 | awk -F"dev " 'NR==1{split($2,a," ");print a[1]}')
|
||||||
|
echo -en "$COLOR_S🌐 IP: "
|
||||||
|
curl -s -m $timeout "https://ipinfo.io/ip"
|
||||||
|
echo -en " (${ip_address} on ${ip_interface})\033[0m\n"
|
||||||
|
|
||||||
# EOF
|
# EOF
|
||||||
|
Loading…
Reference in New Issue
Block a user