summaryrefslogtreecommitdiff
path: root/volume-widget
diff options
context:
space:
mode:
authorNeville Li <neville.lyh@gmail.com>2020-05-23 09:30:22 -0400
committerNeville Li <neville.lyh@gmail.com>2020-05-23 09:30:22 -0400
commita44a3591ebfe1c119138c67cb334ab2b5fb40a12 (patch)
treedf44a44aee618bc7a050d22069c163a415fb9b9e /volume-widget
parent232e504f46ac07b1d03ea45f197a633fe3a9e9fd (diff)
make volume +/- delta configurable
Diffstat (limited to 'volume-widget')
-rw-r--r--volume-widget/README.md1
-rw-r--r--volume-widget/volume.lua7
2 files changed, 5 insertions, 3 deletions
diff --git a/volume-widget/README.md b/volume-widget/README.md
index 065a504..cd53f49 100644
--- a/volume-widget/README.md
+++ b/volume-widget/README.md
@@ -13,6 +13,7 @@ It is possible to customize widget by providing a table with all or some of the
| `volume_audio_controller`| `pulse` | audio device |
| `display_notification` | `false` | Display a notification on mouseover and keypress |
| `notification_position` | `top_right`| The notification position |
+| `delta` | 5 | The volume +/- percentage |
## Installation
diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua
index f04e829..1a670ef 100644
--- a/volume-widget/volume.lua
+++ b/volume-widget/volume.lua
@@ -19,17 +19,17 @@ local PATH_TO_ICONS = "/usr/share/icons/Arc/status/symbolic/"
local volume_icon_name="audio-volume-high-symbolic"
local GET_VOLUME_CMD = 'amixer sget Master'
-local volume = {device = '', display_notification = false, notification = nil}
+local volume = {device = '', display_notification = false, notification = nil, delta = 5}
function volume:toggle()
volume:_cmd('amixer ' .. volume.device .. ' sset Master toggle')
end
function volume:raise()
- volume:_cmd('amixer ' .. volume.device .. ' sset Master 5%+')
+ volume:_cmd('amixer ' .. volume.device .. ' sset Master ' .. tostring(volume.delta) .. '%+')
end
function volume:lower()
- volume:_cmd('amixer ' .. volume.device .. ' sset Master 5%-')
+ volume:_cmd('amixer ' .. volume.device .. ' sset Master ' .. tostring(volume.delta) .. '%-')
end
--{{{ Icon and notification update
@@ -98,6 +98,7 @@ local function worker(args)
if volume_audio_controller == 'pulse' then
volume.device = '-D pulse'
end
+ volume.delta = args.delta or 5
GET_VOLUME_CMD = 'amixer ' .. volume.device.. ' sget Master'
--}}}
--{{{ Check for icon path