summaryrefslogtreecommitdiff
path: root/volume-widget
diff options
context:
space:
mode:
authorstreetturtle <streetturtle@users.noreply.github.com>2020-11-14 20:27:00 -0500
committerGitHub <noreply@github.com>2020-11-14 20:27:00 -0500
commitbec2154948dd75c1c4a9b846a468910c5b62bc77 (patch)
tree8f7940359ecf3c35b48f275d7703efbdc59eecf7 /volume-widget
parent88d6697d8db81343cb44b637ebcb376176807fe5 (diff)
parent0915a81e5432c0e742bbd1114584b0e6d58e15e6 (diff)
Merge pull request #205 from robstoll/volume-battery-right-click
show notification on right click for volume/battery
Diffstat (limited to 'volume-widget')
-rw-r--r--volume-widget/volume.lua19
1 files changed, 12 insertions, 7 deletions
diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua
index 1a670ef..0e13f38 100644
--- a/volume-widget/volume.lua
+++ b/volume-widget/volume.lua
@@ -19,7 +19,7 @@ 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, delta = 5}
+local volume = {device = '', display_notification = false, display_notification_onClick = true, notification = nil, delta = 5}
function volume:toggle()
volume:_cmd('amixer ' .. volume.device .. ' sset Master toggle')
@@ -64,14 +64,14 @@ end
local function update_graphic(widget, stdout, _, _, _)
local txt = parse_output(stdout)
widget.image = PATH_TO_ICONS .. volume_icon_name .. ".svg"
- if volume.display_notification then
+ if (volume.display_notification or volume.display_notification_onClick) then
volume.notification.iconbox.image = PATH_TO_ICONS .. volume_icon_name .. ".svg"
naughty.replace_text(volume.notification, "Volume", txt)
end
end
local function notif(msg, keep)
- if volume.display_notification then
+ if (volume.display_notification or (keep and volume.display_notification_onClick)) then
naughty.destroy(volume.notification)
volume.notification= naughty.notify{
text = msg,
@@ -94,6 +94,7 @@ local function worker(args)
local volume_audio_controller = args.volume_audio_controller or 'pulse'
volume.display_notification = args.display_notification or false
+ volume.display_notification_onClick = args.display_notification_onClick or true
volume.position = args.notification_position or "top_right"
if volume_audio_controller == 'pulse' then
volume.device = '-D pulse'
@@ -134,10 +135,9 @@ local function worker(args)
end
local function show()
- spawn.easy_async(GET_VOLUME_CMD,
- function(stdout, _, _, _)
- txt = parse_output(stdout)
- notif(txt, true)
+ spawn.easy_async(GET_VOLUME_CMD, function(stdout, _, _, _)
+ txt = parse_output(stdout)
+ notif(txt, true)
end
)
end
@@ -156,6 +156,11 @@ local function worker(args)
if volume.display_notification then
volume.widget:connect_signal("mouse::enter", function() show() end)
volume.widget:connect_signal("mouse::leave", function() naughty.destroy(volume.notification) end)
+ elseif volume.display_notification_onClick then
+ volume.widget:connect_signal("button::press", function(_,_,_,button)
+ if (button == 3) then show() end
+ end)
+ volume.widget:connect_signal("mouse::leave", function() naughty.destroy(volume.notification) end)
end
--}}}