blob: e619bf5eb8069f958be5442e1a78191cbb112eeb (
plain) (
blame)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#!/usr/bin/env bash
check_online() {
status=$(curl --silent "http://detectportal.firefox.com/success.txt")
if [ ! "$status" = "success" ]; then exit 1; fi
}
strip_chars() {
tr -d \[\]\(\)%
}
case "$1" in
title)
true
;;
crypto)
check_online
change() { printf "%0.1f" "$(curl --silent --request GET --url "https://api.coincap.io/v2/assets/$1" | jq -r '.data.changePercent24Hr')" ; }
printf " %sN %sM %sX\n" "$(change nexo)" "$(change monero)" "$(change nano)"
;;
backlight)
printf " %s\n" "$(brightnessctl i | awk '/Current/ {print $4}' | strip_chars)"
;;
battery)
status="$(awk -F= '/POWER_SUPPLY_STATUS/ {print $2}' /sys/class/power_supply/BAT0/uevent)"
level="$(awk -F= '/POWER_SUPPLY_CAPACITY=/ {print $2}' /sys/class/power_supply/BAT0/uevent)"
if [ "$status" = "Discharging" ]; then icon=""; else icon=""; fi
printf "%s %s\n" "$icon" "$level"
;;
date)
date=$(date '+%A %eXX %B, %H:%M' | sed -e 's/11XX/11th/' -e 's/12XX/12th/' -e 's/13XX/13th/' -e 's/1XX/1st/' -e 's/2XX/2nd/' -e 's/3XX/3rd/' -e 's/XX/th/' -e 's/ */ /g')
printf " %s\n" "$date"
;;
disk)
printf " %s\n" "$(df / | awk '/dev/ {print $5}' | strip_chars)"
;;
mail)
check_online
mail_server=$(rbw get email --full | awk -F: '/Incoming/ {gsub(/ /,""); print $2}')
mail_password=$(rbw get email)
mail_count=$(curl --silent --netrc-file <(cat <<<"machine $mail_server login $EMAIL password $mail_password") imaps://"$mail_server" -X 'STATUS INBOX (UNSEEN)' | awk -F'[][()]' '{print substr ($2, 8 )}')
printf " %s\n" "$mail_count"
;;
power)
printf "\n"
;;
rss)
check_online
printf " %s\n" "$(curl -Ss "https://rss.$DOMAIN/public.php?op=getUnread&login=admin")"
;;
temperature)
temperature="$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))"
printf " %s\n" "$temperature"
;;
volume)
if [ -z "$(amixer get Master | awk '/off/')" ]; then state=nomute; else state=mute; fi
volume=$(amixer get Master | awk '/%/ {print $4}' | strip_chars)
if [ "$volume" -gt 66 ]
then
icon=""
elif [ "$volume" -gt 33 ]
then
icon=""
else
icon=""
fi
if [ "$state" = "mute" ]; then icon=""; fi
printf "%s %s\n" "$icon" "$volume"
;;
wifi)
printf "\n"
;;
esac
|