i commit fel0ny to gitea

This commit is contained in:
Yessiest 2022-03-22 21:21:46 +00:00
parent cb5fbb5a48
commit 19f95b77c8
1 changed files with 20 additions and 5 deletions

View File

@ -3,6 +3,26 @@ local gears = require("gears")
local wibox = require("wibox") local wibox = require("wibox")
local awmtk = require("awmtk") local awmtk = require("awmtk")
local get_app_volume = function(pid)
-- If pactl is accessible
if os.execute("pactl --version") then
-- Generate pactl sink-inputs data
local pactl_process = io.popen("pactl list sink-inputs","r")
local pactl_data = pactl_process:read("*a")
pactl_process:close()
while pactl_data:match("^(%w.-\n)%w") do
local test = pactl_data:match("^(%w.-\n)%w")
if test:match("application.process.id = \""..tostring(pid).."\"") then
return test:match("Volume: .-(%d?%d?%d%%)")
end
pactl_data = pactl_data:gsub("^%w.-\n(%w)","%1")
end
return nil, "Process doesn't play audio"
else
return nil, "pactl command is not available"
end
end
return function(args) return function(args)
local style = awmtk.style(awmtk.defaults, args.style or {},"client_volume_") local style = awmtk.style(awmtk.defaults, args.style or {},"client_volume_")
local device = args.device or "default" local device = args.device or "default"
@ -24,11 +44,6 @@ return function(args)
return icons.muted return icons.muted
end end
end end
local commands = args.commands or {
get_master = "amixer -D "..device.." sget Master",
set = "amixer -q -D "..device.." sset ",
get = "amixer -D "..device.." sget "
}
local list = { local list = {
layout = wibox.layout.fixed.horizontal layout = wibox.layout.fixed.horizontal
} }