aboutsummaryrefslogtreecommitdiff
path: root/volume.lua
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-14 01:55:33 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-14 01:55:33 +0100
commit237470c8f45190b213e3a173ce6ae1a74b3e11fe (patch)
tree7f53c8144761947d4bde20715bcad34f4be0d6c0 /volume.lua
parent9a82d4113a8271b7dfc7506f2b07379e3ede89a8 (diff)
downloadvicious-legacy-237470c8f45190b213e3a173ce6ae1a74b3e11fe.tar.xz
API: transform widgets namespace table to a directory
Diffstat (limited to 'volume.lua')
-rw-r--r--volume.lua50
1 files changed, 0 insertions, 50 deletions
diff --git a/volume.lua b/volume.lua
deleted file mode 100644
index 070f3bf..0000000
--- a/volume.lua
+++ /dev/null
@@ -1,50 +0,0 @@
----------------------------------------------------
--- Licensed under the GNU General Public License v2
--- * (c) 2010, Adrian C. <anrxc@sysphere.org>
----------------------------------------------------
-
--- {{{ Grab environment
-local tonumber = tonumber
-local io = { popen = io.popen }
-local setmetatable = setmetatable
-local string = { match = string.match }
--- }}}
-
-
--- Volume: provides volume levels and state of requested ALSA mixers
-module("vicious.volume")
-
-
--- {{{ Volume widget type
-local function worker(format, warg)
- local mixer_state = {
- ["on"] = "♫", -- "",
- ["off"] = "♩" -- "M"
- }
-
- -- Get mixer control contents
- local f = io.popen("amixer get " .. warg)
- local mixer = f:read("*all")
- f:close()
-
- -- Capture mixer control state: [5%] ... ... [on]
- local volu, mute = string.match(mixer, "([%d]+)%%.*%[([%l]*)")
- -- Handle mixers without data
- if volu == nil then
- return {0, mixer_state["off"]}
- end
-
- -- Handle mixers without mute
- if mute == "" and volu == "0"
- -- Handle mixers that are muted
- or mute == "off" then
- mute = mixer_state["off"]
- else
- mute = mixer_state["on"]
- end
-
- return {tonumber(volu), mute}
-end
--- }}}
-
-setmetatable(_M, { __call = function(_, ...) return worker(...) end })