blob: fe0771da61182dc6cf155cfb4168b35c53b30a50 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#!/bin/sh
# Get the formatted date and time
datetime=$(date "+%a %b %-d, %Y %-l:%M %p %Z")
# Get battery percentage
battery=$(sysctl -n hw.acpi.battery.life 2>/dev/null)
# Handle battery icon
if [ -z "$battery" ]; then
battery="?"
battery_icon="" # Unknown
else
if [ "$battery" -ge 90 ]; then
battery_icon=""
elif [ "$battery" -ge 60 ]; then
battery_icon=""
elif [ "$battery" -ge 30 ]; then
battery_icon=""
elif [ "$battery" -ge 10 ]; then
battery_icon=""
else
battery_icon=""
fi
fi
# Get connected Wi-Fi SSID (for FreeBSD)
# Use ifconfig to get the SSID of wlan0 (adjust if different interface name)
wifi_ssid=$(ifconfig wlan0 2>/dev/null | awk '/ssid/ {print $2}' | head -n 1)
# Only show Wi-Fi if connected
if [ -n "$wifi_ssid" ]; then
wifi_output=" $wifi_ssid"
else
wifi_output=""
fi
# Build final output
output=""
[ -n "$wifi_output" ] && output="$wifi_output | "
output="$output$battery_icon $battery% | $datetime"
# Output the result
echo "$output"
|