Merge pull request #146 from nevillelyh/neville/volume

make volume +/- delta configurable
This commit is contained in:
streetturtle 2020-05-24 14:14:32 -04:00 committed by GitHub
commit cbfb12590a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 |
| `display_notification` | `false` | Display a notification on mouseover and keypress |
| `notification_position` | `top_right`| The notification position |
| `delta` | 5 | The volume +/- percentage |
## 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 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