#!/usr/bin/env fish function update set -x text if test -f /tmp/recording.pid set text $text "πŸŽ₯" end # mpd if which mpc 1>/dev/null 2>&1 set music (mpc) if string match -r playing "$music[2]" 1>/dev/null 2>&1 set text $text "♬ $music[1]" end end # volume set vol (amixer get Master) if string match -r '\[off\]' "$vol" set text $text "πŸ”‰ 0" else set v (string match -r '\[(\d+)%\]' $vol | tail -n 1) set text $text "πŸ”Š $v" end # network for nic in (ls -d /sys/class/net/e*) if grep up $nic/operstate > /dev/null set speed (cat $nic/speed)M set text $text "πŸ–§ $speed" end end set wifi (grep "^\s*w" /proc/net/wireless | awk '{ print int($3 * 100 / 70) "%" }') if test -n "$wifi" set text $text "πŸ“‘ $wifi" end # memory set memory (free | awk '/^Mem:/ {print $3 "/" $2 "*" 100}' | math -s0) set text $text "πŸ“ˆ $memory%" # cpu set cpu (sensors | awk '/Core /{print $3}' | sort -r | head -n 1) if test -n "$cpu" set text $text "🌑 $cpu" end # battery set battery (cat /sys/class/power_supply/BAT0/capacity 2>/dev/null || echo "-1") if test "$battery" -gt -1 set plugged (cat /sys/class/power_supply/AC/online) if test "$plugged" -eq 1 set battery "πŸ”Œ $battery%" else set battery "πŸ”‹ $battery%" #if test $battery -gt 90 #set battery " $battery%" #else if test $battery -gt 75 #set battery " $battery%" #else if test $battery -gt 50 #set battery " $battery%" #else if test $battery -gt 25 #set battery " $battery%" #else #set battery " $battery%" #end end set text $text "$battery" end # | sed 's/Mon/δΈ€/; s/Tue/二/; s/Wed/δΈ‰/; s/Thu/ε››/; s/Fri/δΊ”/; s/Sat/ε…­/; s/Sun/ζ—₯/;' set dt (date +"%m-%d %H:%M %a") set text $text "⏲ $dt" set text (string join ' ' $text) xsetroot -name " $text " # prevent screen-saver when there is ongoing zoom metting if xdotool search --name '^Zoom Meeting ID:' xset s reset end end function loop while true update sleep 1 end end function start set script (status -f) $script loop & end function restart pkill -f 'dwmbar loop' start end switch "$argv[1]" case "update" update case "loop" loop case "start" start case "*" restart end