# {{{ Now Playing bar_applet("now_playing", 0, "-- Now Playing --") do |wmii, bar| Thread.new do np_maxlength = 35 nixplaying = "Nothing" np_toleranz = 3 np_toleranz_akt = 0 loop do t = `ps | grep amarok|grep -v grep` np_text = if t.length > 1 then `cat ~/.nowplaying` else nixplaying end np_text = nixplaying if np_text.length < 2 if np_text.length <= np_maxlength + np_toleranz np_toleranz_akt = np_toleranz np_dots = "" else np_toleranz_akt = -3 np_dots = "..." end bar.data = np_text[0,np_maxlength+np_toleranz_akt]+np_dots sleep 10 end end xmessagebox = "xmessage -center -buttons quit:0 -default quit -file -" fl = lambda{ wmii.write "/view/ctl", "select 0" } toggle_fl = lambda{ sleep 2; wmii.write "/view/ctl", "select toggle" } bar.on_click do |name, button| current = wmii.curr_view_index case button.to_i when MOUSE_BUTTON_LEFT: wmii.set_curr_view "amarok" unless wmii.curr_view == "amarok" when MOUSE_BUTTON_RIGHT: fl[]; system "cat ~/.nowplaying | wmiisetsid #{xmessagebox} &"; toggle_fl[] end end end