Re: Timer and/or stopwatch for awesome tray

2011-04-27 Thread Torsten Andre

Am 23.04.2011 00:02, schrieb Jörg Thalheim:

There wasn't something until you asked for it. Add this code to your
rc.lua and the widget tea.widget to mywibox or what ever you use.
On a left click the promptbox will popup and ask for a time.
On a right click the timer is reseted.
The default unit is sec but it also accept a format like 12h 25m.
Currently it doesn't display left days correctly, but I hope you not
depend on this feature.
It use desktop notification to inform the user.
Acoustically feedback is possible if you use something like
  awful.util.spawn(aplay /path/to/audio.wave)
If you like it, feel free to post it on the wiki.



Awesome! ;)

Thanks a lot Jörg. The code snippet is exactly what I was looking for. 
Works like a charm.


Cheers,

Torsten

--
To unsubscribe, send mail to awesome-unsubscr...@naquadah.org.


Re: Timer and/or stopwatch for awesome tray

2011-04-22 Thread Jörg Thalheim
local tea = {}
tea.widget = widget({ type = textbox })
tea.timer = timer { timeout = 1 }

function tea:settime(t)
  if t = 3600 then -- more than one hour!
t = os.date(%X, t-3600)
  else
t = os.date(%M:%S, t)
  end
  self.widget.text = string.format(Time for Tea: b%s/b, t)
end

tea:settime(0)

function tea:countdown(time)
  self.left = time
  self.last_time = os.time()
  self:settime(time)
  self.timer:start()
end

tea.widget:buttons(awful.util.table.join(
awful.button({ }, 1, function() 
  awful.prompt.run({ prompt = Set tea timer:  }, mypromptbox[mouse.screen].widget,
  function (t)
local total_time = 0
for time, unit in t:gmatch((%d+)([dhms]?)) do
  time = tonumber(time)
  if unit == d then
time = time * 86400
  elseif unit == h then
time = time * 3600
  elseif unit == m then
time = time * 60
  end 
  total_time = total_time + time
end
tea:countdown(total_time)
  end)
end),
awful.button({ }, 3, function()
  tea.timer:stop()
  tea:settime(0)
end)
))

tea.timer:add_signal(timeout, function()
  local now = os.time()
  tea.left = tea.left - (now - tea.last_time)
  tea.last_time = now

  if tea.left  0 then
tea:settime(tea.left)
  else
naughty.notify {
  title = It's me, the Tea timer.,
  text  = Hey guy, your time is over!,
  timeout = 5 }

tea:settime(0)
tea.timer:stop()
  end
end)
There wasn't something until you asked for it. Add this code to your
rc.lua and the widget tea.widget to mywibox or what ever you use.
On a left click the promptbox will popup and ask for a time.
On a right click the timer is reseted.
The default unit is sec but it also accept a format like 12h 25m.
Currently it doesn't display left days correctly, but I hope you not
depend on this feature.
It use desktop notification to inform the user.
Acoustically feedback is possible if you use something like
 awful.util.spawn(aplay /path/to/audio.wave)
If you like it, feel free to post it on the wiki. 



Timer and/or stopwatch for awesome tray

2011-04-20 Thread Torsten Andre

Hey guys,

Silly me. I was thinking I could quickly install a timer (or even better 
timer and stop watch) for my tray. But guess what, I wasn't able to find 
one. Can someone help me out? All I found was applets for xfce4, kde or 
gnome panels. But since I don't use any panels, these applets won't help.


I need a timer for my awesome tray which allows me to easily set a 
countdown and informs me visually and/or acoustically (something which 
tea-timer used to do for Debian).


Can someone help me out? Thanks guys.


--
To unsubscribe, send mail to awesome-unsubscr...@naquadah.org.