Skip to content

Instantly share code, notes, and snippets.

@uggedal
Created September 4, 2008 10:16
Show Gist options
  • Save uggedal/8747 to your computer and use it in GitHub Desktop.
Save uggedal/8747 to your computer and use it in GitHub Desktop.
#!/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