#!/bin/sh # symbola #export ICON_RCD=šŸŽ„ #export ICON_MSC=ā™¬ #export ICON_MTD=šŸ”‰ #export ICON_VOL=šŸ”Š #export ICON_NIC=šŸ–§ #export ICON_WFI=šŸ“” #export ICON_MEM=šŸ“ˆ #export ICON_TMP=šŸŒ” #export ICON_PLG=šŸ”Œ #export ICON_BAT=šŸ”‹ #export ICON_DAT=ā² # nerdfont export ICON_RCD='ļ©¦' export ICON_MSC='ļ¢†' export ICON_MTD='ļ± ' export ICON_VOL='ļ’… ' export ICON_NIC='ļ›æ ' export ICON_WFI='ļ‡« ' export ICON_MEM='ļ‹› ' export ICON_TMP='ļ‹‰' export ICON_PLG='ļ‡¦ ' export ICON_BA0='ļ‰„ ' export ICON_BA1='ļ‰ƒ ' export ICON_BA2='ļ‰‚ ' export ICON_BA3='ļ‰ ' export ICON_BA4='ļ‰€ ' export ICON_DAT='ļ€— ' MPD=$(which mpc && echo yes) statusbar() { echo -n " " # recording [ -f /tmp/recording.pid ] && echo -n "$ICON_RCD " # mpd [ -n "$MPD" ] && mpc | awk ' NR == 1 { SONG = $0 } NR == 2 { PLAYING = $1 } END { if (PLAYING == "[playing]") printf "%s %s ", ENVIRON["ICON_MSC"], SONG } ' # volume amixer get Master | awk 'END { ICO = $NF == "[off]" ? ENVIRON["ICON_MTD"] : ENVIRON["ICON_VOL"] match($0, / \[([0-9]+%)\] /, m) VOL = m[1] printf "%s %s ", ICO, VOL }' # network for NIC in /sys/class/net/e*; do grep -q 'up' $NIC/operstate && awk '{ printf "%s %s ",ENVIRON["ICON_NIC"],($0 >= 1000 ? $0 / 1000 "G" : $0 "M") }' $NIC/speed done # wifi awk 'NR > 2 { printf "%s %i%% ", ENVIRON["ICON_WFI"], $3*100/70 }' /proc/net/wireless # cpu temperature awk '{ printf "%s %iĀ°C ", ENVIRON["ICON_TMP"], $0/1000 }' /sys/class/thermal/thermal_zone0/temp # memory usage free | awk 'NR == 2 { printf "%s %i%% ", ENVIRON["ICON_MEM"], $3/$2*100 }' # battery if [ -f /sys/class/power_supply/BAT0/capacity ]; then grep -q '1' /sys/class/power_supply/AC/online && export PLUGGED=yes awk '{ if (ENVIRON["PLUGGED"] == "yes") ICON=ENVIRON["ICON_PLG"] else if ($0 > 90) ICON=ENVIRON["ICON_BA4"] else if ($0 > 75) ICON=ENVIRON["ICON_BA3"] else if ($0 > 50) ICON=ENVIRON["ICON_BA2"] else if ($0 > 25) ICON=ENVIRON["ICON_BA1"] else ICON=ENVIRON["ICON_BA0"] printf "%s %s%% ", ICON, $0 }' /sys/class/power_supply/BAT0/capacity fi # datetime echo -n "$ICON_DAT $(date +'%m-%d %H:%M %a') " } start() { while :; do ! pgrep slock 1>/dev/null && xsetroot -name "$(statusbar)" sleep 1 done } restart() { FP=$(readlink -f $0) pkill -f "$FP loop" $FP loop & } case "$1" in loop) start ;; dryrun) statusbar ;; *) restart ;; esac