Floppy-currentcost 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +14 -1
- data/bin/currentcost_tray_monitor.rb +343 -0
- metadata +6 -5
data/README
CHANGED
@@ -19,10 +19,23 @@ Homepage: http://github.com/Floppy/currentcost-ruby
|
|
19
19
|
|
20
20
|
== REQUIREMENTS
|
21
21
|
|
22
|
-
Floppy-rb232 >= 0.
|
22
|
+
Floppy-rb232 >= 0.2.3
|
23
23
|
|
24
24
|
== USAGE
|
25
25
|
|
26
26
|
You can read data from the meter by creating an instance of the CurrentCost::Meter
|
27
27
|
class, and registering an observer which will receive readings. See examples/simple.rb
|
28
28
|
or the CurrentCost::Meter documentation for a simple example of how to do this.
|
29
|
+
|
30
|
+
== TRAY MONITOR
|
31
|
+
|
32
|
+
This gem includes the 'currentcost_tray_monitor.rb' application. This is a program
|
33
|
+
which will sit in your system tray and display a coloured icon based on your power
|
34
|
+
usage. To use the program, run:
|
35
|
+
|
36
|
+
currentcost_tray_monitor.rb -p your_serial_port_name
|
37
|
+
|
38
|
+
The program requires the Gtk2 libraries for Ruby (available from
|
39
|
+
http://ruby-gnome2.sourceforge.jp/).
|
40
|
+
|
41
|
+
For more details, see http://github.com/Floppy/currentcost-ruby/wikis/currentcosttraymonitor
|
@@ -0,0 +1,343 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
dir = File.dirname(__FILE__) + '/../lib'
|
4
|
+
$LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
|
5
|
+
|
6
|
+
require 'gtk2'
|
7
|
+
require 'rubygems'
|
8
|
+
require 'currentcost'
|
9
|
+
require 'optparse'
|
10
|
+
|
11
|
+
# Command-line options
|
12
|
+
options = {:port => '/dev/ttyS0'}
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
opts.on("-p", "--serial_port SERIAL_PORT", "serial port") do |p|
|
15
|
+
options[:port] = p
|
16
|
+
end
|
17
|
+
end.parse!
|
18
|
+
|
19
|
+
|
20
|
+
# Pixbuf images - generated from PNG files with gdk-pixbuf-csource --raw
|
21
|
+
GREY =
|
22
|
+
# Pixbuf magic (0x47646b50)
|
23
|
+
"GdkP" <<
|
24
|
+
# length: header (24) + pixel_data (1024)
|
25
|
+
"\0\0\4\30" <<
|
26
|
+
# pixdata_type (0x1010002)
|
27
|
+
"\1\1\0\2" <<
|
28
|
+
# rowstride (64)
|
29
|
+
"\0\0\0@" <<
|
30
|
+
# width (16)
|
31
|
+
"\0\0\0\20" <<
|
32
|
+
# height (16)
|
33
|
+
"\0\0\0\20" <<
|
34
|
+
# pixel_data:
|
35
|
+
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\351\352\351J\360\360\360\262\353\353" <<
|
36
|
+
"\353\371\347\347\347\377\337\337\337\377\322\323\322\371\310\310\310" <<
|
37
|
+
"\262\267\267\267J\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\336" <<
|
38
|
+
"\336\336\30\366\366\366\270\371\370\370\377\360\360\360\377\350\350\347" <<
|
39
|
+
"\377\337\337\337\377\327\327\327\377\316\317\317\377\306\306\306\377" <<
|
40
|
+
"\275\275\276\377\260\257\257\270\232\232\232\30\0\0\0\0\0\0\0\0\0\0\0" <<
|
41
|
+
"\0\336\336\336\30\371\370\370\335\370\370\370\377\365\365\365\377\347" <<
|
42
|
+
"\347\350\377\337\337\337\377\327\327\327\377\317\316\316\377\306\306" <<
|
43
|
+
"\306\377\275\275\276\377\265\265\265\377\255\255\255\377\241\241\241" <<
|
44
|
+
"\335\213\214\214\30\0\0\0\0\0\0\0\0\366\366\366\270\370\370\370\377\366" <<
|
45
|
+
"\366\366\377\377\377\377\377\355\355\355\377\327\326\327\377\316\316" <<
|
46
|
+
"\316\377\306\306\306\377\275\275\275\377\265\265\265\377\255\255\254" <<
|
47
|
+
"\377\244\244\244\377\234\234\234\377\217\217\217\270\0\0\0\0\351\350" <<
|
48
|
+
"\350J\370\370\370\377\360\360\360\377\374\374\374\377\377\377\377\377" <<
|
49
|
+
"\365\366\366\377\316\316\316\377\306\306\306\377\275\275\275\377\265" <<
|
50
|
+
"\265\265\377\255\255\255\377\244\244\244\377\234\234\234\377\223\223" <<
|
51
|
+
"\223\377\213\213\213\377}||J\357\357\357\262\360\360\360\377\354\354" <<
|
52
|
+
"\354\377\377\377\377\377\377\377\377\377\377\377\377\377\314\314\314" <<
|
53
|
+
"\377\275\275\275\377\275\275\275\377\276\276\276\377\244\244\244\377" <<
|
54
|
+
"\234\233\233\377\223\223\223\377\213\213\213\377\202\202\203\377www\262" <<
|
55
|
+
"\352\352\352\371\347\347\347\377\364\364\364\377\377\377\377\377\377" <<
|
56
|
+
"\377\377\377\377\377\377\377\332\332\332\377\265\265\265\377\354\354" <<
|
57
|
+
"\354\377\377\377\377\377\275\274\275\377\267\267\267\377\261\261\261" <<
|
58
|
+
"\377\254\253\253\377\246\246\246\377\237\237\237\373\347\347\347\377" <<
|
59
|
+
"\342\342\342\377\377\377\377\377\377\377\377\377\377\377\377\377\377" <<
|
60
|
+
"\377\377\377\356\356\356\377\276\276\277\377\377\377\377\377\377\377" <<
|
61
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" <<
|
62
|
+
"\377\377\377\377\377\377\377\377\377\336\336\336\377\354\354\355\377" <<
|
63
|
+
"\377\377\377\377\377\377\377\377\323\323\323\377\377\377\377\377\377" <<
|
64
|
+
"\377\377\377\340\340\340\377\377\377\377\377\377\377\377\377\377\377" <<
|
65
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" <<
|
66
|
+
"\377\377\377\377\377\325\325\325\372\371\371\371\377\377\377\377\377" <<
|
67
|
+
"\341\341\341\377\265\265\265\377\377\377\377\377\377\377\377\377\377" <<
|
68
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\322\322" <<
|
69
|
+
"\322\377qqr\377iii\377``a\377UUU\371\335\335\335\314\377\377\377\377" <<
|
70
|
+
"\377\377\377\377\275\275\275\377\254\254\254\377\352\352\352\377\377" <<
|
71
|
+
"\377\377\377\377\377\377\377\377\377\377\377\271\271\271\377\322\322" <<
|
72
|
+
"\322\377\200\200\200\377iih\377`aa\377XXX\377NNN\262\343\343\343\206" <<
|
73
|
+
"\377\377\377\377\356\356\356\377\254\254\254\377\244\243\243\377\274" <<
|
74
|
+
"\274\274\377\377\377\377\377\377\377\377\377\343\343\343\377yyy\377q" <<
|
75
|
+
"qq\377iii\377```\377XXX\377OOO\377GGGJ\377\377\377\34\351\351\351\347" <<
|
76
|
+
"\265\265\265\377\243\244\244\377\233\233\233\377\223\223\223\377\377" <<
|
77
|
+
"\377\377\377\377\377\377\377\246\246\245\377qqq\377iii\377```\377XXX" <<
|
78
|
+
"\377OOO\377EEE\270\0\0\0\0\0\0\0\0\224\223\224\30\237\237\237\335\233" <<
|
79
|
+
"\233\233\377\223\223\223\377\212\212\212\377\307\307\307\377\360\360" <<
|
80
|
+
"\360\377qqq\377ihh\377```\377XWX\377OPO\377EEE\335=>=\30\0\0\0\0\0\0" <<
|
81
|
+
"\0\0\0\0\0\0\204\205\205\30\214\215\214\270\212\212\212\377\201\202\202" <<
|
82
|
+
"\377yyy\377qqq\377hhh\377```\377XXX\377OOO\377EEE\270===\30\0\0\0\0\0" <<
|
83
|
+
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0yxyJuuu\262lll\371ggg\377^_^\377" <<
|
84
|
+
"TTS\371MMM\262EFFJ\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
85
|
+
|
86
|
+
GREEN =
|
87
|
+
# Pixbuf magic (0x47646b50)
|
88
|
+
"GdkP" <<
|
89
|
+
# length: header (24) + pixel_data (1024)
|
90
|
+
"\0\0\4\30" <<
|
91
|
+
# pixdata_type (0x1010002)
|
92
|
+
"\1\1\0\2" <<
|
93
|
+
# rowstride (64)
|
94
|
+
"\0\0\0@" <<
|
95
|
+
# width (16)
|
96
|
+
"\0\0\0\20" <<
|
97
|
+
# height (16)
|
98
|
+
"\0\0\0\20" <<
|
99
|
+
# pixel_data:
|
100
|
+
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\303\351\304J\317\356\320\262\302\351" <<
|
101
|
+
"\303\371\270\346\271\377\243\335\244\377\206\321\210\371n\306p\262M\265" <<
|
102
|
+
"QJ\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\242\335\243\30\342" <<
|
103
|
+
"\365\343\270\346\367\347\377\317\357\320\377\270\346\272\377\244\336" <<
|
104
|
+
"\246\377\217\325\221\377}\315\177\377j\305m\377Y\274\\\377@\256C\270" <<
|
105
|
+
"\36\231\"\30\0\0\0\0\0\0\0\0\0\0\0\0\242\335\243\30\351\367\351\335\347" <<
|
106
|
+
"\367\347\377\337\364\337\377\270\346\272\377\244\336\245\377\217\325" <<
|
107
|
+
"\221\377}\315\177\377j\305m\377Y\274\\\377I\264L\377:\253>\377(\237+" <<
|
108
|
+
"\335\14\213\20\30\0\0\0\0\0\0\0\0\341\364\342\270\346\367\347\377\344" <<
|
109
|
+
"\366\344\377\377\377\377\377\314\354\315\377\216\325\221\377|\315~\377" <<
|
110
|
+
"j\305m\377Y\274\\\377I\263L\377:\253>\377,\2430\377\40\232$\377\17\215" <<
|
111
|
+
"\23\270\0\0\0\0\277\347\300J\345\366\346\377\317\356\320\377\367\374" <<
|
112
|
+
"\367\377\377\377\377\377\345\365\346\377|\315~\377j\304m\377Y\274\\\377" <<
|
113
|
+
"I\264L\377;\253>\377,\2430\377\40\232$\377\24\222\30\377\12\211\16\377" <<
|
114
|
+
"\0u\3J\315\355\317\262\317\356\320\377\307\353\310\377\377\377\377\377" <<
|
115
|
+
"\377\377\377\377\377\377\377\377z\312}\377Y\274\\\377\\\273_\377f\275" <<
|
116
|
+
"i\377,\2420\377\40\232#\377\24\222\30\377\12\211\16\377\2\200\5\377\0" <<
|
117
|
+
"m\3\262\277\350\300\371\270\346\271\377\340\363\341\377\377\377\377\377" <<
|
118
|
+
"\377\377\377\377\377\377\377\377\242\331\244\377H\263L\377\322\354\323" <<
|
119
|
+
"\377\377\377\377\377j\273m\377b\265e\377[\260^\377V\252Y\377U\240W\377" <<
|
120
|
+
"V\223X\373\266\345\267\377\254\340\255\377\377\377\377\377\377\377\377" <<
|
121
|
+
"\377\377\377\377\377\377\377\377\377\325\356\326\377f\275h\377\377\377" <<
|
122
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" <<
|
123
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377\377\240\334\242\377" <<
|
124
|
+
"\314\354\316\377\377\377\377\377\377\377\377\377\217\322\221\377\377" <<
|
125
|
+
"\377\377\377\377\377\377\377\270\340\271\377\377\377\377\377\377\377" <<
|
126
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" <<
|
127
|
+
"\377\377\377\377\377\377\377\377\377\217\324\221\372\360\371\360\377" <<
|
128
|
+
"\377\377\377\377\264\341\266\377H\263L\377\377\377\377\377\377\377\377" <<
|
129
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" <<
|
130
|
+
"\252\317\253\377\0b\3\377\0S\2\377\0F\2\377\0""7\1\371\250\334\251\314" <<
|
131
|
+
"\377\377\377\377\377\377\377\377\\\273_\3779\253=\377\317\352\320\377" <<
|
132
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377r\270s\377\252\317\253" <<
|
133
|
+
"\377\34s\36\377\0S\2\377\0G\2\377\0:\1\377\0.\1\262\274\342\275\206\377" <<
|
134
|
+
"\377\377\377\326\356\326\3779\252<\377+\242/\377i\273l\377\377\377\377" <<
|
135
|
+
"\377\377\377\377\377\306\342\307\377\0p\3\377\0a\3\377\0S\2\377\0F\2" <<
|
136
|
+
"\377\0:\1\377\0/\1\377\0'\1J\377\377\377\34\313\350\314\347N\264R\377" <<
|
137
|
+
",\2420\377\37\231#\377\24\221\30\377\377\377\377\377\377\377\377\377" <<
|
138
|
+
"U\240W\377\0a\3\377\0S\2\377\0F\2\377\0:\1\377\0/\1\377\0$\1\270\0\0" <<
|
139
|
+
"\0\0\0\0\0\0\25\222\31\30%\235)\335\37\231#\377\24\221\30\377\11\211" <<
|
140
|
+
"\15\377\216\306\220\377\343\357\343\377\0a\3\377\0S\2\377\0F\2\377\0" <<
|
141
|
+
":\1\377\0/\1\377\0$\1\335\0\34\0\30\0\0\0\0\0\0\0\0\0\0\0\0\4\204\10" <<
|
142
|
+
"\30\16\211\22\270\11\210\15\377\1\177\5\377\0p\3\377\0a\3\377\0S\2\377" <<
|
143
|
+
"\0F\2\377\0:\1\377\0/\1\377\0#\1\270\0\33\0\30\0\0\0\0\0\0\0\0\0\0\0" <<
|
144
|
+
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0n\3J\0i\3\262\0Y\3\371\0Q\2\377\0C\2\377" <<
|
145
|
+
"\0""6\1\371\0-\1\262\0$\1J\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
146
|
+
|
147
|
+
RED =
|
148
|
+
# Pixbuf magic (0x47646b50)
|
149
|
+
"GdkP" <<
|
150
|
+
# length: header (24) + pixel_data (1024)
|
151
|
+
"\0\0\4\30" <<
|
152
|
+
# pixdata_type (0x1010002)
|
153
|
+
"\1\1\0\2" <<
|
154
|
+
# rowstride (64)
|
155
|
+
"\0\0\0@" <<
|
156
|
+
# width (16)
|
157
|
+
"\0\0\0\20" <<
|
158
|
+
# height (16)
|
159
|
+
"\0\0\0\20" <<
|
160
|
+
# pixel_data:
|
161
|
+
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\351\303\303J\356\317\317\262\351\302" <<
|
162
|
+
"\302\371\346\270\270\377\335\243\243\377\321\206\206\371\306nn\262\265" <<
|
163
|
+
"MMJ\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\335\242\242\30\365" <<
|
164
|
+
"\342\342\270\367\346\346\377\357\317\317\377\346\270\270\377\336\244" <<
|
165
|
+
"\244\377\325\217\217\377\315}}\377\305jj\377\274YY\377\256@@\270\231" <<
|
166
|
+
"\36\36\30\0\0\0\0\0\0\0\0\0\0\0\0\335\242\242\30\367\351\351\335\367" <<
|
167
|
+
"\347\347\377\364\337\337\377\346\270\270\377\336\244\244\377\325\217" <<
|
168
|
+
"\217\377\315}}\377\305jj\377\274YY\377\264II\377\253::\377\237((\335" <<
|
169
|
+
"\213\14\14\30\0\0\0\0\0\0\0\0\364\341\341\270\367\346\346\377\366\344" <<
|
170
|
+
"\344\377\377\377\377\377\354\314\314\377\325\216\216\377\315||\377\305" <<
|
171
|
+
"jj\377\274YY\377\263II\377\253::\377\243,,\377\232\40\40\377\215\17\17" <<
|
172
|
+
"\270\0\0\0\0\347\277\277J\366\345\345\377\356\317\317\377\374\367\367" <<
|
173
|
+
"\377\377\377\377\377\365\345\345\377\315||\377\304jj\377\274YY\377\264" <<
|
174
|
+
"II\377\253;;\377\243,,\377\232\40\40\377\222\24\24\377\211\12\12\377" <<
|
175
|
+
"u\0\0J\355\315\315\262\356\317\317\377\353\307\307\377\377\377\377\377" <<
|
176
|
+
"\377\377\377\377\377\377\377\377\312zz\377\274YY\377\273\\\\\377\275" <<
|
177
|
+
"ff\377\242,,\377\232\40\40\377\222\24\24\377\211\12\12\377\200\2\2\377" <<
|
178
|
+
"m\0\0\262\350\277\277\371\346\270\270\377\363\340\340\377\377\377\377" <<
|
179
|
+
"\377\377\377\377\377\377\377\377\377\331\242\242\377\263HH\377\354\322" <<
|
180
|
+
"\322\377\377\377\377\377\273jj\377\265bb\377\260[[\377\252VV\377\240" <<
|
181
|
+
"UU\377\223VV\373\345\266\266\377\340\254\254\377\377\377\377\377\377" <<
|
182
|
+
"\377\377\377\377\377\377\377\377\377\377\377\356\325\325\377\275ff\377" <<
|
183
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" <<
|
184
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\334\240" <<
|
185
|
+
"\240\377\354\314\314\377\377\377\377\377\377\377\377\377\322\217\217" <<
|
186
|
+
"\377\377\377\377\377\377\377\377\377\340\270\270\377\377\377\377\377" <<
|
187
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" <<
|
188
|
+
"\377\377\377\377\377\377\377\377\377\377\377\324\217\217\372\371\360" <<
|
189
|
+
"\360\377\377\377\377\377\341\264\264\377\263HH\377\377\377\377\377\377" <<
|
190
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" <<
|
191
|
+
"\377\377\317\252\252\377b\0\0\377S\0\0\377F\0\0\3777\0\0\371\334\250" <<
|
192
|
+
"\250\314\377\377\377\377\377\377\377\377\273\\\\\377\25399\377\352\317" <<
|
193
|
+
"\317\377\377\377\377\377\377\377\377\377\377\377\377\377\270rr\377\317" <<
|
194
|
+
"\252\252\377s\34\34\377S\0\0\377G\0\0\377:\0\0\377.\0\0\262\342\274\274" <<
|
195
|
+
"\206\377\377\377\377\356\326\326\377\25299\377\242++\377\273ii\377\377" <<
|
196
|
+
"\377\377\377\377\377\377\377\342\306\306\377p\0\0\377a\0\0\377S\0\0\377" <<
|
197
|
+
"F\0\0\377:\0\0\377/\0\0\377'\0\0J\377\377\377\34\350\313\313\347\264" <<
|
198
|
+
"NN\377\242,,\377\231\37\37\377\221\24\24\377\377\377\377\377\377\377" <<
|
199
|
+
"\377\377\240UU\377a\0\0\377S\0\0\377F\0\0\377:\0\0\377/\0\0\377$\0\0" <<
|
200
|
+
"\270\0\0\0\0\0\0\0\0\222\25\25\30\235%%\335\231\37\37\377\221\24\24\377" <<
|
201
|
+
"\211\11\11\377\306\216\216\377\357\343\343\377a\0\0\377S\0\0\377F\0\0" <<
|
202
|
+
"\377:\0\0\377/\0\0\377$\0\0\335\34\0\0\30\0\0\0\0\0\0\0\0\0\0\0\0\204" <<
|
203
|
+
"\4\4\30\211\16\16\270\210\11\11\377\177\1\1\377p\0\0\377a\0\0\377S\0" <<
|
204
|
+
"\0\377F\0\0\377:\0\0\377/\0\0\377#\0\0\270\33\0\0\30\0\0\0\0\0\0\0\0" <<
|
205
|
+
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0n\0\0Ji\0\0\262Y\0\0\371Q\0\0\377C\0" <<
|
206
|
+
"\0\3776\0\0\371-\0\0\262$\0\0J\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
207
|
+
|
208
|
+
YELLOW =
|
209
|
+
# Pixbuf magic (0x47646b50)
|
210
|
+
"GdkP" <<
|
211
|
+
# length: header (24) + pixel_data (1024)
|
212
|
+
"\0\0\4\30" <<
|
213
|
+
# pixdata_type (0x1010002)
|
214
|
+
"\1\1\0\2" <<
|
215
|
+
# rowstride (64)
|
216
|
+
"\0\0\0@" <<
|
217
|
+
# width (16)
|
218
|
+
"\0\0\0\20" <<
|
219
|
+
# height (16)
|
220
|
+
"\0\0\0\20" <<
|
221
|
+
# pixel_data:
|
222
|
+
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\351\346\303J\356\354\317\262\351\346" <<
|
223
|
+
"\302\371\346\342\270\377\335\331\243\377\321\314\206\371\306\300n\262" <<
|
224
|
+
"\265\256MJ\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\335\331\242" <<
|
225
|
+
"\30\365\363\342\270\367\365\346\377\357\354\317\377\346\343\270\377\336" <<
|
226
|
+
"\332\244\377\325\320\217\377\315\307}\377\305\277j\377\274\265Y\377\256" <<
|
227
|
+
"\247@\270\231\221\36\30\0\0\0\0\0\0\0\0\0\0\0\0\335\331\242\30\367\366" <<
|
228
|
+
"\351\335\367\365\347\377\364\362\337\377\346\343\270\377\336\332\244" <<
|
229
|
+
"\377\325\320\217\377\315\307}\377\305\277j\377\274\265Y\377\264\254I" <<
|
230
|
+
"\377\253\243:\377\237\227(\335\213\202\14\30\0\0\0\0\0\0\0\0\364\363" <<
|
231
|
+
"\341\270\367\365\346\377\366\364\344\377\377\377\377\377\354\352\314" <<
|
232
|
+
"\377\325\320\216\377\315\307|\377\305\276j\377\274\265Y\377\263\254I" <<
|
233
|
+
"\377\253\243:\377\243\233,\377\232\222\40\377\215\205\17\270\0\0\0\0" <<
|
234
|
+
"\347\344\277J\366\365\345\377\356\354\317\377\374\373\367\377\377\377" <<
|
235
|
+
"\377\377\365\364\345\377\315\307|\377\304\276j\377\274\265Y\377\264\254" <<
|
236
|
+
"I\377\253\243;\377\243\233,\377\232\222\40\377\222\211\24\377\211\200" <<
|
237
|
+
"\12\377un\0J\355\353\315\262\356\354\317\377\353\350\307\377\377\377" <<
|
238
|
+
"\377\377\377\377\377\377\377\377\377\377\312\305z\377\274\265Y\377\273" <<
|
239
|
+
"\265\\\377\275\267f\377\242\232,\377\232\222\40\377\222\211\24\377\211" <<
|
240
|
+
"\200\12\377\200w\2\377mf\0\262\350\345\277\371\346\342\270\377\363\362" <<
|
241
|
+
"\340\377\377\377\377\377\377\377\377\377\377\377\377\377\331\325\242" <<
|
242
|
+
"\377\263\254H\377\354\352\322\377\377\377\377\377\273\266j\377\265\257" <<
|
243
|
+
"b\377\260\252[\377\252\244V\377\240\233U\377\223\217V\373\345\341\266" <<
|
244
|
+
"\377\340\335\254\377\377\377\377\377\377\377\377\377\377\377\377\377" <<
|
245
|
+
"\377\377\377\377\356\354\325\377\275\267f\377\377\377\377\377\377\377" <<
|
246
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" <<
|
247
|
+
"\377\377\377\377\377\377\377\377\377\334\330\240\377\354\352\314\377" <<
|
248
|
+
"\377\377\377\377\377\377\377\377\322\315\217\377\377\377\377\377\377" <<
|
249
|
+
"\377\377\377\340\335\270\377\377\377\377\377\377\377\377\377\377\377" <<
|
250
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" <<
|
251
|
+
"\377\377\377\377\377\324\317\217\372\371\370\360\377\377\377\377\377" <<
|
252
|
+
"\341\336\264\377\263\254H\377\377\377\377\377\377\377\377\377\377\377" <<
|
253
|
+
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\317\315\252" <<
|
254
|
+
"\377b[\0\377SN\0\377FB\0\37773\0\371\334\331\250\314\377\377\377\377" <<
|
255
|
+
"\377\377\377\377\273\265\\\377\253\2439\377\352\350\317\377\377\377\377" <<
|
256
|
+
"\377\377\377\377\377\377\377\377\377\270\263r\377\317\315\252\377sm\34" <<
|
257
|
+
"\377SM\0\377GB\0\377:6\0\377.*\0\262\342\337\274\206\377\377\377\377" <<
|
258
|
+
"\356\354\326\377\252\2429\377\242\232+\377\273\266i\377\377\377\377\377" <<
|
259
|
+
"\377\377\377\377\342\340\306\377pi\0\377a[\0\377SN\0\377FA\0\377:6\0" <<
|
260
|
+
"\377/,\0\377'$\0J\377\377\377\34\350\346\313\347\264\255N\377\242\232" <<
|
261
|
+
",\377\231\221\37\377\221\210\24\377\377\377\377\377\377\377\377\377\240" <<
|
262
|
+
"\233U\377a[\0\377SN\0\377FA\0\377:6\0\377/,\0\377$!\0\270\0\0\0\0\0\0" <<
|
263
|
+
"\0\0\222\211\25\30\235\225%\335\231\221\37\377\221\210\24\377\211\200" <<
|
264
|
+
"\11\377\306\302\216\377\357\356\343\377a[\0\377SM\0\377FB\0\377:6\0\377" <<
|
265
|
+
"/,\0\377$\"\0\335\34\32\0\30\0\0\0\0\0\0\0\0\0\0\0\0\204{\4\30\211\201" <<
|
266
|
+
"\16\270\210\177\11\377\177w\1\377ph\0\377a[\0\377SM\0\377FA\0\377:6\0" <<
|
267
|
+
"\377/,\0\377#!\0\270\33\31\0\30\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" <<
|
268
|
+
"\0\0\0\0\0ng\0Jib\0\262YT\0\371QL\0\377C\77\0\37762\0\371-)\0\262$\"" <<
|
269
|
+
"\0J\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
270
|
+
|
271
|
+
$grey_pixbuf = Gdk::Pixbuf.new(GREY.unpack("C*"), true)
|
272
|
+
$green_pixbuf = Gdk::Pixbuf.new(GREEN.unpack("C*"), true)
|
273
|
+
$red_pixbuf = Gdk::Pixbuf.new(RED.unpack("C*"), true)
|
274
|
+
$yellow_pixbuf = Gdk::Pixbuf.new(YELLOW.unpack("C*"), true)
|
275
|
+
|
276
|
+
# build the UI
|
277
|
+
|
278
|
+
$tray = Gtk::StatusIcon.new
|
279
|
+
$tray.pixbuf = $grey_pixbuf
|
280
|
+
|
281
|
+
$menu = Gtk::Menu.new
|
282
|
+
about_item = Gtk::ImageMenuItem.new(Gtk::Stock::ABOUT)
|
283
|
+
quit_item = Gtk::ImageMenuItem.new(Gtk::Stock::QUIT)
|
284
|
+
$menu.append(about_item)
|
285
|
+
$menu.append(Gtk::SeparatorMenuItem.new)
|
286
|
+
$menu.append(quit_item)
|
287
|
+
$menu.show_all
|
288
|
+
|
289
|
+
about_item.signal_connect('activate') {
|
290
|
+
about = Gtk::AboutDialog.new
|
291
|
+
about.signal_connect('response') {
|
292
|
+
about.destroy
|
293
|
+
}
|
294
|
+
about.name = 'CurrentCost Tray Monitor'
|
295
|
+
about.version = '0.1'
|
296
|
+
about.copyright = '© 2008 James Smith'
|
297
|
+
about.comments = 'Heavily based on CCTrayRb: http://rubyforge.org/projects/cctrayrb/'
|
298
|
+
about.license = 'MIT License - see http://github.com/Floppy/currentcost-ruby/tree/master/COPYING'
|
299
|
+
about.website = 'http://github.com/Floppy/currentcost-ruby/wikis/currentcosttraymonitor'
|
300
|
+
about.authors = ['James Smith - james@floppy.org.uk']
|
301
|
+
about.show_all
|
302
|
+
}
|
303
|
+
|
304
|
+
quit_item.signal_connect('activate') {
|
305
|
+
$meter.close
|
306
|
+
Gtk.main_quit
|
307
|
+
}
|
308
|
+
|
309
|
+
$tray.signal_connect('popup_menu') { |icon, button, time|
|
310
|
+
if button == 3 # right mouse button
|
311
|
+
$menu.popup(nil, nil, button, time)
|
312
|
+
end
|
313
|
+
}
|
314
|
+
|
315
|
+
# Meter observer
|
316
|
+
class MeterObserver
|
317
|
+
def update(reading)
|
318
|
+
# Add all channels to get real figure
|
319
|
+
watts = 0
|
320
|
+
reading.channels.each { |c| watts += c[:watts] }
|
321
|
+
# Change icon colour based on power usage
|
322
|
+
case watts
|
323
|
+
when 0..349
|
324
|
+
$tray.pixbuf = $green_pixbuf
|
325
|
+
when 350..999
|
326
|
+
$tray.pixbuf = $yellow_pixbuf
|
327
|
+
else
|
328
|
+
$tray.pixbuf = $red_pixbuf
|
329
|
+
end
|
330
|
+
# Set tooltip
|
331
|
+
$tray.tooltip = "#{watts} watts"
|
332
|
+
rescue
|
333
|
+
$tray.pixbuf = $grey_pixbuf
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
# Create CurrentCost meter connection
|
338
|
+
$meter = CurrentCost::Meter.new(options[:port])
|
339
|
+
obs = MeterObserver.new
|
340
|
+
$meter.add_observer(obs)
|
341
|
+
|
342
|
+
# Go
|
343
|
+
Gtk.main
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Floppy-currentcost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Smith
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-08-
|
12
|
+
date: 2008-08-22 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -19,12 +19,12 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.2.3
|
23
23
|
version:
|
24
24
|
description:
|
25
25
|
email: james@floppy.org.uk
|
26
|
-
executables:
|
27
|
-
|
26
|
+
executables:
|
27
|
+
- currentcost_tray_monitor.rb
|
28
28
|
extensions: []
|
29
29
|
|
30
30
|
extra_rdoc_files: []
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/currentcost/version.rb
|
39
39
|
- lib/currentcost/exceptions.rb
|
40
40
|
- examples/simple.rb
|
41
|
+
- bin/currentcost_tray_monitor.rb
|
41
42
|
has_rdoc: true
|
42
43
|
homepage: http://github.com/Floppy/currentcost-ruby
|
43
44
|
post_install_message:
|