From 06191eee5893a5bc922aa7c59af43a0232d6d349 Mon Sep 17 00:00:00 2001 From: Dag Odenhall Date: Wed, 9 Apr 2008 11:35:43 +0200 Subject: [PATCH] CPUInfo widget --- README.rdoc | 1 + lib/amazing/widgets.rb | 1 + lib/amazing/widgets/cpuinfo.rb | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 lib/amazing/widgets/cpuinfo.rb diff --git a/README.rdoc b/README.rdoc index 61a836c..d67ca2b 100644 --- a/README.rdoc +++ b/README.rdoc @@ -19,6 +19,7 @@ an amazing widget manager for an awesome window manager ACAdapter : AC adapter status ALSA : Various data for the ALSA mixer Battery : Remaining battery power in percentage + CPUInfo : CPU Information Clock : Displays date and time File : Information for a file Filesystem : Various filesystem information diff --git a/lib/amazing/widgets.rb b/lib/amazing/widgets.rb index 37498fd..33cf616 100644 --- a/lib/amazing/widgets.rb +++ b/lib/amazing/widgets.rb @@ -5,6 +5,7 @@ require 'amazing/widgets/acadapter' require 'amazing/widgets/alsa' require 'amazing/widgets/battery' require 'amazing/widgets/clock' +require 'amazing/widgets/cpuinfo' require 'amazing/widgets/file' require 'amazing/widgets/filesystem' require 'amazing/widgets/gmail' diff --git a/lib/amazing/widgets/cpuinfo.rb b/lib/amazing/widgets/cpuinfo.rb new file mode 100644 index 0000000..ab0f69a --- /dev/null +++ b/lib/amazing/widgets/cpuinfo.rb @@ -0,0 +1,24 @@ +# Copyright (C) 2008 Dag Odenhall +# Licensed under the Academic Free License version 3.0 + +require 'amazing/widget' +require 'amazing/proc_file' + +module Amazing + module Widgets + + # TODO: There might be more yummy stuff in /proc/cpuinfo + class CPUInfo < Widget + description "CPU Information" + option :cpu, "CPU number for default format (0 based)", 0 + field :speed, "CPU Speed in MHz", [] + default { @speed[@cpu].to_i } + + init do + ProcFile.parse_file("cpuinfo").each_with_index do |info, cpu| + @speed[cpu] = info["cpu MHz"].to_f + end + end + end + end +end -- 2.11.4.GIT