]> git.madduck.net Git - etc/awesome.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Add a card attribute for alsa and alsabar
authoremikkva <mikko.valkonen@ericsson.com>
Mon, 16 Feb 2015 21:43:06 +0000 (23:43 +0200)
committercopycat-killer <dada@archlinux.info>
Wed, 5 Aug 2015 11:31:15 +0000 (13:31 +0200)
Currently alsa.lua and alsabar.lua do not support the amixer command
line option "-c" which allows defining which card to use. For at
least new Dell E-series laptops, the card is not the default (0) and
therefore this functionality is required for these widgets to work.

widgets/alsa.lua
widgets/alsabar.lua

index f62a150d18fcd7969accaeb53118841117d05107..5a4335e63b7624a61f49389d0c4d21f252dd99a1 100644 (file)
@@ -12,7 +12,8 @@ local newtimer        = require("lain.helpers").newtimer
 local wibox           = require("wibox")
 
 local io              = { popen  = io.popen }
-local string          = { match  = string.match }
+local string          = { match  = string.match,
+                          format = string.format }
 
 local setmetatable    = setmetatable
 
@@ -22,6 +23,7 @@ local alsa = {}
 
 local function worker(args)
     local args     = args or {}
+    local card     = args.card or "0"
     local timeout  = args.timeout or 5
     local channel  = args.channel or "Master"
     local settings = args.settings or function() end
@@ -29,7 +31,7 @@ local function worker(args)
     alsa.widget = wibox.widget.textbox('')
 
     function alsa.update()
-        local f = assert(io.popen('amixer -M get ' .. channel))
+        local f = assert(io.popen(string.format("amixer -c %s -M get %s", card, channel)))
         local mixer = f:read("*a")
         f:close()
 
index 65a2b33018ea043e6c2458030058e00096fcc9b8..fa10bc2e4215ad1e16d42e7bc27aa4ac93f05205 100644 (file)
@@ -25,6 +25,7 @@ local setmetatable = setmetatable
 -- ALSA volume bar
 -- lain.widgets.alsabar
 local alsabar = {
+    card    = "0",
     channel = "Master",
     step    = "5%",
 
@@ -97,6 +98,7 @@ local function worker(args)
     local ticks_size = args.ticks_size or 7
     local vertical = args.vertical or false
 
+    alsabar.card = args.card or alsabar.card
     alsabar.channel = args.channel or alsabar.channel
     alsabar.step = args.step or alsabar.step
     alsabar.colors = args.colors or alsabar.colors
@@ -115,7 +117,7 @@ local function worker(args)
 
     function alsabar.update()
         -- Get mixer control contents
-        local f = io.popen("amixer -M get " .. alsabar.channel)
+        local f = assert(io.popen(string.format("amixer -c %s -M get %s", alsabar.card, alsabar.channel)))
         local mixer = f:read("*a")
         f:close()
 
@@ -129,7 +131,6 @@ local function worker(args)
 
         alsabar._current_level = tonumber(volu)
         alsabar.bar:set_value(alsabar._current_level / 100)
-
         if not mute and tonumber(volu) == 0 or mute == "off"
         then
             alsabar._muted = true
@@ -154,15 +155,15 @@ local function worker(args)
             awful.util.spawn(alsabar.mixer)
           end),
           awful.button ({}, 3, function()
-            awful.util.spawn(string.format("amixer set %s toggle", alsabar.channel))
+            awful.util.spawn(string.format("amixer -c %s set %s toggle", alsabar.card, alsabar.channel))
             alsabar.update()
           end),
           awful.button ({}, 4, function()
-            awful.util.spawn(string.format("amixer set %s %s+", alsabar.channel, alsabar.step))
+            awful.util.spawn(string.format("amixer -c %s set %s %s+", alsabar.card, alsabar.channel, alsabar.step))
             alsabar.update()
           end),
           awful.button ({}, 5, function()
-            awful.util.spawn(string.format("amixer set %s %s-", alsabar.channel, alsabar.step))
+            awful.util.spawn(string.format("amixer -c %s set %s %s-", alsabar.card, alsabar.channel, alsabar.step))
             alsabar.update()
           end)
     ))