#!/bin/sh ### Created by Amdac @ www.amdac.net ### This script was written to populate the status bar in spectrwm ### Requires the associated volume script vol() { sound=$(amixer get -M Master | awk '/%/ {print $6}') if [ $sound = "[off]" ]; then echo "VOL : [mute]" else volume=$(amixer get -M Master | awk '/%/ {print $4}') echo "VOL : $volume" fi } mem() { memused=$(free -m | awk '/^Mem:/ {print $3}') # memtotal=$(free -m | awk '/^Mem:/ {print $2}') echo "MEM : [$memused MB]" } cpu() { read cpu a b c previdle rest < /proc/stat prevtotal=$((a+b+c+previdle)) sleep 0.5 read cpu a b c idle rest < /proc/stat total=$((a+b+c+idle)) cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) )) echo "CPU : [${cpu}%]" } temp() { zone0="$(cat /sys/class/thermal/thermal_zone8/temp | sed 's/000$/°C/')" echo "TEMP : $zone0" } bat() { level="$(cat /sys/class/power_supply/BAT0/capacity)%" charging="$(cat /sys/class/power_supply/BAT0/status | awk '{print tolower($0)}')" if [ $charging = "discharging" ]; then echo "BAT : ${level} [v]" else echo "BAT : ${level} [^]" fi } net() { wifi=$(ip link | awk '/wlp2s0/ {print $9}') echo "WIFI : [$wifi]" } mouse() { level="$(cat /sys/class/power_supply/hidpp_battery_0/capacity_level)" echo "MOUSE : [$level]" } dte() { dte=$(date +'%a %b %d [%R]') echo $dte } while (true); do echo "+@fg=0;$(mem)+8< +@fg=1;$(cpu)+8< +@fg=0;$(mouse)+8< +@fg=1;$(temp)+8< ++@fg=0;$(bat)+8< +@fg=1;$(vol)+8< +@fg=0;$(dte)" sleep 3 done