Re: [dwm] Stats script

2009-05-09 Thread stanio
* Kurt H Maier  [2009-05-09 17:47]:
> On Sat, May 09, 2009 at 11:49:53AM +0200, sta...@cs.tu-berlin.de wrote:
> > I noticed I very rarely look at most of the stuff in this status bar thoug,
> > so I am thinking of 2 staged status query -- e.g. date/time and temp in the
> > dwm status bar; The rest can be queried 'on demand' in the console.
> 
> I keep clock and battery in the status bar, and other info is in other
> short scripts bound to Super-I, Super-P, Super-O, etc. The loop in
> xinitrc ensures it will automatically revert to the clock within sixty
> seconds.

Great idea. I think I'll go for that.

-- 
 cheers
 stanio_



Re: [dwm] Stats script

2009-05-09 Thread miles
`uptime` is the best combination of usefulness and simplicity in my  
opinion.  Then again I only use dwm on the desktop and things such as  
wireless signal and battery life done apply to me.


miles



Re: [dwm] Stats script

2009-05-09 Thread Jeremy Jay
I have mine just clock and date, but it'll show other stats when they
are "interesting" ie high cpu usage, discharging/low battery, low/off wifi, etc

Jeremy

On Sat 09 May 2009 - 10:47AM, Kurt H Maier wrote:
> On Sat, May 09, 2009 at 11:49:53AM +0200, sta...@cs.tu-berlin.de wrote:
> > I noticed I very rarely look at most of the stuff in this status bar thoug,
> > so I am thinking of 2 staged status query -- e.g. date/time and temp in the
> > dwm status bar; The rest can be queried 'on demand' in the console.
> 
> I keep clock and battery in the status bar, and other info is in other
> short scripts bound to Super-I, Super-P, Super-O, etc. The loop in
> xinitrc ensures it will automatically revert to the clock within sixty
> seconds.
> 
> # Kurt H Maier
> 



Re: [dwm] Stats script

2009-05-09 Thread Kurt H Maier
On Sat, May 09, 2009 at 11:49:53AM +0200, sta...@cs.tu-berlin.de wrote:
> I noticed I very rarely look at most of the stuff in this status bar thoug,
> so I am thinking of 2 staged status query -- e.g. date/time and temp in the
> dwm status bar; The rest can be queried 'on demand' in the console.

I keep clock and battery in the status bar, and other info is in other
short scripts bound to Super-I, Super-P, Super-O, etc. The loop in
xinitrc ensures it will automatically revert to the clock within sixty
seconds.

# Kurt H Maier



Re: [dwm] Stats script

2009-05-09 Thread Martin Oppegaard
On Sat, May 09, 2009 at 11:49:53AM +0200, sta...@cs.tu-berlin.de wrote:
> I noticed I very rarely look at most of the stuff in this status bar thou=
> g,
> so I am thinking of 2 staged status query -- e.g. date/time and temp in t=
> he
> dwm status bar; The rest can be queried 'on demand' in the console.

Indeed.  It's mostly just fun to create, but is never usable.  Now I've only
got the clock.

> 
> --=20
>  cheers
>  stanio_
> 



Re: [dwm] Stats script

2009-05-09 Thread stanio
* Jake Todd  [2009-05-03 05:31]:
> What are you guys using?

I use 

in .Xsession

while  true ; do
xsetroot -name "`${HOME}/.status`";
sleep 4;
done &

and here is .status

cat .status  |~
#!/bin/sh
sswriter \
-w 10 \
-f /home/stanio/.current_song /home/stanio/.recent_events \
-a 20 25 \
-t THRM \
-D eth0 eth2 \
-d "%Y-%m-%d %a %H:%M'%S" \
-s PCM Master Mic \
"%[ | %f0%] %[ | %f1%] |%(B* WARNING * BATTERY *%)%(b%v1%V1 %v2%V2| %d| 
%m %sMB| %n%(w %q%%%) %i:%o kB| %C0MHz %p0%%| %b0%%| %t0°C%)"

Sswriter is pretty powerful c program posted perhaps  more than year
ago on the wmii mailing list, as I was still half wmii user. I use a
patched 0.3.1 version. 

sample output of ./.status is:
 song | event |81on 80off| 2009-05-09 Sat 11:44'18| 278 0MB| eth0 0.0:0.0 kB| 
798MHz 46%| 100%| 53°C

which translates to

 song|event|volume of headphones and 
micropone|date|memory+swap|link|cpu|battery|temp

For those interested:

http://www.mail-archive.com/w...@suckless.org/msg01935.html

I noticed I very rarely look at most of the stuff in this status bar thoug,
so I am thinking of 2 staged status query -- e.g. date/time and temp in the
dwm status bar; The rest can be queried 'on demand' in the console.

-- 
 cheers
 stanio_



Re: [dwm] Stats script

2009-05-03 Thread Claudio M. Alessi
On Sun, May 03, 2009 at 11:03:03AM -0400, Jake Todd wrote:
> I took your advice and I've reduced the amount of cpu cycles used for
> displaying stats by a significant amount. This is what my xinitrc looks like
> now:
It appear much clear now. Also i'm now able to get all fields properly, though
I'm only able to see the last two digit of the memory abount when it goes over
99Mb. As far as I can tell, you could use cut(1) to get the desired offset of
bytes from free(1), as in this example:

   free -m |grep ^- |cut -b27-30

There is more than one way to do it. You may also want to increase the sleep
time (30 seconds are enough?) in order to not stress the CPU furthemore.

HTH.

Regards,
Claudio M. Alessi

-- 
JID: smoppy AT gmail.com
WWW: http://cma.teroristi.org



Re: [dwm] Stats script

2009-05-03 Thread Jake Todd
On Sun, 3 May 2009 09:38:36 +0200
"Claudio M. Alessi"  wrote:

> > The only problem with this is when memory goes over 100MB, it doesn't
> > show up (need to fix that).
> To be honest i don't get any value for the memory field at all. You should
> found a better "general" way. Alsa i suggest you, in order to save few (?)
> cycle of CPU, you can avoid to call cat(1) passing the file name directly
> to sed(1), tail(1), and so forth for others Unix tools.
> 
> Hope this helps.
> 
> 
> Regards,
> Claudio M. Alessi

I took your advice and I've reduced the amount of cpu cycles used for
displaying stats by a significant amount. This is what my xinitrc looks like
now:

#!/bin/sh

xmodmap $HOME/.xmodmap
bgs media/pics/wallpapers/evisceration_plague_wallpaper2_1600x1200.jpg &
while true
do
xsetroot -name "`sed -e
's/\ //g' /proc/acpi/thermal_zone/THRM/temperature | colrm 1 12` |
`free -m | tail -2 | head -1 | colrm 1 27 | colrm 3`MB | `tail\
-1 /proc/net/wireless | colrm 1 15 | colrm 3`% | `date '+%a %b %d %Y
%T'`"
sleep 1
done &
exec dwm



Re: [dwm] Stats script

2009-05-03 Thread Leandro Chescotta
On 5/3/09, Andrius  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  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="xxx." #without the @gmail.com
gmail_password="x"

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

Re: [dwm] Stats script

2009-05-03 Thread Andrius
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  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:



Re: [dwm] Stats script

2009-05-03 Thread pmarin
My status bar is written in Tcl. It shows date, Mhz, memory, traffic
network and battery status when the battery is present. The main
reason to use a dinamic lenguage instead a more classic software tool
approach is that I am not sure if doing 15 fork's each 2 second can be
efficient. I am still using the stdin for read the status bar (dwm 5.2
I think):

#An status bar in 62 lines:

#!/usr/bin/tclsh

package require Tcl 8.5
namespace path {::tcl::mathop ::tcl::mathfunc}; # because  expr sucks!

proc sleep {N} { after [ expr { int( $N * 1000)} ] }

proc date {} { return [clock format [clock seconds] -format {%a %d %b, %R}] }

proc file2array {file arr_name} {
   upvar $arr_name arr
   set chan [open $file r]
   set file_str "[read  -nonewline $chan ]"
   close $chan
   regsub -all {\n} $file_str {:} file_str
   regsub -all {[\s]*:[\s]*} $file_str {:} file_str
   set list_file "[split $file_str ":" ]"
   if { [!= [% [ llength $list_file]  2 ] 0 ] } {
  set list_file [lreplace $list_file end end]
}
   array set arr "$list_file"
}

proc mhz {} {
   file2array "/proc/cpuinfo" cpu
   return [int $cpu(cpu MHz)]
}

proc bat {} {
   file2array "/proc/acpi/battery/BAT1/state" bat
   if { [eq $bat(present)  "yes"] } {
  if { [catch {set battery [/ [* [string trim $bat(remaining
capacity) {\smAh}] 100] 4000] }] } {
 return ""
  }
  return "$battery% $bat(charging state)"
   }
   return ""
}

proc memUsed {} {
   file2array "/proc/meminfo" mem
   foreach i { MemFree MemTotal Cached } { set $i [string trim
$mem($i) {\skB}] }
   return [/ [- $MemTotal [+ $MemFree $Cached] ] 1024]
}

proc trafficSpeed {eth} {
   file2array "/proc/net/dev" net
   if { [catch {  regsub -all { +} $net($eth) { } aux } ] } {
  return "0 0"
   }
   return "[lindex $aux 0] [lindex $aux 8]"
}

set oldNetState "0 0"
while {1} {
   set newNetState [trafficSpeed wlan0]
   set netSpeed  "[/ [/ [- [lindex  $newNetState 0] [lindex
$oldNetState 0]] 1024] 2 ] \
   [/ [/ [- [lindex $newNetState 1] [lindex $oldNetState 1]] 1024] 2]"
   set oldNetState $newNetState
   puts "[bat] | +[lindex $netSpeed 0] KB/S -[lindex $netSpeed 1] KB/S
| [memUsed] MB | [mhz] MHz | [date]"
   sleep 2
}






On Sun, May 3, 2009 at 7:27 AM, Thayer Williams  wrote:
> On Sat, May 2, 2009 at 8:30 PM, Jake Todd  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'm lazy and use conky-cli to do most of the grunt work...my conkyrc
> (below) displays the cpu frequency, cpu usage percentiles, battery or
> AC status, LAN or WIFI stats depending on which is active, and the
> date/time:
>
> ~$ cat .conkyrc
>
> background no
> out_to_console yes
> update_interval 2
> total_run_times 0
> use_spacer none
>
> TEXT
>   ${freq 1}MHz ${cpu cpu1}%/${cpu cpu2}% :: ${if_existing
> /sys/class/power_supply/BAT0/present}Bat
> ${battery_percent}%${else}AC${endif} :: ${if_empty ${exec ifconfig
> wlan0 | grep 'inet addr:'}}${upspeed eth0}K ${downspeed
> eth0}K${else}${wireless_link_qual_perc wlan0}% ${wireless_essid wlan0}
> ${upspeed wlan0}K ${downspeed wlan0}K${endif} :: ${time %b %d %H:%M}
>
> ...and I combine this with a startdwm script so I can reload dwm
> without closing other applications:
>
> $ cat bin/startdwm
> #!/bin/sh
>
> # A simple script to start dwm in a while loop which
> # allows dwm to be killed without closing programs.
> # Usage:    killall dwm         <-- restarts dwm
> #           killall startdwm    <-- kills session
>
> conky-cli | while read line; do
>    xsetroot -name "$line";
> done | while true; do dwm > /dev/null; done;
>
>



Re: [dwm] Stats script

2009-05-03 Thread Claudio M. Alessi
On Sat, May 02, 2009 at 11:30:23PM -0400, Jake Todd 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:
Your script is nice, though I use an UTF-8-based script[0] I wrote some
month ago (and posted a preview here[1]) which you can found useful.
>From my ~/.xinitrc it run as follow:

   while true ; do xsetroot -name "$(~/.mk8monbar.sh -dacw wlan0 -tl)" ; sleep 
30 ; done &

It may need to be adapted from case to case (e.g., your thermal zone
directory in proc is THRM while in mine are TZ00 and TZ01).

> The only problem with this is when memory goes over 100MB, it doesn't
> show up (need to fix that).
To be honest i don't get any value for the memory field at all. You should
found a better "general" way. Alsa i suggest you, in order to save few (?)
cycle of CPU, you can avoid to call cat(1) passing the file name directly
to sed(1), tail(1), and so forth for others Unix tools.

Hope this helps.


Regards,
Claudio M. Alessi


[0] http://cma.teroristi.org/chems/usr/files/sources/scripts/mk8monbar.sh
[1] http://lists.suckless.org/dwm/0810/6849.html

-- 
JID: smoppy AT gmail.com
WWW: http://cma.teroristi.org



Re: [dwm] Stats script

2009-05-02 Thread Thayer Williams
On Sat, May 2, 2009 at 8:30 PM, Jake Todd  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'm lazy and use conky-cli to do most of the grunt work...my conkyrc
(below) displays the cpu frequency, cpu usage percentiles, battery or
AC status, LAN or WIFI stats depending on which is active, and the
date/time:

~$ cat .conkyrc

background no
out_to_console yes
update_interval 2
total_run_times 0
use_spacer none

TEXT
   ${freq 1}MHz ${cpu cpu1}%/${cpu cpu2}% :: ${if_existing
/sys/class/power_supply/BAT0/present}Bat
${battery_percent}%${else}AC${endif} :: ${if_empty ${exec ifconfig
wlan0 | grep 'inet addr:'}}${upspeed eth0}K ${downspeed
eth0}K${else}${wireless_link_qual_perc wlan0}% ${wireless_essid wlan0}
${upspeed wlan0}K ${downspeed wlan0}K${endif} :: ${time %b %d %H:%M}

...and I combine this with a startdwm script so I can reload dwm
without closing other applications:

$ cat bin/startdwm
#!/bin/sh

# A simple script to start dwm in a while loop which
# allows dwm to be killed without closing programs.
# Usage:killall dwm <-- restarts dwm
#   killall startdwm<-- kills session

conky-cli | while read line; do
xsetroot -name "$line";
done | while true; do dwm > /dev/null; done;