Package: awesome-extra
Version: 2009050201
Severity: wishlist

Hi,
it would be nice to have default gateway interface info available in
widgets.net so to auto-display relevant stats whenever the default
interface changes.
Below there's a proof of concept patch (not tested) for having like
${default rx} ${default tx} etc available

--- /usr/share/awesome/lib/wicked.lua   2009-05-01 19:25:43.000000000 +0200
+++ wicked.lua  2009-06-20 22:43:07.000000000 +0200
@@ -496,9 +496,25 @@
 end
 -- }}}
 
+local function default_gw()
+   local f = io.open('/proc/net/route')
+    local res = nil
+    for line in f:lines() do
+        -- XXX http://lua-users.org/wiki/CommonFunctions
+        line = split(line, '\t')
+        if line[1] == "00000000" and line[3] == "0003" then
+            res = line[0]
+        end
+    end
+
+    f:close()
+    return res 
+end
+
 ---- {{{ Net widget type
 function widgets.net(format, padding)
     local f = io.open('/proc/net/dev')
+    local gw = default_gw()
     args = {}
 
     for line in f:lines() do
@@ -582,6 +598,15 @@
 
             nets[name][1] = line[1]
             nets[name][2] = line[9]
+
+            if name == gw then
+                -- copy default gateway keys
+                for _, v in ipairs(args) do
+                    local def = v:gsub(v, name, 'default', 1)
+                    args[def] = args[v]
+                end
+                args['default'] = name
+            end
         end
     end

thanks,
filippo

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (990, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.29.4 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

awesome-extra depends on no packages.

Versions of packages awesome-extra recommends:
ii  awesome                       3.3.1-1    highly configurable, next generati

awesome-extra suggests no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to