dag-amazing 0.1

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.
Files changed (42) hide show
  1. data/LICENSE +202 -0
  2. data/README.rdoc +72 -0
  3. data/bin/amazing +19 -0
  4. data/lib/amazing.rb +24 -0
  5. data/lib/amazing/awesome.rb +46 -0
  6. data/lib/amazing/cli.rb +66 -0
  7. data/lib/amazing/cli/commands.rb +240 -0
  8. data/lib/amazing/cli/helpers.rb +159 -0
  9. data/lib/amazing/cli/initializers.rb +60 -0
  10. data/lib/amazing/config.rb +66 -0
  11. data/lib/amazing/config/dsl.rb +32 -0
  12. data/lib/amazing/config/dsl/awesome.rb +26 -0
  13. data/lib/amazing/config/dsl/awesome/widget.rb +27 -0
  14. data/lib/amazing/config/yaml.rb +11 -0
  15. data/lib/amazing/helpers/pango_markup.rb +26 -0
  16. data/lib/amazing/numeric.rb +50 -0
  17. data/lib/amazing/options.rb +93 -0
  18. data/lib/amazing/proc_file.rb +59 -0
  19. data/lib/amazing/string.rb +19 -0
  20. data/lib/amazing/widget.rb +140 -0
  21. data/lib/amazing/widgets.rb +37 -0
  22. data/lib/amazing/widgets/ac_adapter.rb +31 -0
  23. data/lib/amazing/widgets/alsa.rb +35 -0
  24. data/lib/amazing/widgets/battery.rb +51 -0
  25. data/lib/amazing/widgets/clock.rb +31 -0
  26. data/lib/amazing/widgets/cpu_info.rb +35 -0
  27. data/lib/amazing/widgets/cpu_usage.rb +50 -0
  28. data/lib/amazing/widgets/file.rb +44 -0
  29. data/lib/amazing/widgets/file_system.rb +42 -0
  30. data/lib/amazing/widgets/gmail.rb +61 -0
  31. data/lib/amazing/widgets/maildir.rb +34 -0
  32. data/lib/amazing/widgets/memory.rb +47 -0
  33. data/lib/amazing/widgets/moc.rb +80 -0
  34. data/lib/amazing/widgets/mpd.rb +146 -0
  35. data/lib/amazing/widgets/net_traffic.rb +50 -0
  36. data/lib/amazing/widgets/noop.rb +24 -0
  37. data/lib/amazing/widgets/pacman.rb +34 -0
  38. data/lib/amazing/widgets/raggle.rb +42 -0
  39. data/lib/amazing/widgets/sup.rb +38 -0
  40. data/lib/amazing/x11.rb +15 -0
  41. data/lib/amazing/x11/display_name.rb +50 -0
  42. metadata +101 -0
@@ -0,0 +1,50 @@
1
+ # Copyright 2008 Dag Odenhall <dag.odenhall@gmail.com>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'amazing/widget'
16
+ require 'amazing/proc_file'
17
+
18
+ module Amazing
19
+ module Widgets
20
+ class NetTraffic < Widget
21
+ description "Network traffic information"
22
+ option :interface, "Network interface", "eth0"
23
+ option :upload_peak, "Maximum upstream of your Internet connection in kB/s", 56
24
+ option :download_peak, "Maximum downstream of your Internet connection in kB/s", 56
25
+ field :upload_rate, "Upload rate in kB/s"
26
+ field :download_rate, "Download rate in kB/s"
27
+ field :upload_total, "Amount of data uploaded in kB/s"
28
+ field :download_total, "Amount of data downloaded in kB/s"
29
+ field :upload_percentage, "Percentage upload"
30
+ field :download_percentage, "Percentage download"
31
+ default { @download_percentage.to_i }
32
+
33
+ init do
34
+ dev = ProcFile.parse_file("net/dev")[2][@interface].split
35
+ first_down = dev[0].to_f
36
+ first_up = dev[8].to_f
37
+ sleep 1
38
+ dev = ProcFile.parse_file("net/dev")[2][@interface].split
39
+ second_down = dev[0].to_f
40
+ second_up = dev[8].to_f
41
+ @download_rate = (second_down - first_down) / 1024
42
+ @download_total = second_down / 1024
43
+ @upload_rate = (second_up - first_up) / 1024
44
+ @upload_total = second_up / 1024
45
+ @upload_percentage = @upload_rate * 100 / @upload_peak
46
+ @download_percentage = @download_rate * 100 / @download_peak
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,24 @@
1
+ # Copyright 2008 Dag Odenhall <dag.odenhall@gmail.com>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'amazing/widget'
16
+
17
+ module Amazing
18
+ module Widgets
19
+ class Noop < Widget
20
+ description "Does nothing"
21
+ init {}
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ # Copyright 2008 Dag Odenhall <dag.odenhall@gmail.com>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'amazing/widget'
16
+
17
+ module Amazing
18
+ module Widgets
19
+ class Pacman < Widget
20
+ description "Available upgrades in the Pacman package manager"
21
+ option :pacman, "Path to the pacman program", "pacman"
22
+ field :packages, "List of available upgrades", []
23
+ field :count, "New package count", 0
24
+ default { @count }
25
+
26
+ init do
27
+ IO.popen("#@pacman --query --upgrades") do |io|
28
+ @packages = io.read.scan(/Targets: (.+)\n\n/m).to_s.split
29
+ @count = @packages.size
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,42 @@
1
+ # Copyright 2008 Dag Odenhall <dag.odenhall@gmail.com>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'amazing/widget'
16
+
17
+ module Amazing
18
+ module Widgets
19
+ class Raggle < Widget
20
+ description "Unread posts in raggle"
21
+ dependency "pstore", "Ruby standard library"
22
+ option :feed_list_path, "Path to feeds list", "~/.raggle/feeds.yaml"
23
+ option :feed_cache_path, "Path to feeds cache", "~/.raggle/feed_cache.store"
24
+ field :count, "Ammount of unread posts", 0
25
+ default { @count }
26
+
27
+ init do
28
+ @feed_list_path = ::File.expand_path(@feed_list_path, "~")
29
+ feeds = YAML.load_file(@feed_list_path)
30
+ @feed_cache_path = ::File.expand_path(@feed_cache_path, "~")
31
+ cache = PStore.new(@feed_cache_path)
32
+ cache.transaction(false) do
33
+ feeds.each do |feed|
34
+ cache[feed["url"]].each do |item|
35
+ @count += 1 unless item["read?"]
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,38 @@
1
+ # Copyright 2008 Dag Odenhall <dag.odenhall@gmail.com>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'amazing/widget'
16
+
17
+ begin
18
+ require 'rubygems'
19
+ rescue LoadError
20
+ end
21
+
22
+ module Amazing
23
+ module Widgets
24
+ class Sup < Widget
25
+ description "Mail count in sup for the specified search terms"
26
+ dependency "sup", "gem install sup, http://sup.rubyforge.org/"
27
+ option :terms, "Search terms", "label:inbox -label:deleted -label:spam"
28
+ field :count, "Number of messages matching search terms"
29
+ default { @count }
30
+
31
+ init do
32
+ Redwood::Index.new
33
+ Redwood::Index.load
34
+ @count = Redwood::Index.index.search_each(@terms) {}
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,15 @@
1
+ # Copyright 2008 Dag Odenhall <dag.odenhall@gmail.com>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'amazing/x11/display_name'
@@ -0,0 +1,50 @@
1
+ # Copyright 2008 Dag Odenhall <dag.odenhall@gmail.com>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Amazing
16
+ module X11
17
+
18
+ # Raised by DisplayName#new if called with empty argument, or without
19
+ # argument and ENV["DISPLAY"] is empty.
20
+ class EmptyDisplayName < ArgumentError
21
+ end
22
+
23
+ # Raised by DisplayName#new if format of argument or ENV["DISPLAY"] is
24
+ # invalid.
25
+ class InvalidDisplayName < ArgumentError
26
+ end
27
+
28
+ # Parse an X11 display name
29
+ #
30
+ # display = DisplayName.new("hostname:displaynumber.screennumber")
31
+ # display.hostname #=> "hostname"
32
+ # display.display #=> "displaynumber"
33
+ # display.screen #=> "screennumber"
34
+ #
35
+ # Without arguments, reads ENV["DISPLAY"]. With empty argument or
36
+ # DISPLAY environment, raises EmptyDisplayName. With invalid display name
37
+ # format, raises InvalidDisplayName.
38
+ class DisplayName
39
+ attr_reader :hostname, :display, :screen
40
+
41
+ def initialize(display_name=ENV["DISPLAY"])
42
+ raise EmptyDisplayName, "No display name supplied" if ["", nil].include? display_name
43
+ @hostname, @display, @screen = display_name.scan(/^(.*):(\d+)(?:\.(\d+))?$/)[0]
44
+ raise InvalidDisplayName, "Invalid display name" if @display.nil?
45
+ @hostname = "localhost" if @hostname.empty?
46
+ @screen = "0" unless @screen
47
+ end
48
+ end
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dag-amazing
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.1"
5
+ platform: ruby
6
+ authors:
7
+ - Dag Odenhall
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-05-03 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: dag.odenhall@gmail.com
18
+ executables:
19
+ - amazing
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - lib/amazing/cli/commands.rb
26
+ - lib/amazing/cli/initializers.rb
27
+ - lib/amazing/cli/helpers.rb
28
+ - lib/amazing/x11/display_name.rb
29
+ - lib/amazing/numeric.rb
30
+ - lib/amazing/string.rb
31
+ - lib/amazing/awesome.rb
32
+ - lib/amazing/widgets.rb
33
+ - lib/amazing/config.rb
34
+ - lib/amazing/options.rb
35
+ - lib/amazing/cli.rb
36
+ - lib/amazing/config/dsl/awesome.rb
37
+ - lib/amazing/config/dsl/awesome/widget.rb
38
+ - lib/amazing/config/yaml.rb
39
+ - lib/amazing/config/dsl.rb
40
+ - lib/amazing/proc_file.rb
41
+ - lib/amazing/helpers/pango_markup.rb
42
+ - lib/amazing/widget.rb
43
+ - lib/amazing/x11.rb
44
+ - lib/amazing/widgets/clock.rb
45
+ - lib/amazing/widgets/net_traffic.rb
46
+ - lib/amazing/widgets/ac_adapter.rb
47
+ - lib/amazing/widgets/cpu_usage.rb
48
+ - lib/amazing/widgets/file.rb
49
+ - lib/amazing/widgets/gmail.rb
50
+ - lib/amazing/widgets/raggle.rb
51
+ - lib/amazing/widgets/moc.rb
52
+ - lib/amazing/widgets/mpd.rb
53
+ - lib/amazing/widgets/noop.rb
54
+ - lib/amazing/widgets/sup.rb
55
+ - lib/amazing/widgets/alsa.rb
56
+ - lib/amazing/widgets/maildir.rb
57
+ - lib/amazing/widgets/pacman.rb
58
+ - lib/amazing/widgets/cpu_info.rb
59
+ - lib/amazing/widgets/battery.rb
60
+ - lib/amazing/widgets/memory.rb
61
+ - lib/amazing/widgets/file_system.rb
62
+ - lib/amazing.rb
63
+ - bin/amazing
64
+ - LICENSE
65
+ has_rdoc: true
66
+ homepage: http://amazing.rubyforge.org
67
+ post_install_message:
68
+ rdoc_options:
69
+ - --main
70
+ - README.rdoc
71
+ - --charset
72
+ - utf-8
73
+ - --inline-source
74
+ - --line-numbers
75
+ - --webcvs
76
+ - http://github.com/dag/amazing/tree/master/%s
77
+ - --title
78
+ - amazing api
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: "0"
86
+ version:
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: "0"
92
+ version:
93
+ requirements: []
94
+
95
+ rubyforge_project: amazing
96
+ rubygems_version: 1.0.1
97
+ signing_key:
98
+ specification_version: 2
99
+ summary: An amazing widget manager for an awesome window manager
100
+ test_files: []
101
+