.xinitrc:
#!/bin/sh
fbsetbg -c /home/boily/Images/mallorca.jpg
#exec startxfce4
exec dwmwrap
----------
dwmwrap:
#!/bin/bash
[ -p /home/boily/.dwm-status ] || mkfifo /home/boily/.dwm-status
dwm <>/home/boily/.dwm-status &
sleep 0.2
ruby /usr/local/bin/ligne.rb
----------
ligne.rb:
#!/usr/bin/ruby
PIPE = "/home/boily/.dwm-status"
INTERFACE = "eth1"
RXMAX = 600
TXMAX = 200
lithour = ['midnight', 'one', 'two', 'three', 'four', 'five', 'six', 'seven',
'eight', 'nine', 'ten', 'eleven', 'noon', 'thirteen', 'fourteen', 'fifteen',
'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty-one',
'twenty-two', 'twenty-three']
litmin = ["%s o'clock", "Five past %s", "Ten past %s", "Quarter past %s",
"Twenty past %s", "Twenty-five past %s", "Half past %s", "Twenty-five to %s",
"Twenty to %s", "Quarter to %s", "Ten to %s", "Five to %s"]
def probar(new, last, max)
diff = ((new - last) / max * 10).round
if diff > 10 then
diff = 10
end
return "[" + "=" * diff + " " * (10 - diff) + "]"
end
RXFILE = "/sys/class/net/#{INTERFACE}/statistics/rx_bytes"
TXFILE = "/sys/class/net/#{INTERFACE}/statistics/tx_bytes"
rx = File.read(RXFILE).to_f / 1024
tx = File.read(TXFILE).to_f / 1024
while not `pidof dwm`.chomp.empty?
rxnew = File.read(RXFILE).to_f / 1024
txnew = File.read(TXFILE).to_f / 1024
battery_state, battery_percent = `acpitool`.split(/\s+/)[4..5]
battery = "#{battery_percent.to_f.round}%
(#{battery_state[0..0].tr('cd','+-')})"
now = Time.now
nummin = now.min
numhour = (nummin > 32 ? (now.hour + 1) % 24 : now.hour)
fivemin = case nummin
when (0..2)
0
when (3..7)
1
when (8..12)
2
when (13..17)
3
when (18..22)
4
when (23..27)
5
when (28..32)
6
when (33..37)
7
when (28..42)
8
when (43..47)
9
when (48..52)
10
when (49..57)
11
when (58..59)
0
end
datetime = now.strftime("%d.%m.%Y - ") + (litmin[fivemin] %
lithour[numhour]).capitalize
File.open(PIPE, 'w') do |ligne|
ligne.print "<-%s ->%s - %s - %s\n" % [probar(rxnew, rx, RXMAX),
probar(txnew, tx, TXMAX), battery, datetime]
end
sleep 1
rx = rxnew
tx = txnew
end
Received on Mon Oct 01 2007 - 23:08:47 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:56:42 UTC