]> git.madduck.net Git - etc/awesome.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

moved acw/init to ccurr + code revision
authorluke bonham <dadasignificanulla@gmail.com>
Mon, 10 Feb 2014 18:17:47 +0000 (19:17 +0100)
committercopycat-killer <dada@archlinux.info>
Wed, 5 Aug 2015 11:30:38 +0000 (13:30 +0200)
widgets/contrib/acw/init.lua [deleted file]
widgets/contrib/ccurr.lua [new file with mode: 0644]
wiki

diff --git a/widgets/contrib/acw/init.lua b/widgets/contrib/acw/init.lua
deleted file mode 100644 (file)
index c06de57..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
--[[
-                                                  
-     Licensed under GNU General Public License v2 
-      * (c) 2014, Aaron Lebo                     
-                                                  
---]]
-
-local newtimer = require("lain.helpers").newtimer
-local wibox = require("wibox")
-local json = require("dkjson")
-
--- acw (awesome crypto widget)
--- diplays BTC/USD and DOGE/USD using Coinbase and Cryptsy APIs
--- requires http://dkolf.de/src/dkjson-lua.fsl/home   
--- based upon http://awesome.naquadah.org/wiki/Bitcoin_Price_Widget
--- lain.widgets.contrib.acw
-
-acw = {widget=wibox.widget.textbox('')}
-
-local function get(url)
-    f = io.popen('curl -m 5 -s "' .. url .. '"')
-    if (not f) then return 0 end
-    return f:read("*all")
-end
-
-local function parse(j)
-    local obj, pos, err = json.decode (j, 1, nil)
-    if err thenfunction worker(args)
-        return nil
-    else
-        return obj
-    end
-end
-
-function worker(args)
-    local args = args or {}
-    local timeout = args.timeout or 600
-    local settings = args.settings or function() end
-
-    local function update()
-        btc = parse(get("https://coinbase.com/api/v1/prices/buy"))
-        if btc then
-            btc = tonumber(btc["subtotal"]["amount"])
-            btc_display = "$" .. btc
-        else
-            btc_display = "N/A"
-        end
-        doge = parse(get("http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132"))
-        if doge and btc then
-            doge = tonumber(doge["return"]["markets"]["DOGE"]["lasttradeprice"])
-            doge_display = string.format("$%.4f", btc * doge)
-        else
-            doge_display = "N/A"
-        end
-        prices = btc_display .. " " ..  doge_display
-        prices_now = {}
-        prices_now.prices = prices
-
-        widget = acw.widget
-        settings()
-   end
-
-    newtimer("acw", timeout, update)
-
-    return acw.widget
-end
-
-return setmetatable(acw, { __call = function(_, ...) return worker(...) end })
diff --git a/widgets/contrib/ccurr.lua b/widgets/contrib/ccurr.lua
new file mode 100644 (file)
index 0000000..b9a4f42
--- /dev/null
@@ -0,0 +1,78 @@
+
+--[[
+                                                  
+     Licensed under GNU General Public License v2 
+      * (c) 2014, Aaron Lebo                      
+                                                  
+--]]
+
+local newtimer = require("lain.helpers").newtimer
+local wibox    = require("wibox")
+local json     = require("dkjson")
+
+-- Crypto currencies widget
+-- lain.widgets.contrib.ccurr
+local ccurr = {}
+
+-- Currently gets
+--   * BTC/USD
+--   * DOGE/USD
+-- using Coinbase and Cryptsy APIs.
+
+-- requires   http://dkolf.de/src/dkjson-lua.fsl/home
+-- based upon http://awesome.naquadah.org/wiki/Bitcoin_Price_Widget
+
+local function get(url)
+    local f = io.popen('curl -m 5 -s "' .. url .. '"')
+    if not f then
+        return 0
+    else
+        local s = f:read("*all")
+        f:close()
+        return s
+    end
+end
+
+local function parse(j)
+    local obj, pos, err = json.decode(j, 1, nil)
+    if err then
+        return nil
+    else
+        return obj
+    end
+end
+
+local function worker(args)
+    local args     = args or {}
+    local timeout  = args.timeout  or 600
+    local btc_url  = args.btc_url  or "https://coinbase.com/api/v1/prices/buy"
+    local doge_url = args.doge_url or "http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132"
+    local settings = args.settings or function() end
+
+    ccurr.widget = wibox.widget.textbox('')
+
+    local function update()
+        price_now = {
+            btc  = "N/A",
+            doge = "N/A"
+        }
+
+        btc  = parse(get(btc_url))
+        doge = parse(get(doge_url))
+
+        if btc and doge then
+            price_now.btc  = tonumber(btc["subtotal"]["amount"])
+            price_now.doge = tonumber(doge["return"]["markets"]["DOGE"]["lasttradeprice"])
+            price_now.doge = string.format("%.4f", price_now.btc * price_now.doge)
+        end
+
+        widget = ccurr.widget
+        settings()
+    end
+
+    newtimer("ccurr", timeout, update)
+
+    return ccurr.widget
+end
+
+return setmetatable(ccurr, { __call = function(_, ...) return worker(...) end })
diff --git a/wiki b/wiki
index d4248875dcd12ceb300c8a876001ce68f5405758..72c82d49aa961e15440db7dfefb749fe0d2cdd02 160000 (submodule)
--- a/wiki
+++ b/wiki
@@ -1 +1 @@
-Subproject commit d4248875dcd12ceb300c8a876001ce68f5405758
+Subproject commit 72c82d49aa961e15440db7dfefb749fe0d2cdd02