Re: statusbar got frozen?

sunway <[email protected]>
Newsgroups gmane.comp.window-managers.ion.general
Message-ID <20080212052735.GA13945@sunway>
I have noticed that after 13 times calling of "echo ..|nc localhost
6600" in get_mpd_status(), `ps aux|grep nc`  shows that "sh -c echo ..|nc localhost 6600"
sleeping forever, so I use "mpc" instead of "echo|nc" to get mpd info, it
seems work quite well

On Mon, Feb 11, 2008 at 08:10:09PM +0800, sunway wrote:
>i am using ion3 version 3-20080207, when having both statusd_netmon and
>statusd_mpd shown on the statusbar, the statusbar got frozen after a few seconds,anything wrong?
>
>-- 
>_________________________________________
>sunway
>Broad Network Research Center
>Beijing University of Posts and Telecommunications

-- 
sunway
Broad Network Research Center
Beijing University of Posts and Telecommunications
statusd_mpd.lua (text/plain, 926 B)
--orignal author: delirium-88qmZGEba/[email protected]
--modified by: sunwayforever at gmail dot com
--mpc is required
local defaults={
   update_interval=1000,
   address="localhost",
   port=6600,
}

local settings=table.join(statusd.get_config("mpd"), defaults)
local function get_mpd_status()
   local mpd = io.popen("mpc 2>/dev/null", "r")
   local data1 = mpd:read('*line')
   local data2 = mpd:read('*line')
   mpd:close()
   if data1 == nil then 
      return "mpd not running"
   end
   local s,_= string.find(data1, "volume.*")
   if s == 1 then
      return "Stopped"
   end
   local _,_,state,perc= string.find(data2, "%[(.*)].*%((.*)%)")
   return state.." "..perc.." "..data1
end

local mpd_timer
local function update_mpd()
   local mpd_st = get_mpd_status()
   statusd.inform("mpd", mpd_st)
   mpd_timer:set(settings.update_interval, update_mpd)
end

mpd_timer=statusd.create_timer()
update_mpd()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.