batt 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +10 -0
- data/README.md +15 -4
- data/lib/batt/app.rb +10 -1
- data/lib/batt/reader.rb +3 -1
- data/lib/batt/version.rb +1 -1
- metadata +5 -4
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -35,12 +35,23 @@ Where `action` is one of the following:
|
|
35
35
|
* `remaining` -- amount of time remaining til complete discharge or complete charge
|
36
36
|
* `capacity` -- a percentage of how charged the battery is
|
37
37
|
|
38
|
-
|
38
|
+
## tmux
|
39
39
|
|
40
|
-
|
40
|
+
Tmux support is a work in progress and is one of the primary use-cases for the design
|
41
|
+
of this gem. Currently, only the `capacity` action has tmux support, which can be enabled
|
42
|
+
via passing `--tmux` to it:
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
+
batt capacity --tmux
|
45
|
+
|
46
|
+
Future releases will have additional support for tmux. I just need to work out what
|
47
|
+
it's gonna look like.
|
48
|
+
|
49
|
+
### Example tmux.conf
|
50
|
+
|
51
|
+
Example `tmux` status line configuration. Add this to your .tmux.conf:
|
52
|
+
|
53
|
+
set-option status-right-length 120
|
54
|
+
set-option status-right "[ #(batt source) #(batt capacity --tmux) ] #(date \"+%Y-%m-%d %H:%M\")"
|
44
55
|
|
45
56
|
## Contributing
|
46
57
|
|
data/lib/batt/app.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'pry'
|
1
2
|
module Batt
|
2
3
|
class App < Thor
|
3
4
|
|
@@ -23,10 +24,18 @@ module Batt
|
|
23
24
|
end
|
24
25
|
|
25
26
|
desc "capacity", "spit out the current capacity in % of the battery"
|
27
|
+
option :tmux, :type => :boolean, :desc => 'Enable tmux colour'
|
26
28
|
def capacity
|
27
29
|
b = Batt::Reader.new
|
28
30
|
|
29
|
-
|
31
|
+
c = b.status[:capacity]
|
32
|
+
|
33
|
+
if options[:tmux]
|
34
|
+
color = %w(red yellow green)[c.to_i / 33]
|
35
|
+
puts "#[bg=#{color},fg=black]#{ c }#[default]"
|
36
|
+
else
|
37
|
+
puts c
|
38
|
+
end
|
30
39
|
end
|
31
40
|
|
32
41
|
desc "status", "spit out the status of the battery"
|
data/lib/batt/reader.rb
CHANGED
@@ -13,13 +13,15 @@ module Batt
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
# runs the batteryreader
|
17
|
+
# this could probably be refactored to leverage a class per OS
|
16
18
|
def status
|
17
19
|
@battery_reader.call
|
18
20
|
end
|
19
21
|
|
20
22
|
# figure out which OS is running
|
21
23
|
# this might need to be a little more solid
|
22
|
-
# returns a downcased symbol
|
24
|
+
# returns a downcased symbol (eg: +:darwin+ or +:linux+)
|
23
25
|
def get_os
|
24
26
|
line = Cocaine::CommandLine.new('uname')
|
25
27
|
output = line.run
|
data/lib/batt/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: batt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cocaine
|
@@ -118,6 +118,7 @@ extra_rdoc_files: []
|
|
118
118
|
files:
|
119
119
|
- .gitignore
|
120
120
|
- .rspec
|
121
|
+
- CHANGELOG.md
|
121
122
|
- Gemfile
|
122
123
|
- LICENSE.txt
|
123
124
|
- README.md
|
@@ -145,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
146
|
version: '0'
|
146
147
|
segments:
|
147
148
|
- 0
|
148
|
-
hash:
|
149
|
+
hash: 2248559496602016421
|
149
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
151
|
none: false
|
151
152
|
requirements:
|
@@ -154,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
155
|
version: '0'
|
155
156
|
segments:
|
156
157
|
- 0
|
157
|
-
hash:
|
158
|
+
hash: 2248559496602016421
|
158
159
|
requirements: []
|
159
160
|
rubyforge_project:
|
160
161
|
rubygems_version: 1.8.24
|