Skip to content

Commit 938f74e

Browse files
welcome
1 parent dfd6609 commit 938f74e

File tree

1 file changed

+194
-0
lines changed
  • src/devcontainers/base/src/.devcontainer/nhsnotify

1 file changed

+194
-0
lines changed

src/devcontainers/base/src/.devcontainer/nhsnotify/welcome.sh

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22

3+
# Configuration
4+
WEATHER_LOCATION="Leeds, UK" # Change this to any location
5+
36
# Colors
47
RED='\033[0;31m'
58
GREEN='\033[0;32m'
@@ -37,6 +40,191 @@ animate_border() {
3740
echo
3841
}
3942

43+
# Function to get weather and display ASCII art
44+
show_weather() {
45+
local location="${WEATHER_LOCATION}"
46+
echo -e "${CYAN}${BOLD}🌍 Weather in ${location}${NC}"
47+
48+
# First, geocode the location to get lat/lon using Nominatim (free OpenStreetMap service)
49+
local encoded_location=$(echo "$location" | sed 's/ /%20/g')
50+
local geo_data=$(curl -s --max-time 3 "https://nominatim.openstreetmap.org/search?q=${encoded_location}&format=json&limit=1" 2>/dev/null)
51+
52+
local latitude=""
53+
local longitude=""
54+
55+
if [ -n "$geo_data" ] && echo "$geo_data" | grep -q "lat"; then
56+
latitude=$(echo "$geo_data" | grep -oE '"lat":"[0-9.-]+"' | head -1 | cut -d'"' -f4)
57+
longitude=$(echo "$geo_data" | grep -oE '"lon":"[0-9.-]+"' | head -1 | cut -d'"' -f4)
58+
fi
59+
60+
# Fallback to Leeds coordinates if geocoding fails
61+
if [ -z "$latitude" ] || [ -z "$longitude" ]; then
62+
latitude="53.8008"
63+
longitude="-1.5491"
64+
fi
65+
66+
# Use open-meteo.com (free, no API key required)
67+
local weather_data=$(curl -s --max-time 3 "https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&current_weather=true" 2>/dev/null)
68+
69+
if [ -n "$weather_data" ] && echo "$weather_data" | grep -q "current_weather"; then
70+
# Parse temperature, weather code, wind speed and direction (handle decimal numbers)
71+
local temp=$(echo "$weather_data" | grep -oE '"temperature":[0-9.-]+' | head -1 | cut -d':' -f2)
72+
local weathercode=$(echo "$weather_data" | grep -oE '"weathercode":[0-9]+' | tail -1 | cut -d':' -f2)
73+
local windspeed=$(echo "$weather_data" | grep -oE '"windspeed":[0-9.-]+' | tail -1 | cut -d':' -f2)
74+
local winddirection=$(echo "$weather_data" | grep -oE '"winddirection":[0-9.-]+' | tail -1 | cut -d':' -f2)
75+
76+
# Round temperature and wind speed
77+
temp=$(printf "%.0f" "$temp" 2>/dev/null || echo "$temp")
78+
windspeed=$(printf "%.0f" "$windspeed" 2>/dev/null || echo "$windspeed")
79+
80+
# Convert wind direction to compass direction
81+
local wind_dir=""
82+
if [ -n "$winddirection" ]; then
83+
local dir=$(printf "%.0f" "$winddirection" 2>/dev/null)
84+
if [ $dir -ge 337 ] || [ $dir -lt 23 ]; then
85+
wind_dir="N"
86+
elif [ $dir -ge 23 ] && [ $dir -lt 68 ]; then
87+
wind_dir="NE"
88+
elif [ $dir -ge 68 ] && [ $dir -lt 113 ]; then
89+
wind_dir="E"
90+
elif [ $dir -ge 113 ] && [ $dir -lt 158 ]; then
91+
wind_dir="SE"
92+
elif [ $dir -ge 158 ] && [ $dir -lt 203 ]; then
93+
wind_dir="S"
94+
elif [ $dir -ge 203 ] && [ $dir -lt 248 ]; then
95+
wind_dir="SW"
96+
elif [ $dir -ge 248 ] && [ $dir -lt 293 ]; then
97+
wind_dir="W"
98+
elif [ $dir -ge 293 ] && [ $dir -lt 337 ]; then
99+
wind_dir="NW"
100+
fi
101+
fi
102+
103+
# WMO Weather interpretation codes
104+
# 0: Clear sky, 1-3: Mainly clear/partly cloudy/overcast
105+
# 45,48: Fog, 51-57: Drizzle, 61-67: Rain, 71-77: Snow
106+
# 80-82: Rain showers, 85-86: Snow showers, 95-99: Thunderstorm
107+
108+
case "$weathercode" in
109+
0)
110+
# Clear sky
111+
echo -e "${YELLOW}"
112+
echo " \\ / "
113+
echo " .-. "
114+
echo " ― ( ) ― "
115+
echo " \`-' "
116+
echo " / \\ "
117+
condition="Clear"
118+
;;
119+
1|2|3)
120+
# Mainly clear to overcast
121+
echo -e "${WHITE}"
122+
echo " "
123+
echo " .--. "
124+
echo " .-( ). "
125+
echo " (___.__)__) "
126+
echo " "
127+
condition="Cloudy"
128+
;;
129+
45|48)
130+
# Fog
131+
echo -e "${WHITE}"
132+
echo " "
133+
echo " _ - _ - _ - "
134+
echo " _ - _ - _ "
135+
echo " _ - _ - _ - "
136+
echo " "
137+
condition="Foggy"
138+
;;
139+
51|53|55|56|57|61|63|65|66|67|80|81|82)
140+
# Rain/Drizzle
141+
echo -e "${BLUE}"
142+
echo " .-. "
143+
echo " ( ). "
144+
echo " (___(__) "
145+
echo " ʻ ʻ ʻ ʻ "
146+
echo " ʻ ʻ ʻ ʻ "
147+
condition="Rainy"
148+
;;
149+
71|73|75|77|85|86)
150+
# Snow
151+
echo -e "${WHITE}"
152+
echo " .-. "
153+
echo " ( ). "
154+
echo " (___(__) "
155+
echo " * * * "
156+
echo " * * * "
157+
condition="Snowy"
158+
;;
159+
95|96|99)
160+
# Thunderstorm
161+
echo -e "${YELLOW}"
162+
echo " .-. "
163+
echo " ( ). "
164+
echo " (___(__) "
165+
echo " ⚡ ʻ ⚡ "
166+
echo " ʻ ⚡ ʻ "
167+
condition="Stormy"
168+
;;
169+
*)
170+
# Default
171+
echo -e "${CYAN}"
172+
echo " .-. "
173+
echo " ( ). "
174+
echo " (___(__) "
175+
echo " "
176+
condition="Unknown"
177+
;;
178+
esac
179+
echo -e "${NC}"
180+
echo -e "${WHITE}${condition} ${temp}°C${NC}"
181+
if [ -n "$windspeed" ] && [ -n "$wind_dir" ]; then
182+
echo -e "${CYAN}💨 Wind: ${windspeed} km/h ${wind_dir}${NC}"
183+
fi
184+
else
185+
# Fallback - show a nice cloudy Leeds default (it's usually cloudy there! 😄)
186+
echo -e "${WHITE}"
187+
echo " "
188+
echo " .--. "
189+
echo " .-( ). "
190+
echo " (___.__)__) "
191+
echo " "
192+
echo -e "${NC}"
193+
echo -e "${CYAN}Typical Leeds weather ☁️ (API unavailable)${NC}"
194+
fi
195+
echo
196+
}
197+
198+
# Function to show NHS Notify mascot - a messenger pigeon!
199+
show_mascot() {
200+
local mascots=(
201+
# Pigeon with letter
202+
"${CYAN}
203+
__
204+
___( o)> NHS Notify Messenger!
205+
\\ <_. ) Delivering notifications
206+
\`---' at the speed of flight! 📬
207+
"
208+
# Pigeon sitting
209+
"${BLUE}
210+
(o>
211+
__//\\\\__ Ready to send those
212+
\`-|_|-' important messages! 🕊️
213+
"
214+
# Pigeon with NHS badge
215+
"${PURPLE}
216+
___
217+
(o o) NHS Notify Pigeon:
218+
|)_(| Your trusted notification
219+
'-' delivery service! 💙
220+
"
221+
)
222+
223+
# Pick a random mascot
224+
local random_mascot=${mascots[$RANDOM % ${#mascots[@]}]}
225+
echo -e "${random_mascot}${NC}"
226+
}
227+
40228
# Helper function to count emojis in text
41229
count_emojis() {
42230
local text="$1"
@@ -203,6 +391,9 @@ container_info=(
203391
draw_box "${PURPLE}${BOLD}" "${BOLD}${WHITE}CONTAINER INFORMATION${NC}" 80 "${container_info[@]}"
204392
echo
205393

394+
# Show weather
395+
show_weather
396+
206397
# Feature showcase
207398
echo -e "${GREEN}${BOLD}🚀 READY TO DEVELOP WITH:${NC}"
208399
echo
@@ -264,6 +455,9 @@ random_tip=${dev_tips[$RANDOM % ${#dev_tips[@]}]}
264455
echo -e "${GREEN}${random_tip}${NC}"
265456
echo
266457

458+
# Show NHS Notify mascot
459+
show_mascot
460+
267461
# Quick Commands Reference
268462
echo -e "${PURPLE}${BOLD}⚡ QUICK COMMANDS${NC}"
269463
echo -e "${YELLOW} make help${NC} - Show project-specific commands"

0 commit comments

Comments
 (0)