Try changing

This...

>       volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 
>toggle")

To this...

>       volumecfg.mixercommand(" sset " .. volumecfg.channel .. " toggle") 


PS: Here's my version which has 4 different icons depending on the level,
click toggles mute, wheel up/down over icon changes volume & tool tip gives
actual value...

-- Volume widget
myvolume = {}
myvolume.cardid  = 0
myvolume.channel = "Headphone"  -- edit as appropriate [often "Master"]
myvolume.widget = widget({ type = "imagebox", name = "myvolume.widget" })
myvolume.tooltip = awful.tooltip({ objects = { myvolume.widget },})

myvolume.mixercommand = function (command)
                                                        local fd =
io.popen("amixer -c " .. myvolume.cardid .. " " .. command)
                                                        local status =
fd:read("*all")
                                                        fd:close()

                                                        local volume =
string.match(status, "(%d?%d?%d)%%")

                                                        status =
string.match(status, "%[(o[^%]]*)%]")
                                                        if
string.find(status, "on", 1, true) then
                                                                if
tonumber(volume) < 50 then 
        
myvolume.widget.image = image(awful.util.getdir("config") ..
"/icons/audio-volume-low.png")
                                                                elseif
tonumber(volume) < 100 then 
        
myvolume.widget.image = image(awful.util.getdir("config") ..
"/icons/audio-volume-medium.png")
                                                                else 
        
myvolume.widget.image = image(awful.util.getdir("config") ..
"/icons/audio-volume-high.png")
                                                                end
                                                        else
        
myvolume.widget.image = image(awful.util.getdir("config") ..
"/icons/audio-volume-muted.png")
                                                        end

        
myvolume.tooltip:set_text(volume .. "%")
                                                end

myvolume.update = function () myvolume.mixercommand("sget " ..
myvolume.channel) end
myvolume.up = function () myvolume.mixercommand("sset " .. myvolume.channel
.. " 1%+") end
myvolume.down = function () myvolume.mixercommand("sset " ..
myvolume.channel .. " 1%-") end
myvolume.toggle = function () myvolume.mixercommand("sset " ..
myvolume.channel .. " toggle") end
myvolume.widget:buttons(        {
                                                                button({ },
4, function () myvolume.up() end),
                                                                button({ },
5, function () myvolume.down() end),
                                                                button({ },
1, function () myvolume.toggle() end)
                                                        })

myvolume.update()


David Sorkovsky

+61 468 478 438


-----Original Message-----
From: pyLemon [mailto:leeway1...@gmail.com] 
Sent: Tuesday, 17 July 2012 11:21 PM
To: Abhijeet R
Cc: awesome@naquadah.org; David Gomes
Subject: Re: change gnome-sound-applet icon in awesome

thanks for your quick reply Abhijeet, and thanks David Gomes. I have google
that page. haha, And I have seen someone has successful changed that icon.
but I don't know how..

this is my volume applet config

-- 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("<span color='#1793d1'>%3d</span>",
volume)
       status = string.match(status, "%[(o[^%]]*)%]")
       if string.find(status, "on", 1, true) then
               volume = volume .. "<span color='#1793d1'>%</span>"
       else
               volume = volume .. "<span color='#ff5656'>M</span>"
       end
       volumecfg.widget.text = volume
end
volumecfg.update = function ()
       volumecfg.mixercommand(" sget " .. volumecfg.channel) end
volumecfg.up = function ()
       volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 2%+") end
volumecfg.down = function ()
       volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 2%-") 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()

-----------EOF

the problem is , when I click the widget and it execute
volumecfg.toggle() , the computer gets mute, and I can't get it unmute 
unless I use the gnome-sound-applet or something like that..   what do 
you think about that problem?

pylemon


于Tue 17 Jul 2012 05:36:36 PM CST,Abhijeet R写到:
> Well, I actually don't have a solution but you can use vicious to 
> create a widget like this.
>
> -- {{{ Volume level
> volicon = widget({ type = "imagebox" }) volicon.image = 
> image(awful.util.getdir("config") .. "/icons/vol.png")
>
> volwidget = widget({ type = "textbox" })
> vicious.cache(vicious.widgets.volume)
> -- Register widgets
> vicious.register(volwidget, vicious.widgets.volume, " $1%", 2, 
> "Master")
> -- Register buttons
> volwidget:buttons(awful.util.table.join(
>   awful.button({ }, 1, function () exec("gnome-alsamixer") end),
>   awful.button({ }, 4, function () exec("amixer -q set Master 2dB+",
> false) vicious.force({volwidget}) end),
>   awful.button({ }, 5, function () exec("amixer -q set Master 2dB-",
> false) vicious.force({volwidget}) end)
> ))
>
> In the above configuration, scrolling on the textwidget changes the 
> sound too. Also, clicking on it opens gnome-alsamixer.
>
> On Tue 17 Jul 2012 02:52:42 PM IST, David Gomes wrote:
>> I've had the same problem:
>> http://askubuntu.com/questions/105614/change-gnome-sound-applet-icon
>>
>> I couldn't really get an answer, not sure if it's possible. I just 
>> ended up using a textbox to display my sound, but I'd love to find a 
>> way around this too.
>>
>> On Tue, Jul 17, 2012 at 8:37 AM, pyLemon <leeway1...@gmail.com 
>> <mailto:leeway1...@gmail.com>> wrote:
>>
>>     hi:
>>
>>     I use the gnome-sound-applet to control sound in my awesome
>>     settings, and it has a full black icon. However, my top panel is
>>     also black, so I can't see the icon.
>>
>>     Is it possible to change the icon? Thanks!
>>
>>
>>     best regards,
>>     pylemon
>>
>>     --
>>     To unsubscribe, send mail to awesome-unsubscribe@naquadah.__org
>>     <mailto:awesome-unsubscr...@naquadah.org>.
>>
>>
>



--
To unsubscribe, send mail to awesome-unsubscr...@naquadah.org.


-- 
To unsubscribe, send mail to awesome-unsubscr...@naquadah.org.

Reply via email to