diff options
author | streetturtle <streetturtle@users.noreply.github.com> | 2023-01-18 13:32:47 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-18 13:32:47 -0500 |
commit | a3f4a0731696f62cce4b715dcd1e5975ff553439 (patch) | |
tree | 74fa1e2dcf5ddbc9cdd5f8cff149c597d8ce524b /pactl-widget/utils.lua | |
parent | 5f251902cf2b5cc25e54e2ce3b6292a741d52399 (diff) | |
parent | 81d725fe84ba96f689ad1e4e8990c7750bc40d33 (diff) |
Merge pull request #386 from shuber2/pactl-widget
pactl: A new volume widget using pactl only
Diffstat (limited to 'pactl-widget/utils.lua')
-rw-r--r-- | pactl-widget/utils.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/pactl-widget/utils.lua b/pactl-widget/utils.lua new file mode 100644 index 0000000..52e7869 --- /dev/null +++ b/pactl-widget/utils.lua @@ -0,0 +1,28 @@ +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 |