aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel <[email protected]>2024-11-11 17:01:15 -0500
committerDaniel <[email protected]>2024-11-11 17:01:15 -0500
commita10ffb59d1901dccf73c560bf8d24936738050d7 (patch)
tree0e830d5eae08e2138afefb831076bf682a15a501
parent30b9f940832ef0f64e4a36d8635b500f70093c01 (diff)
mega status script (all blocks)
-rwxr-xr-xbin/.local/bin/scripts/status/all152
1 files changed, 152 insertions, 0 deletions
diff --git a/bin/.local/bin/scripts/status/all b/bin/.local/bin/scripts/status/all
new file mode 100755
index 0000000..22ca92e
--- /dev/null
+++ b/bin/.local/bin/scripts/status/all
@@ -0,0 +1,152 @@
+#!/bin/bash
+
+#### WEATHER
+url="${WTTRURL:-wttr.in}"
+weatherreport="${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport"
+
+getforecast() { curl -sf "$url/Louisville?M" > "$weatherreport" || exit 1; }
+
+checkforecast() {
+ [ -s "$weatherreport" ] && [ "$(stat -c %y "$weatherreport" 2>/dev/null |
+ cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ]
+}
+
+getprecipchance() {
+ echo "$weatherdata" | sed '16q;d' |
+ grep -wo "[0-9]*%" |
+ sort -rn |
+ head -1q
+}
+
+getdailyhighlow() {
+ echo "$weatherdata" | sed '13q;d' |
+ grep -o "m\\([-+]\\)*[0-9]\\+" |
+ sed 's/[+m]//g' |
+ sort -g |
+ sed -e 1b -e '$!d'
+}
+
+readfile() { weatherdata="$(cat "$weatherreport")" ;}
+
+showweather() {
+ checkforecast || getforecast
+ readfile
+ printf "β˜”%s πŸ₯Ά%sΒ°C 🌞%sΒ°C" "$(getprecipchance)" $(getdailyhighlow)
+}
+
+#### CLOCK
+clock=$(date '+%I')
+
+case "$clock" in
+ "00") clockicon="πŸ•›" ;;
+ "01") clockicon="πŸ•" ;;
+ "02") clockicon="πŸ•‘" ;;
+ "03") clockicon="πŸ•’" ;;
+ "04") clockicon="πŸ•“" ;;
+ "05") clockicon="πŸ•”" ;;
+ "06") clockicon="πŸ••" ;;
+ "07") clockicon="πŸ•–" ;;
+ "08") clockicon="πŸ•—" ;;
+ "09") clockicon="πŸ•˜" ;;
+ "10") clockicon="πŸ•™" ;;
+ "11") clockicon="πŸ•š" ;;
+ "12") clockicon="πŸ•›" ;;
+esac
+
+calendar_icon="πŸ“…"
+
+showclock () {
+ printf "%s" $(date "+$calendar_icon %Y-%m-%d (%a) $clockicon %R:%S")
+}
+
+#### BATTERY
+showbattery () {
+ for battery in /sys/class/power_supply/BAT?*; do
+ [ -n "${capacity+x}" ] && printf " "
+ case "$(cat "$battery/status" 2>&1)" in
+ "Full") status="⚑" ;;
+ "Discharging") status="πŸ”‹" ;;
+ "Charging") status="πŸ”Œ" ;;
+ "Not charging") status="πŸ›‘" ;;
+ "Unknown") status="♻️" ;;
+ *) exit 1 ;;
+ esac
+ capacity="$(cat "$battery/capacity" 2>&1)"
+ [ "$status" = "πŸ”‹" ] && [ "$capacity" -le 25 ] && warn="❗"
+ printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn
+ done
+}
+
+#### NETWORK
+# Wifi
+if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ] ; then
+ wifiicon="$(awk '/^\s*w/ { print "πŸ“Ά", int($3 * 100 / 70) "% " }' /proc/net/wireless)"
+elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ] ; then
+ [ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon="πŸ“‘ " || wifiicon="❌ "
+fi
+
+# Ethernet
+[ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon="🌐" || ethericon="❎"
+
+# TUN
+[ -n "$(cat /sys/class/net/tun*/operstate 2>/dev/null)" ] && tunicon=" πŸ”’"
+
+shownetwork() {
+ printf "%s%s%s" "$wifiicon" "$ethericon" "$tunicon"
+}
+
+#### MUSIC
+
+truncate() {
+ echo "$1" | cut -c1-15
+}
+
+# Get current track info
+artist="$(playerctl metadata artist 2>/dev/null || echo "none")"
+title="$(playerctl metadata title 2>/dev/null || echo "none")"
+
+# Truncate artist and title to 15 characters
+truncated_artist=$(truncate "$artist")
+truncated_title=$(truncate "$title")
+
+# Format the output as "artist - title"
+current_track="$truncated_artist - $truncated_title"
+
+playerstatus=$(playerctl status)
+
+case "$playerstatus" in
+ "Playing") playericon="🎡" ;;
+ "Paused") playericon="⏸️" ;;
+ "Stopped") playericon="⏹️" ;;
+ "*") playericon="" ;;
+esac
+
+# Print the current track
+showmusic () {
+ echo "$playericon $current_track"
+}
+
+#### MEMORY
+showmemory () {
+ free --mebi | sed -n '2{p;q}' | awk '{printf ("🧠%2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}'
+}
+
+#### VOLUME
+
+mutestatus="pactl list sinks | grep -q 'Mute: yes' && echo $?"
+
+case "$mutestatus" in
+ 0)
+ soundicon="πŸ”Š" ;;
+ *)
+ soundicon="πŸ”‡" ;;
+esac
+
+showvolume() {
+ volumeInput=$(pactl list sinks)
+ currentVolume=$(echo "${volumeInput#*Sink #$sinkNumber}" | grep -E 'V.*-left' | grep -oE '[0-9]+%' | tail -n 1)
+ printf "%s %s" $soundicon $currentVolume
+}
+
+#### CONCATENATION
+echo -e $(showmemory) "|" $(showweather) "|" $(shownetwork) "|" $(showmusic) "|" $(showvolume) "|" $(showbattery) "|" $(showclock)