From: copycat-killer Date: Mon, 23 Jan 2017 16:58:35 +0000 (+0100) Subject: alsa{bar}: add togglechannel back X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/156515eb28c002300aaf06651f7c412ca2bc07f1?ds=sidebyside alsa{bar}: add togglechannel back --- diff --git a/widgets/alsa.lua b/widgets/alsa.lua index 7c853c9..c86db33 100644 --- a/widgets/alsa.lua +++ b/widgets/alsa.lua @@ -8,6 +8,7 @@ --]] local helpers = require("lain.helpers") +local shell = require("awful.util").shell local wibox = require("wibox") local string = { match = string.match, format = string.format } @@ -22,9 +23,16 @@ local function worker(args) local timeout = args.timeout or 5 local settings = args.settings or function() end - alsa.cmd = args.cmd or "amixer" - alsa.channel = args.channel or "Master" - alsa.last = {} + alsa.cmd = args.cmd or "amixer" + alsa.channel = args.channel or "Master" + alsa.togglechannel = args.togglechannel + + if alsa.togglechannel then + alsa.cmd = { shell, "-c", string.format("%s get %s; %s get %s", + alsa.cmd, alsa.channel, alsa.cmd, alsa.togglechannel) } + end + + alsa.last = {} function alsa.update() helpers.async(alsa.cmd, function(mixer) @@ -39,6 +47,7 @@ local function worker(args) end timer_id = string.format("alsa-%s-%s", alsa.cmd, alsa.channel) + helpers.newtimer(timer_id, timeout, alsa.update) return alsa diff --git a/widgets/alsabar.lua b/widgets/alsabar.lua index bc8d8d3..fde5eec 100644 --- a/widgets/alsabar.lua +++ b/widgets/alsabar.lua @@ -44,6 +44,7 @@ local function worker(args) alsabar.cmd = args.cmd or "amixer" alsabar.channel = args.channel or "Master" + alsabar.togglechannel = args.togglechannel alsabar.colors = args.colors or alsabar.colors alsabar.followtag = args.followtag or false alsabar._notify = args.notify or "on" @@ -54,6 +55,11 @@ local function worker(args) alsabar.notification_preset.font = "Monospace 11" end + if alsabar.togglechannel then + alsabar.cmd = { awful.util.shell, "-c", string.format("%s get %s; %s get %s", + alsabar.cmd, alsabar.channel, alsabar.cmd, alsabar.togglechannel) } + end + alsabar.bar = wibox.widget { forced_height = height, forced_width = width, diff --git a/wiki b/wiki index 85fa41e..66836bb 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 85fa41e74a7ed2923f6e289273e436ff187c6fdc +Subproject commit 66836bbf1ffc0dd3bd3aef4799fff78ded9df4ec