From 156515eb28c002300aaf06651f7c412ca2bc07f1 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Mon, 23 Jan 2017 17:58:35 +0100 Subject: [PATCH 1/1] alsa{bar}: add togglechannel back --- widgets/alsa.lua | 15 ++++++++++++--- widgets/alsabar.lua | 6 ++++++ wiki | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) 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 -- 2.39.5