I want to have two volume widgets: Master, PCM
every volume widget has bar and textbox widget.
bellowing code is in my rc.lua. but it has error. I hope you can figure out. 
Thanks


-- {{{ Volume level
volicon = widget({ type = "imagebox" })
volicon.image = image(beautiful.widget_vol)
-- Initialize widgets
vol.master.widget = widget({ type = "textbox" })
vol.pcm.widget = widget({ type = "textbox" })
volbar = {
  master = awful.widget.progressbar(), pcm = awful.widget.progressbar(),
}
-- Progressbar properties
for _, volbar in pairs(vol) do
    volbar:set_vertical(true):set_ticks(true)
    volbar:set_height(16):set_width(8):set_ticks_size(2)
    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
  volbar.widget:buttons(awful.util.table.join(
    awful.button({ }, 1, function () exec("rox", false) end)
  ))
end -- Enable caching
vicious.cache(vicious.widgets.volume)
-- Register widgets
-- vicious.register(volwidget, vicious.widgets.volume, " $1%", 2, "PCM")
vicious.register(volbar.master.widget,    vicious.widgets.volume,  "$1",  2, 
"Master")
vicious.register(vol.master.widget, vicious.widgets.volume,
    function (widget, args)
        if args[1] == 0 or args[2] == "♩" then
            return "" .. cgrey .. "♪ " .. coldef .. cred .. "mute" .. coldef .. 
""
        else
            return "" .. ccyan .. "♪ " .. coldef .. ccyan .. args[1] .. "%" .. 
coldef .. ""
        end
    end, 2, "Master" )
vicious.register(volbar.pcm.widget,    vicious.widgets.volume,  "$1",  2, "PCM")
vicious.register(vol.pcm.widget, vicious.widgets.volume,
    function (widget, args)
        if args[1] == 0 or args[2] == "♩" then
            return "" .. cgrey .. "♪ " .. coldef .. cred .. "mute" .. coldef .. 
""
        else
            return "" .. ccyan .. "♪ " .. coldef .. ccyan .. args[1] .. "%" .. 
coldef .. ""
        end
    end, 2, "PCM" )
-- Register buttons
volbar.widget:buttons(awful.util.table.join(
   awful.button({ }, 1, function () exec("kmix") end),
   awful.button({ }, 4, function () exec("amixer -q set PCM 2dB+", false) end),
   awful.button({ }, 5, function () exec("amixer -q set PCM 2dB-", false) end)
)) -- Register assigned buttons
volwidget:buttons(volbar.widget:buttons())
-- }}}

-- 
>> stardiviner <<  =>GPG: 5D9F64D8 Twitter: @numbchild
http://stardiviner.dyndns-blog.com/author.html
-- {{{ Volume level
volicon = widget({ type = "imagebox" })
volicon.image = image(beautiful.widget_vol)
-- Initialize widgets
vol.master.widget = widget({ type = "textbox" })
vol.pcm.widget = widget({ type = "textbox" })
volbar = {
  master = awful.widget.progressbar(), pcm = awful.widget.progressbar(),
}
-- Progressbar properties
for _, volbar in pairs(vol) do
    volbar:set_vertical(true):set_ticks(true)
    volbar:set_height(16):set_width(8):set_ticks_size(2)
    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
  volbar.widget:buttons(awful.util.table.join(
    awful.button({ }, 1, function () exec("rox", false) end)
  ))
end -- Enable caching
vicious.cache(vicious.widgets.volume)
-- Register widgets
-- vicious.register(volwidget, vicious.widgets.volume, " $1%", 2, "PCM")
vicious.register(volbar.master.widget,    vicious.widgets.volume,  "$1",  2, 
"Master")
vicious.register(vol.master.widget, vicious.widgets.volume,
    function (widget, args)
        if args[1] == 0 or args[2] == "♩" then
            return "" .. cgrey .. "♪ " .. coldef .. cred .. "mute" .. coldef .. 
""
        else
            return "" .. ccyan .. "♪ " .. coldef .. ccyan .. args[1] .. "%" .. 
coldef .. ""
        end
    end, 2, "Master" )
vicious.register(volbar.pcm.widget,    vicious.widgets.volume,  "$1",  2, "PCM")
vicious.register(vol.pcm.widget, vicious.widgets.volume,
    function (widget, args)
        if args[1] == 0 or args[2] == "♩" then
            return "" .. cgrey .. "♪ " .. coldef .. cred .. "mute" .. coldef .. 
""
        else
            return "" .. ccyan .. "♪ " .. coldef .. ccyan .. args[1] .. "%" .. 
coldef .. ""
        end
    end, 2, "PCM" )
-- Register buttons
volbar.widget:buttons(awful.util.table.join(
   awful.button({ }, 1, function () exec("kmix") end),
   awful.button({ }, 4, function () exec("amixer -q set PCM 2dB+", false) end),
   awful.button({ }, 5, function () exec("amixer -q set PCM 2dB-", false) end)
)) -- Register assigned buttons
volwidget:buttons(volbar.widget:buttons())
-- }}}

Attachment: signature.asc
Description: Digital signature

Reply via email to