Commits

Mike Hix  committed d740e7d

Whitespace fixes, better example.

  • Participants
  • Parent commits b320a30

Comments (0)

Files changed (4)

File 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)

File lib/dock_driver.rb

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

File 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

File 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