]> git.rmz.io Git - dotfiles.git/blobdiff - awesome/widgets/pomodoro.lua
pomodoro: show started task in pomodoro widget
[dotfiles.git] / awesome / widgets / pomodoro.lua
index 3c7af637a6e0564f5eb2d885a15bfa29e2bdcb93..c83accf13b5ad637e4e05c7915c329744f71b5dc 100644 (file)
@@ -1,5 +1,7 @@
 local pomodoro = require("widgets/pomodoro/init")
 local wibox = require("wibox")
 local pomodoro = require("widgets/pomodoro/init")
 local wibox = require("wibox")
+local awful = require("awful")
+local utils = require("utils")
 
 -- durations in seconds
 pomodoro.short_pause_duration = 5 * 60
 
 -- durations in seconds
 pomodoro.short_pause_duration = 5 * 60
@@ -8,15 +10,49 @@ pomodoro.work_duration = 25 * 60
 
 -- format string
 pomodoro.format = function (t) return " <b>"..t.."</b>" end
 
 -- format string
 pomodoro.format = function (t) return " <b>"..t.."</b>" end
+pomodoro.auto_start_pomodoro = true
 
 pomodoro.init()
 
 
 pomodoro.init()
 
-pombox = wibox.layout.fixed.horizontal()
+local pombox = wibox.layout.fixed.horizontal()
+pombox:add(wibox.widget {
+  layout = wibox.layout.align.horizontal,
+  forced_width = 200,
+  expand = "outside",
+  nil,
+  {
+    layout = wibox.container.scroll.horizontal,
+    max_size = 200,
+    extra_space = 10,
+    step_function = wibox.container.scroll.step_functions.linear_increase,
+    speed = 20,
+    {
+      -- TODO: make this context aware
+      widget = awful.widget.watch('task +ACTIVE _unique description',
+        1,
+        function(widget, stdout)
+          if not stdout or stdout == "" then
+            stdout = "No task started!"
+          end
+          widget:set_markup('<b>'..stdout..'</b>')
+        end)
+    },
+  },
+  nil,
+})
 pombox:add(pomodoro.icon_widget)
 pombox:add(pomodoro.widget)
 
 pombox:add(pomodoro.icon_widget)
 pombox:add(pomodoro.widget)
 
-globalkeys = awful.util.table.join(globalkeys,
-    awful.key({ modkey, "Shift" }, "p", function() pomodoro:start() end)
+--TODO connect signals to something sensible  (sb:20170130)
+-- pomodoro:connect_signal("stop_working",  function () naughty.notify{ text = "stop_working",  timeout = 10 } end)
+-- pomodoro:connect_signal("stop_pause",    function () naughty.notify{ text = "stop_pause",    timeout = 10 } end)
+-- pomodoro:connect_signal("start_working", function () naughty.notify{ text = "start_working", timeout = 10 } end)
+pomodoro:connect_signal("work_stop", function ()
+    awful.spawn(terminal, {floating = true, placement = awful.centered })
+end)
+
+globalkeys = gears.table.join(globalkeys,
+    awful.key({ modkey, "Shift" }, "p", function() pomodoro:toggle() end)
 )
 
 return pombox
 )
 
 return pombox