mirror of
https://github.com/elenapan/dotfiles.git
synced 2026-01-10 11:12:37 +08:00
33 lines
1 KiB
Lua
33 lines
1 KiB
Lua
local naughty = require("naughty")
|
|
local icons = require("icons")
|
|
local notifications = require("notifications")
|
|
|
|
local notif
|
|
local timeout = 1.5
|
|
local first_time = true
|
|
awesome.connect_signal("evil::volume", function (percentage, muted)
|
|
if first_time then
|
|
first_time = false
|
|
else
|
|
if sidebar.visible or (client.focus and client.focus.class == "Pavucontrol") then
|
|
-- Sidebar and Pavucontrol already show volume, so
|
|
-- destroy notification if it exists
|
|
if notif then
|
|
notif:destroy()
|
|
end
|
|
else
|
|
-- Send notification
|
|
local message, icon
|
|
if muted then
|
|
message = "muted"
|
|
icon = icons.muted
|
|
else
|
|
message = tostring(percentage)
|
|
icon = icons.volume
|
|
end
|
|
|
|
notif = notifications.notify_dwim({ title = "Volume", message = message, icon = icon, timeout = timeout, app_name = "volume" }, notif)
|
|
end
|
|
end
|
|
end)
|
|
|