Re: [dwm] Stats script

From: Leandro Chescotta <leandro.chescotta_AT_gmail.com>
Date: Sun, 3 May 2009 10:06:03 -0300

On 5/3/09, Andrius <warshke_AT_gmail.com> wrote:
> Hi, i'm using this one for my eee901:
>
> $ cat .dwm.sh
> #!/bin/sh
>
> TEMP=$(awk '{print $2}' /proc/acpi/thermal_zone/TZ00/temperature)
> LOAD=$(awk '{print $1}' /proc/loadavg)
> DATE=$(date "+%D %T")
>
> STATE=$(grep '^charging state:' /proc/acpi/battery/BAT0/state | awk '{print
> $NF}')
> REMAINS=$(grep '^remaining capacity:' /proc/acpi/battery/BAT0/state | awk
> '{print $(NF-1)}')
> RATE=$(grep '^present rate:' /proc/acpi/battery/BAT0/state | awk '{print
> $(NF-1)}')
>
> MAH_MAX=$(grep '^last full capacity:' /proc/acpi/battery/BAT0/info | awk
> '{print $(NF-1)}')
> MAH_MIN=$(grep '^design capacity warning:' /proc/acpi/battery/BAT0/info |
> awk '{print $(NF-1)}')
>
> PERC_LEFT=$((${REMAINS}*100/${MAH_MAX}))
>
> case $STATE in
> charging)
> if [[ $RATE -eq 0 ]]; then
> TIME_LEFT="∞"
> else
> TIME_LEFT=$(($((${MAH_MAX}-${REMAINS}))*60/$RATE))min
> fi
> ;;
> discharging)
> TIME_LEFT=$(($((${REMAINS}-${MAH_MIN}))*60/$RATE))min
> ;;
> charged)
> TIME_LEFT="full"
> ;;
> *)
> TIME_LEFT=$STATE
> ;;
> esac
>
> echo ${TIME_LEFT} $PERC_LEFT% $LOAD ${TEMP}*C $DATE
>
>
>
>
> On Sat, 2 May 2009 23:30:23 -0400
> Jake Todd <jaketodd422_AT_gmail.com> wrote:
>
>> I was wondering what some other dwm users were using for stats like
>> memory, temperature, et cetera. Right now I'm using this for
>> termperature, memory, wifi, date:
>
>

I use dzen for displaying the bar i before used for status bar, but i
found myself hiding the bar to often and in my tiny laptop screen
(10") the status bar, tags, and window info, didn't fit very well, so
here's my design... (you'll see i adheres to unix philosophy, lol)

- In .xinitrc
exec ~/bin/start-dwm

- ~/bin/start-dwm
#!/bin/bash
~/bin/dwm-status | while true; do /usr/bin/dwm > /dev/null; done;

- ~/bin/dwm-status
#!/bin/bash
while true
do
    xsetroot -name "$(date +'%R %d/%m/%Y')"
    sleep 60
done

- ~/bin/get_statusbar
#!/bin/bash
echo $(get_uptime)" | "$(get_cputemp)@$(get_cpufreq)" |
"$(get_freemem)/$(get_freeswap)" | "$(get_diskinfo
sda1)/$(get_diskinfo sda3)/$(get_diskinfo sda4)/$(get_diskinfo
sdb1)/$(get_diskinfo sdc1)/$(get_diskinfo sdd1)" | "$(get_updates)" |
"$(get_volume PCM)/$(get_batterycharge)/$(get_batterycapacity)/$(get_batteryremain)"
| "$(date +'%R %d/%m/%Y')

- ~/bin/get_dzen_statusbar
#!/bin/bash
(echo $(get_statusbar);sleep 30) | dzen2 -l 1 -x o -y o -w 1024 -fn
-*-fixed-medium-r-*-*-18-*-*-*-*-*-iso8859-* -bg black -fg grey

- ~/bin/get_uptime
#!/bin/bash
upSeconds=`cat /proc/uptime`;
upSeconds=${upSeconds%%.*};
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
if [ "${days}" -ne "0" ]
then
           echo -n "${days}d:"
fi
echo -n "${hours}h:${mins}m"

- ~/bin/get_cputemp
#!/bin/bash
cat /proc/acpi/thermal_zone/THRM/temperature | awk '{print $2}'

- ~/bin/get_freemem
#!/bin/bash
free -m | grep - | awk '{print $4}

- ~/bin/get_freeswap
#!/bin/bash
free -m | grep Swap | awk '{print $4}'

- ~/bin/get_diskinfo
#!/bin/bash
dev=$(df -mh | grep /dev/$1 | awk '{print $4}')
if [ "$dev" == "" ]; then
        echo "X"
else
df -mh | grep /dev/$1 | awk '{print $4}' | tr -d G
fi

- ~/bin/get_gmail
#!/bin/bash
gmail_login="xxxxxxx.xxxxxxxx" #without the @gmail.com
gmail_password="xxxxxxxxxxxxx"

dane="$(wget --secure-protocol=TLSv1 --timeout=3 -t 1 -q -O - \
https://${gmail_login}:${gmail_password}@mail.google.com/mail/feed/atom \
--no-check-certificate | grep 'fullcount' \
| sed -e 's/.*<fullcount>//;s/<\/fullcount>.*//' 2>/dev/null)"

if [ -z "$dane" ]; then
        echo "X"
else
        echo "$dane"
fi

- ~/bin/get_updates
#! /usr/bin/perl -w
use strict;
# November 15, 2006
# Daniel Vredenburg (Vredfreak)
# This is a program that checks for package updates for Arch Linux users.

open (MYINPUTFILE, "/home/aleyscha/bin/arch-updates/updates.log") or
die "No such file or directory: $!";

my $i = 0;
while(<MYINPUTFILE>)
{
        if (/^(.*)\/(.*)(\..*\..*\.)/) {
                #print " \n";
                $i++;
        }

}
if ($i == 0) {
        print "0";
} else {
        print "$i";
}
close(MYINPUTFILE);

- ~/bin/arch-updates/pacsync.sh #need to symlink in /etc/cron.hourly/pacsync.sh
#!/bin/bash

# This issues a command to 1. Sync the package database,
# 2. Check for upgradable packages, 3. print the URL of any possible upgrade.
# The output of our command gets written to updates.log, which we will use
# conky_updates.sh to parse to see if there are any available updates.

pacman -Syup --noprogressbar > /home/aleyscha/bin/arch-updates/updates.log

- ~/bin/get_volume
#!/bin/bash
amixer sget $1 | tail -n 1 | gawk '{print $5}' | tr -d [%]

- ~/bin/get_batterycharge
#!/bin/bash
#BATT=$(acpi | cut -d " " -f 9 | sed s/,//g | tr -d %)
BATT=$(acpi | awk '{print $4}' | tr -d %,)
if [ "$BATT" = "" ]; then
        echo X
else
        echo $BATT
fi

- in dwm's config.h i have
static const char *statusbar[] = { "get_dzen_statusbar", NULL };

and

{ MODKEY, XK_c, spawn, {.v = statusbar } },

hope you like it!

-- 
---------------------------------
http://aleyscha.spaces.live.com/
""El lugar mas peligroso de todos es el cielo... En el, cada
pensamiento se hace realidad... sea bueno o malo... creas tu paraiso o
tu infierno""
Received on Sun May 03 2009 - 13:06:03 UTC

This archive was generated by hypermail 2.2.0 : Sun May 03 2009 - 13:12:04 UTC