From 88c3d0c11ef6e68e8a11a394b338fe84682b22ae Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Sun, 29 Aug 2010 01:32:24 +0200 Subject: [PATCH] contrib: use pcall for luasocket in pop --- contrib/init.lua | 2 +- contrib/pop.lua | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/contrib/init.lua b/contrib/init.lua index 255ff87..e0f681a 100644 --- a/contrib/init.lua +++ b/contrib/init.lua @@ -13,7 +13,7 @@ require("vicious.contrib.mpc") require("vicious.contrib.netcfg") require("vicious.contrib.net") require("vicious.contrib.ossvol") ---require("vicious.contrib.pop") +require("vicious.contrib.pop") require("vicious.contrib.pulse") require("vicious.contrib.rss") require("vicious.contrib.sensors") diff --git a/contrib/pop.lua b/contrib/pop.lua index 7b87eab..78e0bcb 100644 --- a/contrib/pop.lua +++ b/contrib/pop.lua @@ -10,9 +10,11 @@ --------------------------------------------------- -- {{{ Grab environment -local setmetatable = setmetatable -local socket = require("socket") local tonumber = tonumber +local setmetatable = setmetatable +local sock_avail, socket = pcall(function() + return require("socket") +end) -- }}} @@ -22,7 +24,7 @@ module("vicious.contrib.pop") -- {{{ POP3 count widget type local function worker(format, warg) - if not warg or #warg ~= 4 then + if not sock_avail or (not warg or #warg ~= 4) then return {"N/A"} end