]> git.madduck.net Git - etc/awesome.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

widgets fix
authorluke bonham <dadasignificanulla@gmail.com>
Thu, 12 Sep 2013 22:07:44 +0000 (00:07 +0200)
committercopycat-killer <dada@archlinux.info>
Wed, 5 Aug 2015 11:30:30 +0000 (13:30 +0200)
14 files changed:
helpers.lua
widgets/alsa.lua
widgets/bat.lua
widgets/calendar.lua
widgets/cpu.lua
widgets/fs.lua
widgets/imap.lua
widgets/maildir.lua
widgets/mem.lua
widgets/mpd.lua
widgets/net.lua
widgets/sysload.lua
widgets/temp.lua
widgets/yawn/init.lua

index a8c4cd7297bc01c830c06c4df98e0d5e05b1780a..81910d21b206bc2b151cdb9214b84e8bb80e4b3b 100644 (file)
@@ -8,8 +8,10 @@
 --]]
 
 local debug  = require("debug")
-local rawget = rawget
+
+local capi   = { timer = timer }
 local io     = { open = io.open }
+local rawget = rawget
 
 -- Lain helper functions for internal use
 -- lain.helpers
@@ -49,7 +51,7 @@ end
 helpers.timer_table = {}
 
 function helpers.newtimer(name, timeout, fun, nostart)
-    helpers.timer_table[name] = timer({ timeout = timeout })
+    helpers.timer_table[name] = capi.timer({ timeout = timeout })
     helpers.timer_table[name]:connect_signal("timeout", fun)
     helpers.timer_table[name]:start()
     if not nostart then
index 887f398cc11670ceccd3a518f1dcb0c6ca07db92..3e025bbd252712f8f152e65c5a6fc783ffe8348c 100644 (file)
@@ -29,30 +29,31 @@ local function worker(args)
     alsa.widget = wibox.widget.textbox('')
 
     function alsa.update()
-        local f = io.popen('amixer get ' .. channel)
+        local f = assert(io.popen('amixer get ' .. channel))
         local mixer = f:read("*all")
         f:close()
 
-        volume = {}
+        volume_now = {}
 
-        volume.level, volume.status = string.match(mixer, "([%d]+)%%.*%[([%l]*)")
+        volume_now.level, volume_now.status = string.match(mixer, "([%d]+)%%.*%[([%l]*)")
 
-        if volume.level == nil
+        if volume_now.level == nil
         then
-            volume.level  = 0
-            volume.status = "off"
+            volume_now.level  = "0"
+            volume_now.status = "off"
         end
 
-        if volume.status == ""
+        if volume_now.status == ""
         then
-            if volume.level == 0
+            if volume_now.level == "0"
             then
-                volume.status = "off"
+                volume_now.status = "off"
             else
-                volume.status = "on"
+                volume_now.status = "on"
             end
         end
 
+        widget = alsa.widget
         settings()
     end
 
index ba1fa58f0aea99c57444c8c75b810f3ec2fe50aa..09b135fc29bc03463a411471c592b91430f6fa77 100644 (file)
@@ -30,9 +30,9 @@ local function worker(args)
 
     bat.widget = wibox.widget.textbox('')
 
-    function bat.update()
+    function update()
         bat_now = {
-            status = "not present",
+            status = "Not present",
             perc   = "N/A",
             time   = "N/A",
             watt   = "N/A"
@@ -110,7 +110,7 @@ local function worker(args)
         settings()
     end
 
-    newtimer("bat", timeout, bat.update)
+    newtimer("bat", timeout, update)
 
     return bat.widget
 end
index e28e735bf2441ebabf1a47957415712181867697..57fadd946d03acff62d8828cbe40c5459ca9f34b 100644 (file)
@@ -21,12 +21,12 @@ local setmetatable = setmetatable
 -- Calendar notification
 -- lain.widgets.calendar
 local calendar = {}
-local notification = nil
+local cal_notification = nil
 
 function calendar:hide()
-    if notification ~= nil then
-        naughty.destroy(notification)
-        notification = nil
+    if cal_notification ~= nil then
+        naughty.destroy(cal_notification)
+        cal_notification = nil
     end
 end
 
@@ -95,12 +95,12 @@ function calendar:show(t_out, inc_offset)
              .. "</span></tt>"
     f:close()
 
-    notification = naughty.notify({ text = c_text,
-                                    icon = calendar.notify_icon,
-                                    position = calendar.position,
-                                    fg = calendar.fg,
-                                    bg = calendar.bg,
-                                    timeout = tims })
+    cal_notification = naughty.notify({ text = c_text,
+                                        icon = calendar.notify_icon,
+                                        position = calendar.position,
+                                        fg = calendar.fg,
+                                        bg = calendar.bg,
+                                        timeout = tims })
 end
 
 function calendar:attach(widget, args)
index f307b26b3bcc021218555ca0f65ef7e800183209..55a3799457271598d60e05847480a23bf149bc49 100644 (file)
@@ -33,7 +33,7 @@ local function worker(args)
 
     cpu.widget = wibox.widget.textbox('')
 
-    function cpu.update()
+    function update()
         -- Read the amount of time the CPUs have spent performing
         -- different kinds of work. Read the first line of /proc/stat
         -- which is the sum of all CPUs.
@@ -68,7 +68,7 @@ local function worker(args)
         cpu.last_total = total
     end
 
-    newtimer("cpu", timeout, cpu.update)
+    newtimer("cpu", timeout, update)
 
     return cpu.widget
 end
index b5800103673e7287880bacac9a47c85b305f162c..17037c4009c21535a6e83134f27a6d367c5b357b 100644 (file)
@@ -27,7 +27,7 @@ local setmetatable = setmetatable
 local fs = {}
 
 local notification  = nil
-notification_preset = { fg = beautiful.fg_normal }
+fs_notification_preset = { fg = beautiful.fg_normal }
 
 function fs:hide()
     if notification ~= nil then
@@ -44,7 +44,7 @@ function fs:show(t_out)
     f:close()
 
     notification = naughty.notify({
-        preset = notification_preset,
+        preset = fs_notification_preset,
         text = ws,
        timeout = t_out
     })
@@ -63,7 +63,7 @@ local function worker(args)
 
     helpers.set_map("fs", false)
 
-    function fs.update()
+    function update()
         fs_info = {} 
 
         local f = io.popen("LC_ALL=C df -kP")
@@ -108,20 +108,12 @@ local function worker(args)
         end
     end
 
-    helpers.newtimer(partition, timeout, fs.update)
+    helpers.newtimer(partition, timeout, update)
 
     widget:connect_signal('mouse::enter', function () fs:show(0) end)
     widget:connect_signal('mouse::leave', function () fs:hide() end)
 
-    output = {
-        widget = fs.widget,
-        show = function(t_out)
-                  fs.update()
-                  fs:show(t_out)
-               end
-    }
-
-    return setmetatable(output, { __index = output.widget })
+    return setmetatable(fs, { __index = fs.widget })
 end
 
 return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
index 4df3610db18364fdfb4b5fa63e3a6c3b97249928..6574276221e54de1f138dc1e6389ddf9d781f576 100644 (file)
@@ -47,8 +47,8 @@ local function worker(args)
 
     imap.widget = wibox.widget.textbox('')
 
-    function imap.update()
-        notification_preset = {
+    function update()
+        mail_notification_preset = {
             icon     = helpers.icons_dir .. "mail.png",
             position = "top_left"
         }
@@ -73,13 +73,13 @@ local function worker(args)
             else
                 nt = mail .. " has <b>" .. mailcount .. "</b> new messages"
             end
-            naughty.notify({ preset = notification_preset, text = nt })
+            naughty.notify({ preset = mail_notification_preset, text = nt })
         end
 
         helpers.set_map(mail, mailcount)
     end
 
-    helpers.newtimer(mail, timeout, imap.update, true)
+    helpers.newtimer(mail, timeout, update, true)
     return imap.widget
 end
 
index 4ac34bc25fece45f199de6a001b025cbff331447..d4608812e7c62e92e30cfced6eae628b747fc393 100644 (file)
@@ -33,7 +33,7 @@ local function worker(args)
 
     maildir.widget = wibox.widget.textbox('')
 
-    function maildir.update()
+    function update()
         -- Find pathes to mailboxes.
         local p = io.popen("find " .. mailpath ..
                            " -mindepth 1 -maxdepth 1 -type d" ..
@@ -88,8 +88,7 @@ local function worker(args)
         settings()
     end
 
-    newtimer(mailpath, timeout, maildir.update, true)
-
+    newtimer(mailpath, timeout, update, true)
     return maildir.widget
 end
 
index f0141494247700b4c3ee6ec8295a129fc2b3f743..78ed3e0a4076705e3254de5f9340de491c6806da 100644 (file)
@@ -1,12 +1,10 @@
 
 --[[
-                                                           
-     Licensed under GNU General Public License v2          
-      * (c) 2013,      Luke Bonham                         
-      * (c) 2010-2012, Peter Hofmann                       
-      * (c) 2010,      Adrian C.      <anrxc@sysphere.org> 
-      * (c) 2009,      Lucas de Vries <lucas@glacicle.com> 
-                                                           
+                                                   
+     Licensed under GNU General Public License v2  
+      * (c) 2013,      Luke Bonham                 
+      * (c) 2010-2012, Peter Hofmann               
+                                                   
 --]]
 
 local newtimer        = require("lain.helpers").newtimer
@@ -32,30 +30,30 @@ local function worker(args)
 
     mem.widget = wibox.widget.textbox('')
 
-    function mem.update()
-        mem = {}
+    function update()
+        mem_now = {}
         for line in io.lines("/proc/meminfo")
         do
             for k, v in string.gmatch(line, "([%a]+):[%s]+([%d]+).+")
             do
-                if     k == "MemTotal"  then mem.total = math.floor(v / 1024)
-                elseif k == "MemFree"   then mem.free  = math.floor(v / 1024)
-                elseif k == "Buffers"   then mem.buf   = math.floor(v / 1024)
-                elseif k == "Cached"    then mem.cache = math.floor(v / 1024)
-                elseif k == "SwapTotal" then mem.swap  = math.floor(v / 1024)
-                elseif k == "SwapFree"  then mem.swapf = math.floor(v / 1024)
+                if     k == "MemTotal"  then mem_now.total = math.floor(v / 1024)
+                elseif k == "MemFree"   then mem_now.free  = math.floor(v / 1024)
+                elseif k == "Buffers"   then mem_now.buf   = math.floor(v / 1024)
+                elseif k == "Cached"    then mem_now.cache = math.floor(v / 1024)
+                elseif k == "SwapTotal" then mem_now.swap  = math.floor(v / 1024)
+                elseif k == "SwapFree"  then mem_now.swapf = math.floor(v / 1024)
                 end
             end
         end
 
-        used = mem.total - (mem.free + mem.buf + mem.cache)
-        swapused = mem.swap - mem.swapf
+        mem_now.used = mem_now.total - (mem_now.free + mem_now.buf + mem_now.cache)
+        mem_now.swapused = mem_now.swap - mem_now.swapf
 
         widget = mem.widget
         settings()
     end
 
-    newtimer("mem", timeout, mem.update)
+    newtimer("mem", timeout, update)
 
     return mem.widget
 end
index 016f2a3a4e5de2a150e7276c810e7507601548ea..cd97b37cb5fee86377b85d2bca9e218ecbddbdc2 100644 (file)
@@ -40,7 +40,7 @@ local function worker(args)
 
     mpd.widget = wibox.widget.textbox('')
 
-    notification_preset = {
+    mpd_notification_preset = {
         title   = "Now playing",
         timeout = 6
     }
@@ -73,8 +73,8 @@ local function worker(args)
 
         f:close()
 
-        notification_preset.text = string.format("%s (%s) - %s\n%s", mpd_now.artist,
-                                   mpd_now.album, mpd_now.date, mpd_now.title)
+        mpd_notification_preset.text = string.format("%s (%s) - %s\n%s", mpd_now.artist,
+                                       mpd_now.album, mpd_now.date, mpd_now.title)
         widget = mpd.widget
         settings()
 
@@ -87,7 +87,7 @@ local function worker(args)
                 os.execute(string.format("%s %q %q", mpdcover, music_dir, mpd_now.file))
 
                 mpd.id = naughty.notify({
-                    preset = notification_preset,
+                    preset = mpd_notification_preset,
                     icon = "/tmp/mpdcover.png",
                     replaces_id = mpd.id
                 }).id
index d692df1268976f75a44379cab22bd227e22c6717..b3deca6b471a68bd4e3640b9a4f54fc49874ca37 100644 (file)
@@ -50,23 +50,25 @@ local function worker(args)
 
     helpers.set_map(iface, true)
 
-    function net.update() 
+    function update() 
+        net_now = {}
+
         if iface == "" then iface = net.get_device() end
 
-        carrier = helpers.first_line('/sys/class/net/' .. iface ..
+        net_now.carrier = helpers.first_line('/sys/class/net/' .. iface ..
                                            '/carrier') or "0"
-        state = helpers.first_line('/sys/class/net/' .. iface ..
+        net_now.state = helpers.first_line('/sys/class/net/' .. iface ..
                                            '/operstate') or "down"
         local now_t = helpers.first_line('/sys/class/net/' .. iface ..
                                            '/statistics/tx_bytes') or 0
         local now_r = helpers.first_line('/sys/class/net/' .. iface ..
                                            '/statistics/rx_bytes') or 0
 
-        sent = tostring((now_t - net.last_t) / timeout / units)
-        sent = string.gsub(string.format('%.1f', sent), ",", ".")
+        net_now.sent = tostring((now_t - net.last_t) / timeout / units)
+        net_now.sent = string.gsub(string.format('%.1f', net_now.sent), ",", ".")
 
-        received = tostring((now_r - net.last_r) / timeout / units)
-        received = string.gsub(string.format('%.1f', received), ",", ".")
+        net_now.received = tostring((now_r - net.last_r) / timeout / units)
+        net_now.received = string.gsub(string.format('%.1f', net_now.received), ",", ".")
 
         widget = net.widget
         settings()
@@ -74,7 +76,7 @@ local function worker(args)
         net.last_t = now_t
         net.last_r = now_r
 
-        if carrier ~= "1"
+        if net_now.carrier ~= "1"
         then
             if helpers.get_map(iface)
             then
@@ -95,8 +97,7 @@ local function worker(args)
         end
     end
 
-    helpers.newtimer(iface, timeout, net.update)
-
+    helpers.newtimer(iface, timeout, update)
     return net.widget
 end
 
index 90bdedfbcde5149e82d3c18c3dbd85bf2160ef0d..868398c9f6b593855b67a6f47fd7785f54dd93a8 100644 (file)
@@ -28,19 +28,18 @@ local function worker(args)
 
     sysload.widget = wibox.widget.textbox('')
 
-    function sysload.update()
+    function update()
         local f = io.open("/proc/loadavg")
         local ret = f:read("*all")
         f:close()
         
-        a, b, c = string.match(ret, "([^%s]+) ([^%s]+) ([^%s]+)")
+        load_1, load_5, load_15 = string.match(ret, "([^%s]+) ([^%s]+) ([^%s]+)")
 
         widget = sysload.widget
         settings()
     end
 
-    newtimer("sysload", timeout, sysload.update)
-
+    newtimer("sysload", timeout, update)
     return sysload.widget
 end
 
index e5681389faffcad70a828b17665be2c3bb2ca9e8..b57c477929b1e0315b03b0ba4181671aa4278289 100644 (file)
@@ -26,7 +26,7 @@ local function worker(args)
 
     temp.widget = wibox.widget.textbox('')
 
-    function temp.update()
+    function update()
         local f = io.open("/sys/class/thermal/thermal_zone0/temp")
         coretemp_now = tonumber(f:read("*all")) / 1000
         f:close()
@@ -34,8 +34,7 @@ local function worker(args)
         settings()
     end
 
-    newtimer("coretemp", timeout, temp.update)
-
+    newtimer("coretemp", timeout, update)
     return temp.widget
 end
 
index 4d14966b17e827df82d1963ece8dd5989f3aaa00..4c90df4c440795f7e8e4e59f66f4374776e69078 100644 (file)
@@ -43,7 +43,7 @@ local city_id             = nil
 local sky                 = nil
 local settings            = function() end
 
-notification_preset = {}
+yawn_notification_preset = {}
 
 local function fetch_weather()
     local url = api_url .. units_set .. city_id
@@ -56,6 +56,7 @@ local function fetch_weather()
     -- widgets won't display
     if text == "" or text:match("City not found")
     then
+        yawn.icon:set_image(icon_path .. "na.png")
         if text == "" then
             weather_data = "Service not available at the moment."
             yawn.widget:set_text("N/A")
@@ -152,7 +153,7 @@ function yawn.show(t_out)
     yawn.hide()
 
     notification = naughty.notify({
-        preset = notification_preset,
+        preset = yawn_notification_preset,
         text = weather_data,
         icon = sky,
         timeout = t_out