From 19f95b77c8afa6836eccfba70db060d1deb66586 Mon Sep 17 00:00:00 2001 From: Yessiest Date: Tue, 22 Mar 2022 21:21:46 +0000 Subject: [PATCH] i commit fel0ny to gitea --- widgets/client-volume.lua | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/widgets/client-volume.lua b/widgets/client-volume.lua index 12e8669..94c6b0c 100644 --- a/widgets/client-volume.lua +++ b/widgets/client-volume.lua @@ -3,6 +3,26 @@ local gears = require("gears") local wibox = require("wibox") 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) local style = awmtk.style(awmtk.defaults, args.style or {},"client_volume_") local device = args.device or "default" @@ -24,11 +44,6 @@ return function(args) return icons.muted 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 = { layout = wibox.layout.fixed.horizontal }