sysstatus (2378B)
1 #!/bin/sh 2 3 separator="|" 4 5 # screenrecord 6 [ -f /tmp/screenrecord.pid ] && printf ' R %s' "$separator" 7 8 # mail 9 printf '%s' "$(mailstatus | sed "s/^/ /;s/\$/ $separator/;s/ |//")" 10 11 # music 12 printf '%s' "$(mpc status | sed 1q | sed 's/^volume:.*$//;s/^/ /;s/$/ |/;s/ |//')" 13 14 # keymap 15 printf ' %s %s' "$(setxkbmap -print | sed -n '5s/^.*pc+//;5s/+.*$//;5p')" "$separator" 16 17 # audio volume 18 if type mixerctl >/dev/null 2>&1; then 19 if [ "$(mixerctl -n outputs.master.mute)" = "off" ]; then 20 printf ' vol ' 21 else 22 printf ' M ' 23 fi 24 printf '%s' "$(echo $(mixerctl -n outputs.master | \ 25 sed 's/,.*//')/255*100 | bc -l | sed 's/\..*//')%" 26 elif type amixer >/dev/null 2>&1; then 27 printf ' vol %s' "$(amixer get Master | grep -o "[0-9]*%\|\[off\]")" 28 elif type pulsemixer >/dev/null 2>&1; then 29 printf ' vol %s' "$(pulsemixer --get-volume | cut -d' ' -f1)%" 30 fi 31 printf ' %s' "$separator" 32 33 # cpu 34 printf ' ' 35 if type sensors >/dev/null 2>&1; then 36 printf '%s ' "$(sensors | grep -n 'Core 0:' | awk '{print $3}')" 37 elif type sysctl >/dev/null 2>&1; then 38 printf '%s ' "$(sysctl hw.sensors.cpu0.temp0 | \ 39 sed 's/.*=//;s/\.[0-9]* deg/°/')" 40 fi 41 if [ -f /proc/loadavg ]; then 42 printf '%s' "$(cut -f 1 -d' ' /proc/loadavg)" 43 else 44 printf '%s' "$(uptime | sed 's/.*: \([0-9]*\.[0-9]*\),.*/\1/')" 45 fi 46 printf ' %s' "$separator" 47 48 # battery 49 if type apm >/dev/null 2>&1; then 50 printf ' %s' "$(apm | grep -o -E "[0-9]+%")" 51 printf '%s' "$(apm | grep -o -E " [0-9]+ min")" 52 printf ' %s' "$separator" 53 elif [ -d "/sys/class/power_supply/BAT0" ]; then 54 batstatus="$(sed -n 's/Charging/+/;s/Discharging/-/' \ 55 /sys/class/power_supply/${battery}/status | sed 's/Unknown//')" 56 batlvl="$(cat /sys/class/power_supply/${battery}/capacity)" 57 batremain="$(acpi -b | sed 1q |\ 58 sed -n 's/.*\([0-9][0-9]:[0-9][0-9]\):[0-9][0-9].*$/\1/p')" 59 printf ' %s %s' "$(echo "${batstatus}${batlvl}% ${batremain}" | sed 's/ $//')" "$separator" 60 fi 61 62 # wlan 63 if type ifconfig >/dev/null 2>&1; then 64 printf ' %s %s' "$(ifconfig iwn0 | grep join | cut -f 3,8 -d' ')" "$separator" 65 elif type iwgetid >/dev/null 2>&1; then 66 wlandev="$(find /sys/class/net/ -type l -name 'wlp*' -exec basename {} \;)" 67 printf ' %s' "$(iwgetid -r $wlandev)" 68 printf ' %s %s' "$(echo \ 69 "0$(grep $wlandev /proc/net/wireless | awk '{print $3}')/70 * 100" |\ 70 bc -l | sed 's/\..*$//')%" "$separator" 71 fi 72 73 # date 74 printf ' %s\n' "$(date +'%F %a %T')"