rendered paste body#!/usr/bin/awk -f
BEGIN {
DATE_CMD = "date +\"%d/%m/%y-%H:%M\"";
BAT_CMD = "acpi -b | awk '{ print $4}' | head -1 | sed -e s/,//"
VOLUME_CMD = "amixer get Master | grep Left | grep % | awk '{print $5}' | cut -d [ -f2 | cut -d% -f1"
CPUT_CMD = "acpi -t | grep Thermal | grep 1: | awk '{print $4}'"
WIFI_CMD = "sudo iwconfig eth2 | grep Link | awk '{print $2}' | sed -e s/Quality=// | cut -d/ -f1"
#ACBRANCH = "acpi -b | awk '{ print $3}'"
RAF = 1;
MPD_MSG = 0;
while (!system("sleep " RAF ))
{
#date
DATE_CMD | getline DATE;
close(DATE_CMD);
#bat
BAT_CMD | getline BAT
close(BAT_CMD);
#vol
VOLUME_CMD | getline VOLUME
close(VOLUME_CMD);
#cpu_temp
CPUT_CMD | getline CPUT
close(CPUT_CMD);
#wifi
WIFI_CMD | getline WIFI
close(WIFI_CMD);
#ac
ACBRANCH | getline AC
close(ACBRANCH);
#mpd
MPD | getline MPD
close(MPD);
#mem
count = 0;
while ((getline < "/proc/meminfo") > 0)
{
if ("MemFree:" == $1){mem_free = $2;count++;}
else if ("MemTotal:" == $1){mem_total = $2;count++;}
else if ("SwapFree:" == $1){swap_free = $2;count++;}
else if ("SwapTotal:" == $1){swap_total = $2;count++;}
if (count >= 4){break;}
}
close("/proc/meminfo");
mem_percent = 100 * (mem_total - mem_free) / mem_total;
swap_percent = 100 * (swap_total - swap_free) / swap_total;
if (MPD_MSG)
{
mpd_lines=0
while (("mpc" | getline) > 0)
{
mpd_info[mpd_lines]=$0
if (mpd_lines==1) {mpd_time=$3}
mpd_lines+=1;
}
close("mpc");
if (mpd_lines == 1)
mpd_msg="mpd not playing";
else
mpd_msg=mpd_info[0];
if (mpd_info[1] ~ /paused/)
mpd_msg = "<" mpd_msg ">";
mpd_msg = mpd_msg" (" mpd_time ")"
}
# if(BAT=="100%"){ BAT = "Max"; BATP = "100%"; }
# else{ BATP = BAT; }
if(WIFI=="0" || WIFI=="Quality:0"){WIFI="Ã Ã "}
print "0 widget_tell top tb_hour text " DATE " ";
print "0 widget_tell bat text " BAT "";
print "0 widget_tell pb_bat data bat " BATP "";
print "0 widget_tell top pb_vol data vol " VOLUME;
print "0 widget_tell top tb_temp text " CPUT "ðC";
print "0 widget_tell tb_wifi text " WIFI "%";
print "0 widget_tell top pb_ram data ram " mem_percent;
print "0 widget_tell top pb_ram data swap " swap_percent;
print "";
}
}