Hey,
I'm playing a little with widgets and trying to use very simple and
compact  icon+progress bar and add a naughty notification on mouse
over to show details.
It's quite all right, but:

I find that creating the notification I have to call the function that
runs the script with the info again.
For example: in the volume widget, I run a function to get the volume
level and set the progress bar value, but when I want to create the
notification, I have to call the same function (and more importantly:
the script) again. I think it would be better to just show the value
of the progress bar, but I see no way o getting it, there's just
setter methods and no getters.

Also, is it possible to alter the text of an existing notification?
Back to the volume example: when the user has the mouse over the
widget, he scrolls the wheel to alter the volume. But the notification
does not reflect this change and keeps showing the old value.
Currently, I'm replacing the notification with a new one, but it
flashes a little.

Additionally, is it possible to get a widget's geometry, so I could
create a naughty notification just below the widget and not far far
away in the corner of the screen?

Sorry for mixing all this in one single e-mail, but it's all kinda
related, see my code below (heavily based on anrxc's configs)

-- {{{ Volume level
volicon = widget({ type = "imagebox" })
volicon.image = image(beautiful.widget_vol)
-- Initialize widgets
volbar    = awful.widget.progressbar()
volwidget = widget({ type = "textbox" })
-- Progressbar properties
volbar:set_vertical(true):set_ticks(false)
volbar:set_width(8)--:set_height(12)
volbar:set_background_color(beautiful.fg_off_widget)
volbar:set_gradient_colors({ beautiful.fg_widget,
   beautiful.fg_center_widget, beautiful.fg_end_widget
}) -- Enable caching
vicious.cache(vicious.widgets.volume)
-- Register widgets
vicious.register(volbar,    vicious.contrib.pulse,  "$1",  2)
vicious.register(volwidget, vicious.contrib.pulse, " $1%", 2)
-- Register buttons
volbar.widget:buttons(awful.util.table.join(
    awful.button({ }, 1, function () awful.util.spawn("pavucontrol") end),
    awful.button({ }, 4, function ()
        vicious.contrib.pulse.add(5)
        volbar:set_value(vicious.contrib.pulse.getVolume()/100)
        local v = math.floor(vicious.contrib.pulse.getVolume() + 0.5)
        if volinfo ~= nil then
            volinfo = naughty.notify({ text = v .. "%", icon =
beautiful.widget_vol, replaces_id = volinfo.id })
        else
            volinfo = naughty.notify({ text = v .. "%", icon =
beautiful.widget_vol })
        end
    end),
    awful.button({ }, 5, function ()
        vicious.contrib.pulse.add(-5)
        volbar:set_value(vicious.contrib.pulse.getVolume()/100)
        local v = math.floor(vicious.contrib.pulse.getVolume() + 0.5)
        --naughty.destroy(volinfo)
        if volinfo ~= nil then
            volinfo = naughty.notify({ text = v .. "%", icon =
beautiful.widget_vol, replaces_id = volinfo.id })
        else
            volinfo = naughty.notify({ text = v .. "%", icon =
beautiful.widget_vol })
        end
    end)
)) -- Register assigned buttons
--volwidget:buttons(volbar.widget:buttons())
-- Mouseover
volbar.widget:add_signal("mouse::enter", function()
    local v = vicious.contrib.pulse.getVolume()
    volinfo = naughty.notify({ text = v .. "%", icon = beautiful.widget_vol })
end)
volbar.widget:add_signal("mouse::leave", function()
    if volinfo ~= nil then
        naughty.destroy(volinfo)
        volinfo = nil
    end
end)
-- }}}


Thanks!

-- 
To unsubscribe, send mail to [email protected].

Reply via email to