diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-02-22 15:09:51 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-02-22 15:09:51 -0300 |
commit | c764098185c3bab9cf10d75c5069e5c0d4dc6d48 (patch) | |
tree | 196191570e2002ca61f9d845eebb1c7d96ec7ede /modules/awesome/config.dot/awesome.link/volume.lua | |
parent | e59b8e510d2bbe3deefb83b571b633e1ccf4020a (diff) | |
download | dotfiles-c764098185c3bab9cf10d75c5069e5c0d4dc6d48.tar.gz dotfiles-c764098185c3bab9cf10d75c5069e5c0d4dc6d48.tar.bz2 |
Adding volume keys and widgets
Diffstat (limited to 'modules/awesome/config.dot/awesome.link/volume.lua')
-rw-r--r-- | modules/awesome/config.dot/awesome.link/volume.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/modules/awesome/config.dot/awesome.link/volume.lua b/modules/awesome/config.dot/awesome.link/volume.lua new file mode 100644 index 0000000..0a5bb45 --- /dev/null +++ b/modules/awesome/config.dot/awesome.link/volume.lua @@ -0,0 +1,34 @@ +-- See http://awesome.naquadah.org/wiki/Volume_control_and_display +volume_widget = widget({ type = "textbox", name = "tb_volume", + align = "right" }) + +function update_volume(widget) + local fd = io.popen("amixer sget Master") + local status = fd:read("*all") + fd:close() + + local volume = tonumber(string.match(status, "(%d?%d?%d)%%")) / 100 + -- volume = string.format("% 3d", volume) + + status = string.match(status, "%[(o[^%]]*)%]") + + -- starting colour + local sr, sg, sb = 0x3F, 0x3F, 0x3F + -- ending colour + local er, eg, eb = 0xDC, 0xDC, 0xCC + + local ir = volume * (er - sr) + sr + local ig = volume * (eg - sg) + sg + local ib = volume * (eb - sb) + sb + interpol_colour = string.format("%.2x%.2x%.2x", ir, ig, ib) + if string.find(status, "on", 1, true) then + volume = " <span background='#" .. interpol_colour .. "'> </span>" + else + volume = " <span color='red' background='#" .. interpol_colour .. "'> M </span>" + end + widget.text = volume + end + +mytimer = timer({ timeout = 1 }) +mytimer:add_signal("timeout", function () update_volume(volume_widget) end) +mytimer:start() |