summaryrefslogtreecommitdiff
path: root/dotfiles/system/.config/sway/config.d/swaybar.sh
diff options
context:
space:
mode:
Diffstat (limited to 'dotfiles/system/.config/sway/config.d/swaybar.sh')
-rwxr-xr-xdotfiles/system/.config/sway/config.d/swaybar.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/dotfiles/system/.config/sway/config.d/swaybar.sh b/dotfiles/system/.config/sway/config.d/swaybar.sh
new file mode 100755
index 0000000..fe0771d
--- /dev/null
+++ b/dotfiles/system/.config/sway/config.d/swaybar.sh
@@ -0,0 +1,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"