show notification on right click for volume/battery
This commit is contained in:
parent
ef9292d082
commit
0915a81e54
|
@ -40,4 +40,7 @@ luac.out
|
||||||
*.hex
|
*.hex
|
||||||
|
|
||||||
# IDEA files
|
# IDEA files
|
||||||
.idea
|
.idea
|
||||||
|
|
||||||
|
# vscode files
|
||||||
|
.history
|
|
@ -32,6 +32,7 @@ local function worker(args)
|
||||||
local margin_right = args.margin_right or 0
|
local margin_right = args.margin_right or 0
|
||||||
|
|
||||||
local display_notification = args.display_notification or false
|
local display_notification = args.display_notification or false
|
||||||
|
local display_notification_onClick = args.display_notification_onClick or true
|
||||||
local position = args.notification_position or "top_right"
|
local position = args.notification_position or "top_right"
|
||||||
local timeout = args.timeout or 10
|
local timeout = args.timeout or 10
|
||||||
|
|
||||||
|
@ -182,7 +183,13 @@ local function worker(args)
|
||||||
if display_notification then
|
if display_notification then
|
||||||
battery_widget:connect_signal("mouse::enter", function() show_battery_status(batteryType) end)
|
battery_widget:connect_signal("mouse::enter", function() show_battery_status(batteryType) end)
|
||||||
battery_widget:connect_signal("mouse::leave", function() naughty.destroy(notification) end)
|
battery_widget:connect_signal("mouse::leave", function() naughty.destroy(notification) end)
|
||||||
|
elseif display_notification_onClick then
|
||||||
|
battery_widget:connect_signal("button::press", function(_,_,_,button)
|
||||||
|
if (button == 3) then show_battery_status(batteryType) end
|
||||||
|
end)
|
||||||
|
battery_widget:connect_signal("mouse::leave", function() naughty.destroy(notification) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return wibox.container.margin(battery_widget, margin_left, margin_right)
|
return wibox.container.margin(battery_widget, margin_left, margin_right)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ 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, delta = 5}
|
local volume = {device = '', display_notification = false, display_notification_onClick = true, 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')
|
||||||
|
@ -64,14 +64,14 @@ end
|
||||||
local function update_graphic(widget, stdout, _, _, _)
|
local function update_graphic(widget, stdout, _, _, _)
|
||||||
local txt = parse_output(stdout)
|
local txt = parse_output(stdout)
|
||||||
widget.image = PATH_TO_ICONS .. volume_icon_name .. ".svg"
|
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"
|
volume.notification.iconbox.image = PATH_TO_ICONS .. volume_icon_name .. ".svg"
|
||||||
naughty.replace_text(volume.notification, "Volume", txt)
|
naughty.replace_text(volume.notification, "Volume", txt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function notif(msg, keep)
|
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)
|
naughty.destroy(volume.notification)
|
||||||
volume.notification= naughty.notify{
|
volume.notification= naughty.notify{
|
||||||
text = msg,
|
text = msg,
|
||||||
|
@ -94,6 +94,7 @@ local function worker(args)
|
||||||
|
|
||||||
local volume_audio_controller = args.volume_audio_controller or 'pulse'
|
local volume_audio_controller = args.volume_audio_controller or 'pulse'
|
||||||
volume.display_notification = args.display_notification or false
|
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"
|
volume.position = args.notification_position or "top_right"
|
||||||
if volume_audio_controller == 'pulse' then
|
if volume_audio_controller == 'pulse' then
|
||||||
volume.device = '-D pulse'
|
volume.device = '-D pulse'
|
||||||
|
@ -134,10 +135,9 @@ local function worker(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function show()
|
local function show()
|
||||||
spawn.easy_async(GET_VOLUME_CMD,
|
spawn.easy_async(GET_VOLUME_CMD, function(stdout, _, _, _)
|
||||||
function(stdout, _, _, _)
|
txt = parse_output(stdout)
|
||||||
txt = parse_output(stdout)
|
notif(txt, true)
|
||||||
notif(txt, true)
|
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -156,6 +156,11 @@ local function worker(args)
|
||||||
if volume.display_notification then
|
if volume.display_notification then
|
||||||
volume.widget:connect_signal("mouse::enter", function() show() end)
|
volume.widget:connect_signal("mouse::enter", function() show() end)
|
||||||
volume.widget:connect_signal("mouse::leave", function() naughty.destroy(volume.notification) 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
|
end
|
||||||
--}}}
|
--}}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue