summaryrefslogtreecommitdiff
path: root/home-config/waybar/modules
diff options
context:
space:
mode:
authorRyan Schanzenbacher <ryan@rschanz.org>2023-05-17 00:21:45 -0400
committerRyan Schanzenbacher <ryan@rschanz.org>2023-05-17 00:21:45 -0400
commitbf6a91943d2c5852025ed1d1aadb30d83edf0354 (patch)
treea7c4efde6a1e2d18919016e9dff81aee8db8f0fe /home-config/waybar/modules
parent4fe3a734d104fa1836255b18f8d8bcf4aeaa407f (diff)
Added personal channel, starting to add more dotfiles
Diffstat (limited to 'home-config/waybar/modules')
-rwxr-xr-xhome-config/waybar/modules/spotify.sh19
-rwxr-xr-xhome-config/waybar/modules/storage.sh25
-rwxr-xr-xhome-config/waybar/modules/weather.sh77
3 files changed, 121 insertions, 0 deletions
diff --git a/home-config/waybar/modules/spotify.sh b/home-config/waybar/modules/spotify.sh
new file mode 100755
index 0000000..a75136c
--- /dev/null
+++ b/home-config/waybar/modules/spotify.sh
@@ -0,0 +1,19 @@
1#!/bin/sh
2
3class=$(playerctl metadata --player=spotifyd --format '{{lc(status)}}')
4icon=""
5
6if [[ $class == "playing" ]]; then
7 info=$(playerctl metadata --player=spotifyd --format '{{artist}} - {{title}}')
8 if [[ ${#info} > 40 ]]; then
9 info=$(echo $info | cut -c1-40)"..."
10 fi
11 text=$info" "$icon
12elif [[ $class == "paused" ]]; then
13 text=$icon
14elif [[ $class == "stopped" ]]; then
15 text=""
16fi
17
18echo -e "{\"text\":\""$text"\", \"class\":\""$class"\"}"
19
diff --git a/home-config/waybar/modules/storage.sh b/home-config/waybar/modules/storage.sh
new file mode 100755
index 0000000..90cc3dc
--- /dev/null
+++ b/home-config/waybar/modules/storage.sh
@@ -0,0 +1,25 @@
1#!/bin/sh
2
3mount="/"
4warning=20
5critical=10
6
7df -h -P -l "$mount" | awk -v warning=$warning -v critical=$critical '
8/\/.*/ {
9 text=$4
10 tooltip="Filesystem: "$1"\rSize: "$2"\rUsed: "$3"\rAvail: "$4"\rUse%: "$5"\rMounted on: "$6
11 use=$5
12 exit 0
13}
14END {
15 class=""
16 gsub(/%$/,"",use)
17 if ((100 - use) < critical) {
18 class="critical"
19 } else if ((100 - use) < warning) {
20 class="warning"
21 }
22 print "{\"text\":\""text"\", \"percentage\":"use",\"tooltip\":\""tooltip"\", \"class\":\""class"\"}"
23}
24'
25
diff --git a/home-config/waybar/modules/weather.sh b/home-config/waybar/modules/weather.sh
new file mode 100755
index 0000000..01faffc
--- /dev/null
+++ b/home-config/waybar/modules/weather.sh
@@ -0,0 +1,77 @@
1cachedir=~/.cache/rbn
2cachefile=${0##*/}-$1
3
4if [ ! -d $cachedir ]; then
5 mkdir -p $cachedir
6fi
7
8if [ ! -f $cachedir/$cachefile ]; then
9 touch $cachedir/$cachefile
10fi
11
12# Save current IFS
13SAVEIFS=$IFS
14# Change IFS to new line.
15IFS=$'\n'
16
17cacheage=$(($(date +%s) - $(stat -c '%Y' "$cachedir/$cachefile")))
18if [ $cacheage -gt 1740 ] || [ ! -s $cachedir/$cachefile ]; then
19 data=($(curl -s https://en.wttr.in/$1\?0qnT 2>&1))
20 echo ${data[0]} | cut -f1 -d, > $cachedir/$cachefile
21 echo ${data[1]} | sed -E 's/^.{15}//' >> $cachedir/$cachefile
22 echo ${data[2]} | sed -E 's/^.{15}//' >> $cachedir/$cachefile
23fi
24
25weather=($(cat $cachedir/$cachefile))
26
27# Restore IFSClear
28IFS=$SAVEIFS
29
30temperature=$(echo ${weather[2]} | sed -E 's/([[:digit:]]+)\.\./\1 to /g')
31
32#echo ${weather[1]##*,}
33
34# https://fontawesome.com/icons?s=solid&c=weather
35case $(echo ${weather[1]##*,} | tr '[:upper:]' '[:lower:]') in
36"clear" | "sunny")
37 condition=""
38 ;;
39"partly cloudy")
40 condition=""
41 ;;
42"cloudy")
43 condition=""
44 ;;
45"overcast")
46 condition=""
47 ;;
48"mist" | "fog" | "freezing fog")
49 condition="敖"
50 ;;
51"patchy rain possible" | "patchy light drizzle" | "light drizzle" | "patchy light rain" | "light rain" | "light rain shower" | "rain")
52 condition="殺"
53 ;;
54"moderate rain at times" | "moderate rain" | "heavy rain at times" | "heavy rain" | "moderate or heavy rain shower" | "torrential rain shower" | "rain shower")
55 condition=""
56 ;;
57"patchy snow possible" | "patchy sleet possible" | "patchy freezing drizzle possible" | "freezing drizzle" | "heavy freezing drizzle" | "light freezing rain" | "moderate or heavy freezing rain" | "light sleet" | "ice pellets" | "light sleet showers" | "moderate or heavy sleet showers")
58 condition="流"
59 ;;
60"blowing snow" | "moderate or heavy sleet" | "patchy light snow" | "light snow" | "light snow showers")
61 condition="ﰕ"
62 ;;
63"blizzard" | "patchy moderate snow" | "moderate snow" | "patchy heavy snow" | "heavy snow" | "moderate or heavy snow with thunder" | "moderate or heavy snow showers")
64 condition=""
65 ;;
66"thundery outbreaks possible" | "patchy light rain with thunder" | "moderate or heavy rain with thunder" | "patchy light snow with thunder")
67 condition=""
68 ;;
69*)
70 condition=""
71 echo -e "{\"text\":\""$condition"\", \"alt\":\""${weather[0]}"\", \"tooltip\":\""${weather[0]}: $temperature ${weather[1]}"\"}"
72 ;;
73esac
74
75#echo $temp $condition
76
77echo -e "{\"text\":\""$temperature $condition"\", \"alt\":\""${weather[0]}"\", \"tooltip\":\""${weather[0]}: $temperature ${weather[1]}"\"}"