port volume widget to freebsd
This commit is contained in:
parent
f86c60d2fd
commit
54baa996c4
|
@ -0,0 +1,38 @@
|
||||||
|
-- {{{ Grab environment
|
||||||
|
local tonumber = tonumber
|
||||||
|
local io = { popen = io.popen }
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local string = { match = string.match }
|
||||||
|
local helpers = require("vicious.helpers")
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
|
-- Volume: provides volume levels and state of requested mixer
|
||||||
|
-- vicious.widgets.volume_freebsd
|
||||||
|
local volume_freebsd = {}
|
||||||
|
|
||||||
|
|
||||||
|
-- {{{ Volume widget type
|
||||||
|
local function worker(format, warg)
|
||||||
|
if not warg then return end
|
||||||
|
|
||||||
|
local mixer_state = { "♫", "♩" }
|
||||||
|
|
||||||
|
-- Get mixer control contents
|
||||||
|
f = io.popen("mixer -s " .. helpers.shellquote(warg))
|
||||||
|
local mixer = f:read()
|
||||||
|
f:close()
|
||||||
|
|
||||||
|
-- Capture mixer control state: [5%] ... ... [on]
|
||||||
|
local voll, volr = string.match(mixer, "([%d]+):([%d]+)$")
|
||||||
|
|
||||||
|
if voll == "0" and volr == "0" then
|
||||||
|
return {0, 0, mixer_state[2]}
|
||||||
|
else
|
||||||
|
return {voll, volr, mixer_state[1]}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
return setmetatable(volume_freebsd, { __call = function(_, ...) return worker(...) end })
|
|
@ -14,7 +14,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- Volume: provides volume levels and state of requested ALSA mixers
|
-- Volume: provides volume levels and state of requested ALSA mixers
|
||||||
-- vicious.widgets.volume
|
-- vicious.widgets.volume
|
||||||
local volume = {}
|
local volume_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Volume widget type
|
-- {{{ Volume widget type
|
||||||
|
@ -51,4 +51,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(volume, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(volume_linux, { __call = function(_, ...) return worker(...) end })
|
Loading…
Reference in New Issue