On Thu, Jul 31, 2014 at 6:06 AM, Navi Charlotte <[email protected]> wrote:
> So I got the play/pause and previous/next song working like this:
>
> in the global keys table:
> -- Short-cuts for media play control
> awful.key({modkey}, "Insert",  nil, function () os.execute("xdotool key 
> --delay 0 XF86AudioPlay") end ),
> awful.key({modkey}, "Home",  nil, function ()  os.execute("xdotool key 
> --delay 0 XF86AudioPrev")  end ),
> awful.key({modkey}, "End",    nil, function ()  os.execute("xdotool key 
> --delay 0 XF86AudioNext")  end ),
>
> The mute and volume up/down keys still refuse to work, so I went and just 
> assigned the keys in KDE configuration to have kmix control the volume.
>
> Again, thanks for the tip and I hope this helps someone else looking for some 
> media key emulation in a media key-less keyboard :)

I use Ubuntu and have done all these using a additional lines under
globalkeys, where I invoke amixer (commandline utility) to achieve
this. audioind is a function to display the audio volume in systray.

----------------------- begin code snippet -----------
    -- Audio Control Buttons
    awful.key({ modkey, "Control" }, "Up",   function ()
awful.util.spawn("amixer set Master 10%+ unmute")

awful.util.spawn("amixer set Speaker unmute")

awful.util.spawn("amixer set Headphone unmute")
                                                         audioind()
                                         end),
    awful.key({ modkey, "Control" }, "Down", function ()
awful.util.spawn("amixer set Master 10%- unmute")

awful.util.spawn("amixer set Speaker unmute")

awful.util.spawn("amixer set Headphone unmute")
                                                         audioind()
                                         end),
    awful.key({ modkey, "Control" }, "Left", function ()
awful.util.spawn("amixer set Master mute")
                                                         audioind()
                                         end),
    awful.key({ modkey, "Control" }, "Right",function ()
awful.util.spawn("amixer set Master 100% unmute")

awful.util.spawn("amixer set Speaker 100% unmute")

awful.util.spawn("amixer set Headphone 100% unmute")
                                                         audioind()
                                         end),
------------------------------------ end code snippet -----------

------------------ begin code snippet at the end of rc.lua ------------------
-- Audio indicator in systray
function audioind()
         status = io.popen("amixer get Master"):read("*all")
         vol = tonumber(string.match(status, "(%d?%d?%d)%%"))

         status = string.match(status, "%[(o[^%]]*)%]")

         local color = "#FF0000"
         if string.find(status, "on", 1, true) then
              color = "#00FF00"
         end
         status = ""
         for i = 1, math.floor(vol / 20) do
             status = status .. "I"
         end
         for i = math.floor(vol / 20) + 1, 5 do
             status = status .. "."
         end
         status = "[" ..status .. "]"
         status = "<span color=\"" .. color .. "\">" .. status .. "</span>"
         volume:set_markup(status)
         barwidget:set_color(color)
         barwidget:set_background_color("#000000")
         barwidget:set_border_color(color)
         barwidget:set_value(vol/100)
end
-- First invocation to update audio indicator in systray
audioind()
---------------------------------------- end of code snippet ------------

Hope this helps.

-- Mohan Sundaram

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

Reply via email to