You are not logged in.

#1 2012-08-25 22:12:40

Feigr
Member
Registered: 2012-04-26
Posts: 7

AwesomeWM volume widget is not recognizing input

Hi, I am trying to get this volume widget to work:

-- Volume widget

volumecfg = {}
volumecfg.cardid  = 0
volumecfg.channel = "Master"
volumecfg.widget = widget({ type = "textbox", name = "volumecfg.widget", align = "right" })

volumecfg_t = awful.tooltip({ objects = { volumecfg.widget },})
volumecfg_t:set_text("Volume")

-- command must start with a space!
volumecfg.mixercommand = function (command)
       local fd = io.popen("amixer -c " .. volumecfg.cardid .. command)
       local status = fd:read("*all")
       fd:close()

       local volume = string.match(status, "(%d?%d?%d)%%")
       volume = string.format("% 3d", volume)
       status = string.match(status, "%[(o[^%]]*)%]")
       if string.find(status, "on", 1, true) then
               volume = volume .. "%"
       else
               volume = volume .. "M"
       end
       volumecfg.widget.text = volume
end
volumecfg.update = function ()
       volumecfg.mixercommand(" sget " .. volumecfg.channel)
end
volumecfg.up = function ()
       volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 1%+")
end
volumecfg.down = function ()
       volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 1%-")
end
volumecfg.toggle = function ()
       volumecfg.mixercommand(" sset " .. volumecfg.channel .. " toggle")
end
volumecfg.widget:buttons({
       button({ }, 4, function () volumecfg.up() end),
       button({ }, 5, function () volumecfg.down() end),
       button({ }, 1, function () volumecfg.toggle() end)
})
volumecfg.update()

It shows up in the task bar, but I can not interact with it in any way, apart from the text box that pops up on hover. I have other widgets that accept mouse input just fine.
Anyone know what the problem might be?

UPDATE:

I set global keybindings pointing to the functions in the widget as an experiment:

awful.key({ modkey,    }, "0", function () volumecfg.up() end),
awful.key({ modkey,    }, "9", function () volumecfg.down() end),

And it works! So the widget is functional, it's just the mouse interaction that is broken.

When I reload awesome I get this in the console:

/home/zypo/.config/awesome/rc.lua:185: W: luaA_button_new: This function is deprecated and will be removed, see new syntax
/home/zypo/.config/awesome/rc.lua:186: W: luaA_button_new: This function is deprecated and will be removed, see new syntax
/home/zypo/.config/awesome/rc.lua:187: W: luaA_button_new: This function is deprecated and will be removed, see new syntax

those lines are:

       button({ }, 4, function () volumecfg.up() end),
       button({ }, 5, function () volumecfg.down() end),
       button({ }, 1, function () volumecfg.toggle() end)

Last edited by Feigr (2012-08-26 13:02:58)

Offline

#2 2012-09-01 09:46:15

TeaBough
Member
Registered: 2012-06-21
Posts: 17

Re: AwesomeWM volume widget is not recognizing input

Hi, in order to get rid of those warnings, you can try :

 
volumecfg.widget:buttons({awful.util.table.join(
		     awful.button({ }, 4, function () volumecfg.up() end),
		     awful.button({ }, 5, function () volumecfg.down() end),
		     awful.button({ }, 1, function () volumecfg.toggle() end)
					)})

instead of :

 
volumecfg.widget:buttons({
       button({ }, 4, function () volumecfg.up() end),
       button({ }, 5, function () volumecfg.down() end),
       button({ }, 1, function () volumecfg.toggle() end)
})

Offline

Board footer

Powered by FluxBB