barr 0.1.2 → 0.2.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.
@@ -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
@@ -1,15 +0,0 @@
1
- module Barr
2
- module Blocks
3
-
4
- class WhoAmI < Block
5
- def initialize opts={}
6
- super
7
- @output = sys_cmd
8
- end
9
-
10
- def sys_cmd
11
- `whoami`.chomp
12
- end
13
- end
14
- end
15
- end