make volume +/- delta configurable

This commit is contained in:
Neville Li 2020-05-23 09:30:22 -04:00
parent 232e504f46
commit a44a3591eb
2 changed files with 5 additions and 3 deletions

View File

@ -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 | | `volume_audio_controller`| `pulse` | audio device |
| `display_notification` | `false` | Display a notification on mouseover and keypress | | `display_notification` | `false` | Display a notification on mouseover and keypress |
| `notification_position` | `top_right`| The notification position | | `notification_position` | `top_right`| The notification position |
| `delta` | 5 | The volume +/- percentage |
## Installation ## Installation

View File

@ -19,17 +19,17 @@ local PATH_TO_ICONS = "/usr/share/icons/Arc/status/symbolic/"
local volume_icon_name="audio-volume-high-symbolic" local volume_icon_name="audio-volume-high-symbolic"
local GET_VOLUME_CMD = 'amixer sget Master' 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() function volume:toggle()
volume:_cmd('amixer ' .. volume.device .. ' sset Master toggle') volume:_cmd('amixer ' .. volume.device .. ' sset Master toggle')
end end
function volume:raise() function volume:raise()
volume:_cmd('amixer ' .. volume.device .. ' sset Master 5%+') volume:_cmd('amixer ' .. volume.device .. ' sset Master ' .. tostring(volume.delta) .. '%+')
end end
function volume:lower() function volume:lower()
volume:_cmd('amixer ' .. volume.device .. ' sset Master 5%-') volume:_cmd('amixer ' .. volume.device .. ' sset Master ' .. tostring(volume.delta) .. '%-')
end end
--{{{ Icon and notification update --{{{ Icon and notification update
@ -98,6 +98,7 @@ local function worker(args)
if volume_audio_controller == 'pulse' then if volume_audio_controller == 'pulse' then
volume.device = '-D pulse' volume.device = '-D pulse'
end end
volume.delta = args.delta or 5
GET_VOLUME_CMD = 'amixer ' .. volume.device.. ' sget Master' GET_VOLUME_CMD = 'amixer ' .. volume.device.. ' sget Master'
--}}} --}}}
--{{{ Check for icon path --{{{ Check for icon path