Mike Hix avatar Mike Hix committed d740e7d

Whitespace fixes, better example.

Comments (0)

Files changed (4)

data/example.dock_driver.yml

 ---
-dock_driver:
-    command: 'dzen2'
-    template: ''
 dock:
-    items:
-        - name: gronald
-          command: foo --bar baz
-          frequency: 1.5
-        - name: aphrodite
-          command: feeblebeeble -vqnf 42
-          scan: 'Gort: (\d+)'
-          frequency: 3
+
+  template: 
+    '
+    ^fg(gray75)<%= user %>^fg(gray50)@^fg(gray75)<%= host %>
+    ^fg(skyblue2)<%= day %>
+    ^fg(skyblue3)<%= date %>
+    ^fg(white)mail <%= mail %>
+    ^fg(white)uptime ^fg(skyblue4)<%= uptime %>
+    '
+  command:
+    dzen2 -dock -ta r -x 0 -y 0 -w 1920 -h 18 -bg black -fg white
+    -fn "-*-terminus-medium-r-*-*-10-*-*-*-*-*-*-*"
+    -e "button3="
+
+  items:
+    - name: day
+      command: date '+%A'
+      frequency: 60
+    - name: date
+      command: date '+%F'
+      frequency: 1
+    - name: uptime
+      command: uptime
+      frequency: 5
+    - name: user
+      command: 'whoami'
+      frequency: 600
+    - name: host
+      command: 'hostname'
+      frequency: 600
+    - name: mail
+      command: 'dock_mail.rb'
+
 logging:
-    __default__: warn (color)
-    dock_driver: debug (color)
+  __default__: warn (color)
+  dock_driver: warn (color)

lib/dock_driver.rb

     log_as :dock_driver
 
     # Project version.
-    VERSION = '0.2.0'
+    VERSION = '0.2.1'
 
     # Project revision.
     REVISION = %$Revision$

lib/dock_driver/dock.rb

             merged    = CONFIG_DEFAULTS.merge( section )
             @items    = merged[:items]
             @command  = merged[:command]
-            @template = ERB.new( merged[:template] )
+            @template = ERB.new( merged[:template].strip.gsub( /\s+/, ' ' ) )
         end
 
         #####################################################################
         ### Provide output for the dock.
         def to_s
             vbind = OpenStruct.new( self.items ).send( :binding )
-            return self.class.template.result( vbind ).gsub( /\s+/, ' ' )
+            return self.class.template.result( vbind )
         end
 
     end

lib/dock_driver/dock_item.rb

         def run
             self.log.debug "%s is running." % self.name
             loop do
+                self.output = `#{self.command}`.strip.gsub( /\s+/, ' ')
+                # TODO output scanning
+                self.notify_observers
                 sleep self.frequency
-                # TODO output scanning
-                self.output = `#{self.command}`
-                self.notify_observers
             end
         end
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.