2020-05-09 14:08:47 +02:00
|
|
|
#!/bin/bash
|
2020-09-06 14:03:40 +02:00
|
|
|
print_weather() {
|
|
|
|
[ "$(stat -c %y "/home/yorune/.config/weatherreport" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] && curl -s "wttr.in/$location" > "/home/yorune/.config/weatherreport"
|
2020-05-09 14:08:47 +02:00
|
|
|
|
2020-05-18 17:04:01 +02:00
|
|
|
printf "%s " "$(sed '16q;d' "/home/yorune/.config/weatherreport" | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/☔ /g" | tr -d '\n')" && sed '13q;d' "/home/yorune/.config/weatherreport" | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄",$1 "°","☀",$2 "°"}'
|
2020-05-09 14:08:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print_volume() {
|
2020-05-18 17:04:01 +02:00
|
|
|
[ "$(pulsemixer --get-mute)" = "1" ] && printf "🔇" && exit
|
2020-05-09 14:08:47 +02:00
|
|
|
vol=$(pulsemixer --get-volume | awk '{print $1}')
|
2020-05-18 17:04:01 +02:00
|
|
|
printf "%s%%\\n" "🔊 $vol"
|
2020-05-09 14:08:47 +02:00
|
|
|
}
|
|
|
|
|
2020-09-06 14:03:40 +02:00
|
|
|
print_wifi(){
|
2021-01-22 08:49:44 +01:00
|
|
|
#[ "$(stat -c %y "/home/yorune/.config/vpn" 3>/dev/null | egrep -o '[0-9]+\-[0-9]+\-[0-9]+ [0-9]+')" != "$(date '+%Y-%m-%d %H')" ] && sudo /root/.local/bin/protonvpn status | grep -i Status | awk {'print $2'} > "/home/yorune/.config/vpn"
|
2020-05-09 14:08:47 +02:00
|
|
|
|
2020-09-09 23:00:20 +02:00
|
|
|
echo -e "$(cat /sys/class/net/w*/operstate | sed "s/down/❌/;s/up/📶/") $(cat /sys/class/net/e*/operstate | sed "s/down/❌/;s/up/🌐/")"
|
|
|
|
#echo -e "$(cat /sys/class/net/w*/operstate | sed "s/down/❌/;s/up/📶/") $(cat /sys/class/net/e*/operstate | sed "s/down/❌/;s/up/🌐/") $(cat /home/yorune/.config/vpn | sed 's/Connected/🌐/g;s/Disconnected/❌/g')"
|
2020-05-09 14:08:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
print_temp(){
|
2021-01-22 08:49:44 +01:00
|
|
|
echo -e "🔥 $(sensors | awk '/Core 0/ {print int($3)"°C"}') $(sudo nvidia-smi -q -d temperature | grep --color=no -i "GPU Current" |egrep --color=no -o '[0-9]*')°C"
|
2020-05-09 14:08:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
print_date(){
|
2020-11-05 23:58:06 +01:00
|
|
|
echo -e "🕛 $(date +"%d/%m %H:%M")"
|
2020-05-09 14:08:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
print_mem(){
|
2020-05-27 00:03:35 +02:00
|
|
|
free --mebi | sed -n '2{p;q}' | awk '{printf ("🧠 %2.2fGiB", ( $3 / 1024) )}'
|
2020-05-09 14:08:47 +02:00
|
|
|
}
|
|
|
|
|
2021-01-22 08:49:44 +01:00
|
|
|
print_music(){
|
|
|
|
# Source: https://github.com/joestandring/dwm-bar
|
|
|
|
# A dwm_bar function that shows the current artist, track, position, duration, and status from cmus
|
|
|
|
# Joe Standring <git@joestandring.com>
|
|
|
|
# GNU GPLv3
|
|
|
|
# Dependencies: cmus
|
|
|
|
|
|
|
|
if ps -C cmus > /dev/null; then
|
|
|
|
ARTIST=$(cmus-remote -Q | grep -a '^tag artist' | awk '{gsub("tag artist ", "");print}')
|
|
|
|
TRACK=$(cmus-remote -Q | grep -a '^tag title' | awk '{gsub("tag title ", "");print}')
|
|
|
|
POSITION=$(cmus-remote -Q | grep -a '^position' | awk '{gsub("position ", "");print}')
|
|
|
|
DURATION=$(cmus-remote -Q | grep -a '^duration' | awk '{gsub("duration ", "");print}')
|
|
|
|
STATUS=$(cmus-remote -Q | grep -a '^status' | awk '{gsub("status ", "");print}')
|
|
|
|
SHUFFLE=$(cmus-remote -Q | grep -a '^set shuffle' | awk '{gsub("set shuffle ", "");print}')
|
|
|
|
|
|
|
|
if [ "$STATUS" = "playing" ]; then
|
|
|
|
STATUS="▶"
|
|
|
|
else
|
|
|
|
STATUS="⏸"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#printf "%s%s %s - %s " "$STATUS" "$ARTIST" "$TRACK"
|
|
|
|
printf "%s" "$STATUS"
|
|
|
|
#printf "%0d:%02d/" $((POSITION%3600/60)) $((POSITION%60))
|
|
|
|
#printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60))
|
|
|
|
#printf "%s\n"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-05-27 00:03:35 +02:00
|
|
|
print_battery() {
|
2020-05-09 14:08:47 +02:00
|
|
|
# Find the battery level
|
|
|
|
hash acpi || return 0
|
|
|
|
onl="$(acpi -V | grep "on-line")"
|
|
|
|
charge="$(cat /sys/class/power_supply/BAT*/capacity)"
|
|
|
|
time="$(awk '{print $5}' <(acpi))"
|
|
|
|
|
|
|
|
# Determine battery glyph by percentage range
|
|
|
|
if [[ -z $onl && ${charge} -gt 80 ]]; then
|
2020-05-18 17:04:01 +02:00
|
|
|
echo -e "🔋 ${charge}% ${time}"
|
2020-05-09 14:08:47 +02:00
|
|
|
elif [[ -z $onl && ${charge} -le 80 && ${charge} -gt 60 ]]; then
|
2020-05-18 17:04:01 +02:00
|
|
|
echo -e "🔋 ${charge}% ${time}"
|
2020-05-09 14:08:47 +02:00
|
|
|
elif [[ -z $onl && ${charge} -le 60 && ${charge} -gt 40 ]]; then
|
2020-05-18 17:04:01 +02:00
|
|
|
echo -e "🔋 ${charge}% ${time}"
|
2020-05-09 14:08:47 +02:00
|
|
|
elif [[ -z $onl && ${charge} -le 40 && ${charge} -gt 20 ]]; then
|
2020-05-18 17:04:01 +02:00
|
|
|
echo -e "🔋 ${charge}% ${time}"
|
2020-05-09 14:08:47 +02:00
|
|
|
elif [[ -z $onl && ${charge} -le 20 ]]; then
|
2020-05-18 17:04:01 +02:00
|
|
|
echo -e "❗🔋 ${charge}% ${time}"
|
2020-05-09 14:08:47 +02:00
|
|
|
# If charging, use animated glyph
|
|
|
|
else
|
2020-05-18 17:04:01 +02:00
|
|
|
echo -e "🔌"
|
2020-05-09 14:08:47 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-05-18 17:04:01 +02:00
|
|
|
print_mail(){
|
|
|
|
unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f | wc -l 2>/dev/null)"
|
|
|
|
icon="$(cat "/tmp/imapsyncicon_$USER" 2>/dev/null)"
|
2020-11-07 20:26:35 +01:00
|
|
|
[ "$unread" = "1" ] && [ "$icon" = "" ] || echo "📬 $unread$icon"
|
2020-05-18 17:04:01 +02:00
|
|
|
}
|
2020-05-09 14:08:47 +02:00
|
|
|
|
2020-05-18 17:04:01 +02:00
|
|
|
print_cpu() {
|
2020-10-14 00:35:04 +02:00
|
|
|
cpuUse=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print int(100 - $1)"%"}')
|
2020-05-18 17:04:01 +02:00
|
|
|
echo -e "💻 $cpuUse"
|
2020-05-09 14:08:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
while true
|
|
|
|
do
|
2021-01-22 08:49:44 +01:00
|
|
|
xsetroot -name "$(print_music) $(print_temp) $(print_mail) $(print_cpu) $(print_mem) $(print_wifi) $(print_battery) $(print_volume) $(print_date)"
|
2020-11-05 23:58:06 +01:00
|
|
|
sleep 2
|
2020-05-09 14:08:47 +02:00
|
|
|
done
|