barr 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/README.md +122 -123
- data/barr.gemspec +2 -1
- data/examples/README.md +0 -2
- data/examples/all_in.rb +39 -44
- data/examples/barr_example.rb +6 -6
- data/examples/fizzbuzz.rb +14 -15
- data/examples/i3_cpu_mem.rb +12 -9
- data/examples/rhythm.rb +7 -8
- data/examples/time_and_date.rb +5 -5
- data/examples/two_temperatures.rb +11 -11
- data/exe/barr_example +6 -6
- data/exe/barr_i3ipc +1 -1
- data/lib/barr.rb +12 -9
- data/lib/barr/block.rb +51 -26
- data/lib/barr/blocks/clock.rb +6 -4
- data/lib/barr/blocks/cpu.rb +17 -3
- data/lib/barr/blocks/hdd.rb +15 -7
- data/lib/barr/blocks/i3.rb +15 -6
- data/lib/barr/blocks/ip.rb +16 -11
- data/lib/barr/blocks/mem.rb +7 -3
- data/lib/barr/blocks/rhythmbox.rb +65 -0
- data/lib/barr/blocks/temperature.rb +20 -11
- data/lib/barr/blocks/whoami.rb +25 -0
- data/lib/barr/manager.rb +49 -36
- data/lib/barr/version.rb +1 -1
- metadata +19 -5
- data/lib/barr/blocks/rhythm_box.rb +0 -55
- data/lib/barr/blocks/who_am_i.rb +0 -15
@@ -1,55 +0,0 @@
|
|
1
|
-
module Barr
|
2
|
-
module Blocks
|
3
|
-
|
4
|
-
class Rhythmbox < Block
|
5
|
-
attr_reader :show_title, :show_buttons, :show_artist
|
6
|
-
|
7
|
-
def initialize opts={}
|
8
|
-
super
|
9
|
-
@show_title = opts[:show_title].nil? ? true : opts[:show_title]
|
10
|
-
@show_artist = opts[:show_artist].nil? ? true : opts[:show_artist]
|
11
|
-
@show_buttons = opts[:show_buttons].nil? ? true : opts[:show_buttons]
|
12
|
-
end
|
13
|
-
|
14
|
-
def update
|
15
|
-
op = []
|
16
|
-
|
17
|
-
if @show_artist || @show_title
|
18
|
-
if(running?)
|
19
|
-
info = sys_cmd("--print-playing").split(" - ")
|
20
|
-
if @show_artist && @show_title
|
21
|
-
op << info.join(" - ")
|
22
|
-
elsif @show_artist
|
23
|
-
op << info[0]
|
24
|
-
elsif @show_title
|
25
|
-
op << info[1]
|
26
|
-
end
|
27
|
-
else
|
28
|
-
op << "None"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
op << buttons if @show_buttons
|
33
|
-
|
34
|
-
@output = op.join(" ")
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
def running?
|
39
|
-
@running ||= (`pgrep rhythmbox`.length >= 1 ) ? true : false
|
40
|
-
end
|
41
|
-
|
42
|
-
def buttons
|
43
|
-
@buttons ||= [
|
44
|
-
"%{A:rhythmbox-client --previous:}\uf048%{A}",
|
45
|
-
"%{A:rhythmbox-client --play-pause:}\uf04b%{A}",
|
46
|
-
"%{A:rhythmbox-client --next:}\uf051%{A}"
|
47
|
-
].join(" ")
|
48
|
-
end
|
49
|
-
|
50
|
-
def sys_cmd cmd
|
51
|
-
`rhythmbox-client #{cmd}`
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|