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 <thay...@gmail.com> wrote: > On Sat, May 2, 2009 at 8:30 PM, Jake Todd <jaketodd...@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'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; > >