Created
September 4, 2008 10:16
-
-
Save uggedal/8747 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'awesomer' | |
def meminfo(key) | |
`cat /proc/meminfo | grep #{key}`[/\d+/].to_i / 1024 | |
end | |
def load | |
`uptime`[/e: (\d\.\d\d),/, 1] | |
end | |
def volume(mixer) | |
`amixer get #{mixer}`.scan(/\[(\d+)%\]/) | |
end | |
def battery | |
`acpi`[/\d{1,3}%/] | |
end | |
Awesomer.contact do |a| | |
MEM_TOTAL = meminfo :MemTotal | |
a.statusbar = :status | |
loop do | |
a.widget_tell :battery, :text, "[#{battery}]" | |
a.widget_tell :memory, :text, | |
"[#{MEM_TOTAL-meminfo(:MemFree)}/#{MEM_TOTAL}MB" | |
a.widget_tell :load, :text, "#{load}]" | |
a.widget_tell :volume, :text, "[#{volume(:PCM).join('/')}%]" | |
a.widget_tell :clock, :text, Time.now.strftime('[%Y-%m-%d %H:%M]') | |
sleep 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment