67 lines
1.7 KiB
Bash
Executable file
67 lines
1.7 KiB
Bash
Executable file
#!/bin/sh
|
||
# Samæ (ↄ) 2016 - Public domain
|
||
|
||
# Monitors are placed in
|
||
MONITORD="/tmp/monitors"
|
||
#MONITORLIST="battery mail room volume wireless xmonad cpu"
|
||
MONITORLIST="xmonad"
|
||
|
||
battery() {
|
||
#echo "$(cat $MONITORD/battery) %"
|
||
cat /sys/class/power_supply/BAT0/capacity
|
||
}
|
||
|
||
clock() {
|
||
date '+%A %d %B %H:%M %Z'
|
||
}
|
||
|
||
mail() {
|
||
sed 's/0/None/' < "$MONITORD/mail"
|
||
}
|
||
|
||
cpu() {
|
||
echo "$(cat $MONITORD/cpu) %"
|
||
}
|
||
|
||
room() {
|
||
echo "$(cat $MONITORD/room) %"
|
||
}
|
||
|
||
volume() {
|
||
sed 's/-1 %/Mute/' <<< "$(cat $MONITORD/volume) %"
|
||
}
|
||
|
||
wireless() {
|
||
cat "$MONITORD/wireless"
|
||
}
|
||
|
||
xmonad() {
|
||
cat "$MONITORD/xmonad"
|
||
}
|
||
|
||
# Loop foreva; wait for events.
|
||
while :; do
|
||
buf="%{S0}"
|
||
buf="${buf} $(xmonad) "
|
||
buf="${buf}%{r}"
|
||
#buf="${buf} %{+u}CPU:%{-u} %{F#EEE8D5}$(cpu) %{F-} "
|
||
#buf="${buf} %{+u}WFI:%{-u} %{F#EEE8D5}$(wireless) %{F-} "
|
||
#buf="${buf} %{+u}CRL:%{-u} %{F#EEE8D5}$(mail) %{F-} "
|
||
#buf="${buf} %{+u}OQP:%{-u} %{F#EEE8D5}$(room) %{F-} "
|
||
#buf="${buf} %{+u}VPN:%{-u} %{F#EEE8D5}$(network) %{F-} "
|
||
#buf="${buf} %{+u}RAM:%{-u} %{F#EEE8D5}$(memused) % %{F-} "
|
||
#buf="${buf} %{+u}MPD:%{-u} %{F#EEE8D5}$(nowplaying) %{F-} "
|
||
#buf="${buf} %{+u}VOL:%{-u} %{F#EEE8D5}$(volume) %{F-} "
|
||
buf="${buf} %{+u}FUEL:%{-u} %{F#EEE8D5}$(battery) %{F-} "
|
||
buf="${buf} %{F#6C71C4}$(clock) %{F-}"
|
||
|
||
echo $buf
|
||
|
||
cd ${MONITORD}
|
||
inotifywait -q -q -e create,modify ${MONITORLIST}
|
||
|
||
# Ugly hack to prevent reading the monitor file to early (thus catching it
|
||
# while it is empty ^^) Waiting time is set to approximatively 1/27 of a
|
||
# second ie a frame at 27fps, so that it doesn't introduce a feeling of lag
|
||
sleep 0.03s
|
||
done
|