awesome-wm-widgets/pactl-widget/utils.lua
Stefan Huber 81d725fe84 pactl: A new volume widget using pactl only
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.
2023-01-18 07:59:53 +01:00

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