summaryrefslogtreecommitdiff
path: root/volume-widget/volume.lua
diff options
context:
space:
mode:
authorstreetturtle <streetturtle@users.noreply.github.com>2021-10-13 19:56:53 -0400
committerGitHub <noreply@github.com>2021-10-13 19:56:53 -0400
commit56b13ca8b1b337e738cf0bd12311d8529211ad07 (patch)
tree4c541d6ba75a43594761f97797f9047dfdc256c5 /volume-widget/volume.lua
parent8c5a58c93c0549c26f76cb199cd307f8ef7026bd (diff)
parentfe6606d51124b1ca3053474d4b625023238a2577 (diff)
Merge pull request #301 from Desour/volume_step_inc_dec
Add a step parameter for volume_widget:inc() and :dec()
Diffstat (limited to 'volume-widget/volume.lua')
-rw-r--r--volume-widget/volume.lua15
1 files changed, 6 insertions, 9 deletions
diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua
index a22effd..2c563b0 100644
--- a/volume-widget/volume.lua
+++ b/volume-widget/volume.lua
@@ -18,8 +18,8 @@ local utils = require("awesome-wm-widgets.volume-widget.utils")
local LIST_DEVICES_CMD = [[sh -c "pacmd list-sinks; pacmd list-sources"]]
local GET_VOLUME_CMD = 'amixer -D pulse sget Master'
-local INC_VOLUME_CMD
-local DEC_VOLUME_CMD
+local function INC_VOLUME_CMD(step) return 'amixer -D pulse sset Master ' .. step .. '%+' end
+local function DEC_VOLUME_CMD(step) return 'amixer -D pulse sset Master ' .. step .. '%-' end
local TOG_VOLUME_CMD = 'amixer -D pulse sset Master toggle'
@@ -168,9 +168,6 @@ local function worker(user_args)
local refresh_rate = args.refresh_rate or 1
local step = args.step or 5
- INC_VOLUME_CMD = 'amixer -D pulse sset Master ' .. step .. '%+'
- DEC_VOLUME_CMD = 'amixer -D pulse sset Master ' .. step .. '%-'
-
if widget_types[widget_type] == nil then
volume.widget = widget_types['icon_and_text'].get_widget(args.icon_and_text_args)
else
@@ -187,12 +184,12 @@ local function worker(user_args)
widget:set_volume_level(volume_level)
end
- function volume:inc()
- spawn.easy_async(INC_VOLUME_CMD, function(stdout) update_graphic(volume.widget, stdout) end)
+ function volume:inc(s)
+ spawn.easy_async(INC_VOLUME_CMD(s or step), function(stdout) update_graphic(volume.widget, stdout) end)
end
- function volume:dec()
- spawn.easy_async(DEC_VOLUME_CMD, function(stdout) update_graphic(volume.widget, stdout) end)
+ function volume:dec(s)
+ spawn.easy_async(DEC_VOLUME_CMD(s or step), function(stdout) update_graphic(volume.widget, stdout) end)
end
function volume:toggle()