mirror of
https://github.com/streetturtle/awesome-wm-widgets.git
synced 2024-11-15 19:48:04 +01:00
81d725fe84
Add a new volume widget that is using pactl only for controlling volume and selecting sources and sinks. It therefore works with PulseAudio or PipeWire as backend, unlike the original Volume widget. The code is split as follows: - volume.lua contains the UI logic - pactl.lua contains the pactl interfacing and output parsing - utils.lua contains some shared helper routines It is heavily based on the original Volume code and supports the same configuration options and uses the same widget code.
28 lines
507 B
Lua
28 lines
507 B
Lua
local utils = {}
|
|
|
|
|
|
function utils.trim(str)
|
|
return string.match(str, "^%s*(.-)%s*$")
|
|
end
|
|
|
|
function utils.split(string_to_split, separator)
|
|
if separator == nil then separator = "%s" end
|
|
local t = {}
|
|
|
|
for str in string.gmatch(string_to_split, "([^".. separator .."]+)") do
|
|
table.insert(t, str)
|
|
end
|
|
|
|
return t
|
|
end
|
|
|
|
function utils.popen_and_return(cmd)
|
|
local handle = io.popen(cmd)
|
|
local result = handle:read("*a")
|
|
handle:close()
|
|
|
|
return result
|
|
end
|
|
|
|
|
|
return utils
|