#!/bin/sh # Script que muestra un panel con información del sistema # Dependencias: xsetroot, alsa-utils, moc # # Autor: O. Sánchez while true; do DATE=$(date +" %a %d %b  %R") TEMP=$(sed 's/000$/°C/' /sys/class/thermal/thermal_zone1/temp) MEM=$(free -h | awk '/^Mem:/ {print $3}') CPU=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}') VOL() { a=$(amixer sget Master | tail -n1 | sed -r "s/.*\[(.*)\]/\1/") b=$(amixer get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/") if [ "$a" = 'on' ]; then printf " $b%%" else printf ""; fi } SONG() { if [ "$(pgrep mocp)" ]; then if [ "$(mocp -Q %state)" = "PLAY" ];then SONG=$(mocp -Q %song) if [ -n "$SONG" ]; then echo " $SONG - $(mocp -Q %album) |" else echo " $(mocp -Q %file) |" fi fi else echo "" fi } BAT() { bat_dir=/sys/class/power_supply/BAT1 read -r capacity < "$bat_dir/capacity" read -r status < "$bat_dir/status" printf '%s%% [%s]\n' "$capacity" "$status" } xsetroot -name "$(SONG) CPU $CPU | MEM $MEM | TEMP $TEMP | $(VOL) | $DATE | $BAT" sleep 1 done