packages: awesome-plugin-vicious/moc.lua (NEW), awesome-plugin-vicious/awes...

uzsolt uzsolt at pld-linux.org
Sun Nov 8 15:22:20 CET 2009


Author: uzsolt                       Date: Sun Nov  8 14:22:19 2009 GMT
Module: packages                      Tag: HEAD
---- Log message:
- initial
- moc support

---- Files affected:
packages/awesome-plugin-vicious:
   moc.lua (NONE -> 1.1)  (NEW), awesome-plugin-vicious-readme.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/awesome-plugin-vicious/moc.lua
diff -u /dev/null packages/awesome-plugin-vicious/moc.lua:1.1
--- /dev/null	Sun Nov  8 15:22:20 2009
+++ packages/awesome-plugin-vicious/moc.lua	Sun Nov  8 15:22:14 2009
@@ -0,0 +1,66 @@
+---------------------------------------------------
+-- Licensed under the GNU General Public License v2
+--  * (c) 2009, Adrian C. <anrxc.sysphere.org>
+--  * (c) Wicked, Lucas de Vries
+--  moc plugin written by Zsolt Udvari <udvzsolt.gmail.com>
+---------------------------------------------------
+
+-- {{{ Grab environment
+local io = { popen = io.popen }
+local setmetatable = setmetatable
+local helpers = require("vicious.helpers")
+local string = {
+    find = string.find,
+    gsub = string.gsub,
+    match = string.match
+}
+
+local print = print
+-- }}}
+
+
+-- Moc: provides the currently playing song in Moc
+module("vicious.moc")
+
+
+-- {{{ MOC widget type
+local function worker(format)
+    -- Get data from mocp
+    local f = io.popen("mocp -i")
+    local np = f:read("*all")
+    local state = ""
+    local artist = ""
+    local title = ""
+    local filename = ""
+    local curtime = ""
+    local totaltime = ""
+
+    f:close()
+
+    -- Check if it's stopped, off or not installed
+    if np == nil then
+        return {"STOP"}
+    end
+
+    state = string.match(np, "State: %a*")
+    state = string.gsub(state,"State: ","")
+    if state ~= "STOP" then
+        artist = string.gsub(string.match(np,"Artist: %C*") or artist,"Artist: ","")
+        title  = string.gsub(string.match(np,"SongTitle: %C*") or title,"SongTitle: ","")
+        filename = string.gsub(string.match(np,"File: %C*") or filename,"File: ","")
+        curtime = string.gsub(string.match(np,"CurrentTime: %d*:%d*") or curtime,"CurrentTime: ","")
+        totaltime = string.gsub(string.match(np,"TotalTime: %d*:%d*") or totaltime,"TotalTime: ","")
+
+        state = helpers.escape(state)
+        artist = helpers.escape(artist)
+        title = helpers.escape(title)
+        filename = helpers.escape(filename)
+        curtime = helpers.escape(curtime)
+        totaltime = helpers.escape(totaltime)
+    end
+
+    return {state,artist,title,filename,curtime,totaltime}
+end
+-- }}}
+
+setmetatable(_M, { __call = function(_, ...) return worker(...) end })

================================================================
Index: packages/awesome-plugin-vicious/awesome-plugin-vicious-readme.patch
diff -u /dev/null packages/awesome-plugin-vicious/awesome-plugin-vicious-readme.patch:1.1
--- /dev/null	Sun Nov  8 15:22:20 2009
+++ packages/awesome-plugin-vicious/awesome-plugin-vicious-readme.patch	Sun Nov  8 15:22:14 2009
@@ -0,0 +1,15 @@
+--- vicious-1.0.18-orig/README	2009-11-08 15:17:58.821582603 +0100
++++ vicious-1.0.18/README	2009-11-08 15:20:07.314062040 +0100
+@@ -258,6 +258,12 @@
+   - provides the currently playing song in MPD
+   - returns 1st value as the currently playing song
+ 
++vicious.widgets.moc
++  - provides the currently playing song in Moc
++  - returns 1st value is state, 2nd is the artist, 3rd is the title,
++    4nd is the filename, 5nd is the elapsed time, 6nd is the total time
++    of the currently playing song
++
+ vicious.widgets.volume
+   - provides volume levels of requested ALSA mixers
+   - takes the ALSA channel as an argument, i.e. "Master"
================================================================


More information about the pld-cvs-commit mailing list