summaryrefslogtreecommitdiff
path: root/home-config/waybar
diff options
context:
space:
mode:
Diffstat (limited to 'home-config/waybar')
-rw-r--r--home-config/waybar/config116
-rwxr-xr-xhome-config/waybar/modules/spotify.sh19
-rwxr-xr-xhome-config/waybar/modules/storage.sh25
-rwxr-xr-xhome-config/waybar/modules/weather.sh77
-rw-r--r--home-config/waybar/style.css77
5 files changed, 314 insertions, 0 deletions
diff --git a/home-config/waybar/config b/home-config/waybar/config
new file mode 100644
index 0000000..10e27c7
--- /dev/null
+++ b/home-config/waybar/config
@@ -0,0 +1,116 @@
1{
2 "layer": "bottom",
3 "position": "top",
4 "height": 30,
5
6 "modules-left": ["sway/workspaces", "sway/mode"],
7 "modules-center": ["sway/window"],
8 "modules-right": ["tray", "custom/spotify", "custom/weather", "custom/mail", "custom/storage", "backlight", "pulseaudio", "network", "idle_inhibitor", "battery", "clock"],
9 "sway/mode": {
10 "format": " {}"
11 },
12 "sway/workspaces": {
13 "format": "{name}",
14 "disable-scroll": true
15 },
16 "sway/window": {
17 "max-length": 80,
18 "tooltip": false
19 },
20 "clock": {
21 "format": "{:%a %d %b %H:%M}",
22 "tooltip": false
23 },
24 "battery": {
25 "format": "{capacity}% {icon}",
26 "format-alt": "{time} {icon}",
27 "format-icons": ["", "", "", "", ""],
28 "format-charging": "{capacity}% ",
29 "interval": 30,
30 "states": {
31 "warning": 25,
32 "critical": 10
33 },
34 "tooltip": false,
35 "bat":"BAT1"
36 },
37 "network": {
38 "format-alt": "{icon}",
39 "format": "{ipaddr}/{cidr} {icon}",
40 "format-alt-click": "click-right",
41 "format-icons": {
42 "wifi": ["", "" ,""],
43 "ethernet": [""],
44 "disconnected": ["睊"]
45 },
46 "on-click": "alacritty -e iwctl",
47 "tooltip": false
48 },
49 "pulseaudio": {
50 "format-alt": "{icon}",
51 "format": "{volume} {icon}",
52 "format-alt-click": "click-right",
53 "format-muted": "",
54 "format-icons": {
55 "phone": [" ", " ", " ", " "],
56 "default": ["", "", "", ""]
57 },
58 "scroll-step": 1,
59 "on-click": "pavucontrol",
60 "tooltip": false
61 },
62 "custom/spotify": {
63 "interval": 2,
64 "return-type": "json",
65 "exec": "~/.config/waybar/modules/spotify.sh",
66 "exec-if": "pgrep spotifyd",
67 "escape": true,
68 "on-click": "~/.config/waybar/modules/spotify-play-pause.sh play-pause"
69 },
70 "custom/storage": {
71 "format-alt": "{} ",
72 "format": "{percentage}% ",
73 "format-alt-click": "click-right",
74 "return-type": "json",
75 "interval": 60,
76 "exec": "~/.config/waybar/modules/storage.sh"
77 },
78 "backlight": {
79 "format-alt": "{icon}",
80 "format": "{percent}% {icon}",
81 "format-alt-click": "click-right",
82 "format-icons": ["", ""],
83 "on-scroll-down": "light -A 1",
84 "on-scroll-up": "light -U 1"
85 },
86 "custom/weather": {
87 "format-alt": "{}",
88 "format": "{alt}: {}",
89 "format-alt-click": "click-right",
90 "interval": 1800,
91 "return-type": "json",
92 "on-click": "alacritty --class ala-wttr --hold -e curl https://v2.wttr.in",
93 "exec": "~/.config/waybar/modules/weather.sh",
94 "exec-if": "ping wttr.in -c1"
95 },
96 "idle_inhibitor": {
97 "format": "{icon}",
98 "format-icons": {
99 "activated": "",
100 "deactivated": ""
101 },
102 "tooltip": false
103 },
104 "custom/mail": {
105 "format": "",
106 "format-alt": "{alt} ",
107 "format-alt-click": "click-right",
108 "interval": 60,
109 "return-type": "json",
110 "exec": "~/.config/waybar/modules/mail.py",
111 "tooltip": false
112 },
113 "tray": {
114 "icon-size": 18
115 }
116}
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]}"\"}"
diff --git a/home-config/waybar/style.css b/home-config/waybar/style.css
new file mode 100644
index 0000000..f785881
--- /dev/null
+++ b/home-config/waybar/style.css
@@ -0,0 +1,77 @@
1* {
2 border: none;
3 border-radius: 0;
4 font-family: Sans;
5 font-size: 15px;
6 box-shadow: none;
7 text-shadow: none;
8 transition-duration: 0s;
9 color: white;
10}
11
12#waybar {
13 background-color:rgba(0,0,0,0.25);
14 color: white;
15}
16
17window {
18 color: rgba(217, 216, 216, 1);
19 background: rgba(35, 31, 32, 0.00);
20}
21
22window#waybar.solo {
23 color: rgba(217, 216, 216, 1);
24 background: rgba(35, 31, 32, 0.85);
25}
26
27#workspaces {
28 margin: 0 5px;
29}
30
31#workspaces button {
32 padding: 0 5px;
33 color: rgba(217, 216, 216, 0.4);
34}
35
36#workspaces button.visible {
37 color: rgba(217, 216, 216, 1);
38}
39
40#workspaces button.focused {
41 border-top: 3px solid rgba(217, 216, 216, 1);
42 border-bottom: 3px solid rgba(217, 216, 216, 0);
43}
44
45#workspaces button.urgent {
46 color: rgba(238, 46, 36, 1);
47}
48
49#mode, #battery, #cpu, #memory, #network, #pulseaudio, #idle_inhibitor, #backlight, #custom-storage, #custom-spotify, #custom-weather, #custom-mail {
50 margin: 0px 6px 0px 10px;
51 min-width: 25px;
52}
53
54#clock {
55 margin: 0px 16px 0px 10px;
56 min-width: 140px;
57}
58
59#battery.warning {
60 color: rgba(255, 210, 4, 1);
61}
62
63#battery.critical {
64 color: rgba(238, 46, 36, 1);
65}
66
67#battery.charging {
68 color: rgba(217, 216, 216, 1);
69}
70
71#custom-storage.warning {
72 color: rgba(255, 210, 4, 1);
73}
74
75#custom-storage.critical {
76 color: rgba(238, 46, 36, 1);
77}