├── .travis.yml ├── Guardfile ├── README.md ├── images ├── gray.png ├── green.png ├── locked.png ├── orange.png └── red.png ├── impl.lua ├── impl_test.lua └── init.lua /.travis.yml: -------------------------------------------------------------------------------- 1 | # Fake out that this is an erlang worker 2 | language: erlang 3 | 4 | env: 5 | - LUA="" 6 | - LUA="luajit" 7 | 8 | install: 9 | - sudo apt-get install luajit 10 | - sudo apt-get install luarocks 11 | - sudo luarocks install luafilesystem 12 | - sudo luarocks install busted 13 | 14 | script: "busted *_test.lua" 15 | -------------------------------------------------------------------------------- /Guardfile: -------------------------------------------------------------------------------- 1 | guard :shell do 2 | watch /\.lua/ do |m| 3 | `busted impl_test.lua` 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pomodoro Widget 2 | 3 | [![Build Status](https://travis-ci.org/nikolavp/awesome-pomodoro.svg?branch=master)](https://travis-ci.org/nikolavp/awesome-pomodoro) 4 | 5 | Here are some screenshots on what you'll get if you include this module: 6 | * 7 | * 8 | * 9 | * 10 | 11 | more can be found in our [screenshots wiki page](https://github.com/nikolavp/awesome-pomodoro/wiki/Screenshots). 12 | 13 | ## Installation 14 | 15 | cd ~/.config/awesome 16 | git clone git://github.com/nikolavp/awesome-pomodoro.git pomodoro 17 | 18 | ### In you rc.lua: 19 | 20 | // insert after beautiful.init("...") 21 | local pomodoro = require("./pomodoro/init") 22 | 23 | //init the pomodoro object 24 | pomodoro.init() 25 | 26 | At this point there are two widget you will want to use in your wibox: 27 | 28 | * pomodoro.widget - the main widget that will display the time of the current pomodoro. 29 | 30 | * pomodoro.icon_widget - the icon that you can use to display close to the text. 31 | 32 | ### Add the widgets to your wibox 33 | 34 | You can use: 35 | 36 | * only the text widget: 37 | 38 | mywibox[s].widgets = { 39 | pomodoro.widget, 40 | mytextclock, 41 | } 42 | 43 | * only the icon widget: 44 | 45 | mywibox[s].widgets = { 46 | pomodoro.icon_widget, 47 | mytextclock, 48 | } 49 | 50 | * or you can use them both: 51 | 52 | mywibox[s].widgets = { 53 | pomodoro.widget, pomodoro.icon_widget, 54 | mytextclock, 55 | } 56 | 57 | If you want to change something or bind pomodoro actions to keys, please look at the [custimzations](https://github.com/nikolavp/awesome-pomodoro/wiki/Advanced-customizations) page or open a feature/change request if your thing is not there. 58 | 59 | 60 | ## License 61 | 62 | Copyright 2010-2011 François de Metz, Nikolay Sturm(nistude), Nikola Petrov(nikolavp) 63 | 64 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 65 | Version 2, December 2004 66 | 67 | Copyright (C) 2004 Sam Hocevar 68 | 69 | Everyone is permitted to copy and distribute verbatim or modified 70 | copies of this license document, and changing it is allowed as long 71 | as the name is changed. 72 | 73 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 74 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 75 | 76 | 0. You just DO WHAT THE FUCK YOU WANT TO. 77 | -------------------------------------------------------------------------------- /images/gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nikolavp/awesome-pomodoro/ffc8322dabf134f5828d1e7dd70d8cc58f93f5e9/images/gray.png -------------------------------------------------------------------------------- /images/green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nikolavp/awesome-pomodoro/ffc8322dabf134f5828d1e7dd70d8cc58f93f5e9/images/green.png -------------------------------------------------------------------------------- /images/locked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nikolavp/awesome-pomodoro/ffc8322dabf134f5828d1e7dd70d8cc58f93f5e9/images/locked.png -------------------------------------------------------------------------------- /images/orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nikolavp/awesome-pomodoro/ffc8322dabf134f5828d1e7dd70d8cc58f93f5e9/images/orange.png -------------------------------------------------------------------------------- /images/red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nikolavp/awesome-pomodoro/ffc8322dabf134f5828d1e7dd70d8cc58f93f5e9/images/red.png -------------------------------------------------------------------------------- /impl.lua: -------------------------------------------------------------------------------- 1 | local module_path = (...):match ("(.+/)[^/]+$") or "" 2 | 3 | local image = image 4 | local os = os 5 | local string = string 6 | local ipairs = ipairs 7 | local setmetatable = setmetatable 8 | local print = print 9 | local tonumber = tonumber 10 | local math = require("math") 11 | 12 | module("pomodoro.impl") 13 | 14 | return function(wibox, awful, naughty, beautiful, timer, awesome, base) 15 | -- pomodoro timer widget 16 | pomodoro = wibox.widget.base.make_widget() 17 | -- tweak these values in seconds to your liking 18 | pomodoro.short_pause_duration = 5 * 60 19 | pomodoro.long_pause_duration = 15 * 60 20 | pomodoro.work_duration = 25 * 60 21 | pomodoro.npomodoros = 0 22 | pomodoro.pause_duration = pomodoro.short_pause_duration 23 | pomodoro.change = 60 24 | pomodoro.module_path = module_path 25 | 26 | 27 | pomodoro.format = function (t) return "Pomodoro: " .. t .. "" end 28 | pomodoro.pause_title = "Pause finished." 29 | pomodoro.pause_text = "Get back to work!" 30 | pomodoro.work_title = "Pomodoro finished." 31 | pomodoro.work_text = "Time for a pause!" 32 | pomodoro.working = true 33 | pomodoro.widget = wibox.widget.textbox() 34 | pomodoro.icon_widget = wibox.widget.imagebox() 35 | pomodoro.timer = timer { timeout = 1 } 36 | 37 | -- Callbacks to be called when the pomodoro finishes or the rest time finishes 38 | pomodoro.on_work_pomodoro_finish_callbacks = {} 39 | pomodoro.on_pause_pomodoro_finish_callbacks = {} 40 | 41 | last_icon_used = nil 42 | 43 | function set_pomodoro_icon(icon_name) 44 | local pomodoro_image_path = awful.util.getdir("config") .. "/" .. pomodoro.module_path .. "images/" .. icon_name .. ".png" 45 | if last_icon_used == pomodoro_image_path then 46 | return 47 | end 48 | last_icon_used = pomodoro_image_path 49 | pomodoro.icon_widget:set_image(pomodoro_image_path) 50 | end 51 | 52 | function pomodoro:settime(t) 53 | if t >= 3600 then -- more than one hour! 54 | t = os.date("!%X", t) 55 | else 56 | t = os.date("%M:%S", t) 57 | end 58 | self.widget:set_markup(pomodoro.format(t)) 59 | end 60 | 61 | function pomodoro:notify(title, text, duration, working) 62 | naughty.notify { 63 | bg = beautiful.bg_urgent, 64 | fg = beautiful.fg_urgent, 65 | title = title, 66 | text = text, 67 | timeout = 10 68 | } 69 | 70 | pomodoro.left = duration 71 | pomodoro:settime(duration) 72 | pomodoro.working = working 73 | end 74 | 75 | function pomodoro:start() 76 | pomodoro.last_time = os.time() 77 | pomodoro.timer:again() 78 | if pomodoro.working then 79 | self:emit_signal("start_working") 80 | else 81 | self:emit_signal("start_pause") 82 | end 83 | end 84 | 85 | function pomodoro:pause() 86 | -- TODO: Fix the showed remaining text 87 | pomodoro.timer:stop() 88 | set_pomodoro_icon('locked') 89 | end 90 | 91 | function pomodoro:stop() 92 | pomodoro.timer:stop() 93 | pomodoro.working = true 94 | pomodoro.left = pomodoro.work_duration 95 | pomodoro:settime(pomodoro.work_duration) 96 | set_pomodoro_icon('gray') 97 | end 98 | 99 | function pomodoro:increase_time() 100 | pomodoro.timer:stop() 101 | pomodoro:settime(pomodoro.work_duration+pomodoro.change) 102 | pomodoro.work_duration = pomodoro.work_duration+pomodoro.change 103 | pomodoro.left = pomodoro.work_duration 104 | end 105 | 106 | function pomodoro:decrease_time() 107 | pomodoro.timer:stop() 108 | if pomodoro.work_duration > pomodoro.change then 109 | pomodoro:settime(pomodoro.work_duration-pomodoro.change) 110 | pomodoro.work_duration = pomodoro.work_duration-pomodoro.change 111 | pomodoro.left = pomodoro.work_duration 112 | end 113 | end 114 | 115 | function get_buttons() 116 | return awful.util.table.join( 117 | awful.button({ }, 1, function() 118 | pomodoro:start() 119 | end), 120 | awful.button({ }, 2, function() 121 | pomodoro:pause() 122 | end), 123 | awful.button({ }, 3, function() 124 | pomodoro:stop() 125 | end), 126 | awful.button({ }, 4, function() 127 | pomodoro:increase_time() 128 | end), 129 | awful.button({ }, 5, function() 130 | pomodoro:decrease_time() 131 | end) 132 | ) 133 | end 134 | 135 | function pomodoro:ticking_time() 136 | if pomodoro.left > 0 then 137 | if pomodoro.working then 138 | local pomodoro_portion = pomodoro.work_duration / 3 139 | if pomodoro.left > (2 * pomodoro_portion) then 140 | set_pomodoro_icon('green') 141 | elseif pomodoro.left > pomodoro_portion then 142 | set_pomodoro_icon('orange') 143 | else 144 | set_pomodoro_icon('red') 145 | end 146 | else 147 | set_pomodoro_icon('green') 148 | end 149 | pomodoro:settime(pomodoro.left) 150 | else 151 | set_pomodoro_icon('gray') 152 | if pomodoro.working then 153 | pomodoro.npomodoros = pomodoro.npomodoros + 1 154 | if pomodoro.npomodoros % 4 == 0 then 155 | pomodoro.pause_duration = pomodoro.long_pause_duration 156 | else 157 | pomodoro.pause_duration = pomodoro.short_pause_duration 158 | end 159 | self:emit_signal("stop_working") 160 | pomodoro:notify(pomodoro.work_title, pomodoro.work_text, 161 | pomodoro.pause_duration, false) 162 | for _, value in ipairs(pomodoro.on_work_pomodoro_finish_callbacks) do 163 | value() 164 | end 165 | else 166 | pomodoro:notify(pomodoro.pause_title, pomodoro.pause_text, 167 | pomodoro.work_duration, true) 168 | self:emit_signal("stop_pause") 169 | for _, value in ipairs(pomodoro.on_pause_pomodoro_finish_callbacks) do 170 | value() 171 | end 172 | end 173 | pomodoro.timer:stop() 174 | end 175 | end 176 | 177 | -- Function that keeps the logic for ticking 178 | function pomodoro:ticking() 179 | local now = os.time() 180 | pomodoro.left = pomodoro.left - (now - pomodoro.last_time) 181 | pomodoro.last_time = now 182 | pomodoro:ticking_time() 183 | end 184 | 185 | function pomodoro:init() 186 | local pread = awful.spawn and awful.spawn.pread or awful.util.pread 187 | local xresources = pread("xrdb -query") 188 | local time_from_last_run = xresources:match('awesome.Pomodoro.time:%s+%d+') 189 | local started_from_last_run = xresources:match('awesome.Pomodoro.started:%s+%w+') 190 | local working_from_last_run = xresources:match('awesome.Pomodoro.working:%s+%w+') 191 | local npomodoros_from_last_run = xresources:match('awesome.Pomodoro.npomodoros:%s+%d+') 192 | 193 | set_pomodoro_icon('gray') 194 | 195 | -- Timer configuration 196 | -- 197 | pomodoro.timer:connect_signal("timeout", pomodoro.ticking) 198 | 199 | awesome.connect_signal("exit", function(restarting) 200 | -- Save current state in xrdb. 201 | -- run this synchronously cause otherwise it is not saved properly -.- 202 | if restarting then 203 | started_as_number = pomodoro.timer.started and 1 or 0 204 | working_as_number = pomodoro.working and 1 or 0 205 | pread('echo "awesome.Pomodoro.time: ' .. pomodoro.left 206 | .. '\nawesome.Pomodoro.started: ' .. started_as_number 207 | .. '\nawesome.Pomodoro.working: ' .. working_as_number 208 | .. '\nawesome.Pomodoro.npomodoros: ' .. pomodoro.npomodoros 209 | .. '" | xrdb -merge') 210 | end 211 | end) 212 | 213 | pomodoro.widget:buttons(get_buttons()) 214 | pomodoro.icon_widget:buttons(get_buttons()) 215 | 216 | if time_from_last_run then 217 | time_from_last_run = tonumber(time_from_last_run:match('%d+')) 218 | if working_from_last_run then 219 | pomodoro.working = (tonumber(working_from_last_run:match('%d+')) == 1) 220 | end 221 | -- Use `math.min` to get the lower value for `pomodoro.left`, in 222 | -- case the config/setting has been changed. 223 | if pomodoro.working then 224 | pomodoro.left = math.min(time_from_last_run, pomodoro.work_duration) 225 | else 226 | pomodoro.left = math.min(time_from_last_run, pomodoro.pause_duration) 227 | end 228 | 229 | if npomodoros_from_last_run then 230 | pomodoro.npomodoros = tonumber(npomodoros_from_last_run:match('%d+')) 231 | end 232 | 233 | if started_from_last_run then 234 | started_from_last_run = tonumber(started_from_last_run:match('%d+')) 235 | if started_from_last_run == 1 then 236 | pomodoro:start() 237 | end 238 | end 239 | else 240 | -- Initial value depends on the one set by the user 241 | pomodoro.left = pomodoro.work_duration 242 | end 243 | pomodoro:settime(pomodoro.left) 244 | 245 | awful.tooltip({ 246 | objects = { pomodoro.widget, pomodoro.icon_widget}, 247 | timer_function = function() 248 | local collected = 'Collected ' .. pomodoro.npomodoros .. ' pomodoros so far.\n' 249 | if pomodoro.timer.started then 250 | if pomodoro.working then 251 | return collected .. 'Work ending in ' .. os.date("%M:%S", pomodoro.left) 252 | else 253 | return collected .. 'Rest ending in ' .. os.date("%M:%S", pomodoro.left) 254 | end 255 | else 256 | return collected .. 'Pomodoro not started' 257 | end 258 | return 'Bad tooltip' 259 | end, 260 | }) 261 | 262 | end 263 | 264 | return pomodoro 265 | end 266 | -------------------------------------------------------------------------------- /impl_test.lua: -------------------------------------------------------------------------------- 1 | local createPomodoro = require('impl') 2 | 3 | local wibox = { 4 | widget = { 5 | textbox = function() 6 | return { 7 | set_markup = function(self, s) return nil end, 8 | buttons = function(self, bs) return nil end, 9 | } 10 | end, 11 | imagebox = function() 12 | return { 13 | set_image = function(self, image_path) return nil end, 14 | buttons = function(self, bs) return nil end, 15 | } 16 | end, 17 | base = { 18 | make_widget = function() 19 | return { 20 | emit_signal = function(self, s) return nil end 21 | } 22 | end 23 | } 24 | } 25 | } 26 | local awful = { 27 | util = { 28 | getdir = function(str) return '/home/cooluser/.config/awesome' end, 29 | table = { 30 | join = function(elements) return nil end 31 | } 32 | }, 33 | spawn = { 34 | pread = function(cmd) return "" end, 35 | }, 36 | button = function(modifier, mouseButton, f) return nil end, 37 | tooltip = function(table) return nil end 38 | } 39 | local naughty = { 40 | notify = function(bg, fg, title, text, timeout) 41 | end 42 | } 43 | local beautiful = {} 44 | 45 | local timer = function(t) 46 | return { 47 | again = function(self, f) return nil end, 48 | stop = function(self) return nil end, 49 | connect_signal = function(self, f) return nil end, 50 | } 51 | end 52 | 53 | local awesome = { 54 | connect_signal = function(self, f) return nil end, 55 | } 56 | 57 | local pomodoro = createPomodoro(wibox, awful, naughty, beautiful, timer, awesome) 58 | 59 | 60 | describe("Should set the default values properly", function() 61 | it('pause duration should be 5 minutes', function() 62 | assert.are.equal(300, pomodoro.pause_duration) 63 | end) 64 | it('work duration should be set to 25 minutes', function() 65 | assert.are.equal(1500, pomodoro.work_duration) 66 | end) 67 | it('default changing value for increasing and decreasing should be one minute', function() 68 | assert.are.equal(60, pomodoro.change) 69 | end) 70 | it('working pomodoro should be the next state', function() 71 | assert.are.equal(true, pomodoro.working) 72 | end) 73 | end) 74 | 75 | describe('Set time should change the textbox appropriately', function() 76 | local s = spy.on(pomodoro.widget, "set_markup") 77 | it('more than one hour pomodoro should be formatted with an hour part', function() 78 | pomodoro:settime(3601) 79 | assert.spy(s).was_called_with(pomodoro.widget, "Pomodoro: 01:00:01") 80 | end) 81 | it('less than one hour should be set with only minutes and seconds', function() 82 | pomodoro:settime(1500) 83 | assert.spy(s).was_called_with(pomodoro.widget, "Pomodoro: 25:00") 84 | end) 85 | end) 86 | 87 | describe('Notifications should send a naughty notification and change pomodoro object appropriately', function() 88 | -- TODO: For some reason I cannot mock naughty... 89 | it('naughty should be called properly', function() 90 | local s = spy.on(naughty, 'notify') 91 | pomodoro:notify('title', 'sometext', 10, true) 92 | end) 93 | it('should set the left to the new duration for the new state', function() 94 | pomodoro:notify('title', 'sometext', 10, true) 95 | assert.are.equal(10, pomodoro.left) 96 | end) 97 | it('should set working to false if the next timer is not for a work duration', function() 98 | pomodoro:notify('title', 'sometext', 10, false) 99 | assert.are.equal(false, pomodoro.working) 100 | end) 101 | end) 102 | 103 | describe('Starting a pomodoro', function() 104 | it('should start the timer', function() 105 | local s = spy.on(pomodoro.timer, 'again') 106 | pomodoro:start() 107 | assert.spy(s).was_called_with(pomodoro.timer) 108 | end) 109 | end) 110 | 111 | 112 | describe('Stopping a pomodoro', function() 113 | it('should stop the timer', function() 114 | local s = spy.on(pomodoro.timer, 'stop') 115 | pomodoro:stop() 116 | assert.spy(s).was_called_with(pomodoro.timer) 117 | end) 118 | it('should set the next pomodoro to be for work', function() 119 | pomodoro:stop() 120 | assert.are.equal(true, pomodoro.working) 121 | end) 122 | it('should set time left to the work duration', function() 123 | pomodoro:stop() 124 | assert.are.equal(1500, pomodoro.left) 125 | end) 126 | it('should set the textbox to the work duration', function() 127 | local s = spy.on(pomodoro, 'settime') 128 | pomodoro:stop() 129 | assert.spy(s).was_called_with(pomodoro, 1500) 130 | end) 131 | end) 132 | 133 | describe('Pausing a pomodoro', function() 134 | it('should stop the timer', function() 135 | local s = spy.on(pomodoro.timer, 'stop') 136 | pomodoro:stop() 137 | assert.spy(s).was_called_with(pomodoro.timer) 138 | end) 139 | end) 140 | 141 | describe('Preserve the pomodoro before restart if any', function() 142 | it('should find the last time in X resource DB', function() 143 | awful.spawn.pread = function(s) 144 | return [[ 145 | awesome.Pomodoro.time: 716 146 | XTerm*faceName: consolas 147 | xterm*.background: grey5 148 | ]] 149 | end 150 | pomodoro:init() 151 | assert.are.equal(716, pomodoro.left) 152 | end) 153 | it('should start the pomodoro right away if the value is found in the database after a restart and it was started', function() 154 | local s = spy.on(pomodoro, 'start') 155 | awful.spawn.pread = function(s) 156 | return [[ 157 | awesome.Pomodoro.time: 716 158 | awesome.Pomodoro.started: 1 159 | XTerm*faceName: consolas 160 | xterm*.background: grey5 161 | ]] 162 | end 163 | pomodoro:init() 164 | assert.spy(s).was_called() 165 | end) 166 | it('should use the normal duration and don\'t start a pomodoro if not found in the database', function() 167 | local s = spy.on(pomodoro, 'start') 168 | awful.spawn.pread = function(s) 169 | return [[ 170 | awesome.pomodoro.time: 716 171 | XTerm*faceName: consolas 172 | xterm*.background: grey5 173 | ]] 174 | end 175 | pomodoro:init() 176 | assert.spy(s).was_not_called() 177 | assert.are.equal(1500, pomodoro.left) 178 | end) 179 | 180 | it('should not start the timer if it was paused or stopped', function() 181 | local s = spy.on(pomodoro, 'start') 182 | awful.spawn.pread = function(s) 183 | return [[ 184 | awesome.Pomodoro.time: 716 185 | awesome.Pomodoro.started: 0 186 | XTerm*faceName: consolas 187 | xterm*.background: grey5 188 | ]] 189 | end 190 | pomodoro:init() 191 | assert.spy(s).was_not_called() 192 | assert.are.equal(716, pomodoro.left) 193 | end) 194 | end) 195 | 196 | describe('Should use the images properly', function() 197 | path_we_got = nil 198 | local pomodoro = createPomodoro(wibox, awful, naughty, beautiful, timer, awesome) 199 | pomodoro.module_path = "pomodoro/" 200 | pomodoro.icon_widget.set_image = function(self, image_path) 201 | path_we_got = image_path 202 | end 203 | pomodoro.working = true 204 | 205 | it('should set the default icon to gray by default', function() 206 | pomodoro:init() 207 | assert.are.equal('/home/cooluser/.config/awesome/pomodoro/images/gray.png', path_we_got) 208 | end) 209 | 210 | it('should set the image to the locked one when we pause a pomodoro', function() 211 | pomodoro:pause() 212 | assert.are.equal('/home/cooluser/.config/awesome/pomodoro/images/locked.png', path_we_got) 213 | end) 214 | 215 | it('should set the image to the gray one when we stop a pomodoro', function() 216 | pomodoro:stop() 217 | assert.are.equal('/home/cooluser/.config/awesome/pomodoro/images/gray.png', path_we_got) 218 | end) 219 | 220 | it('should change the image depending on the time that elapsed for the pomodoro', function() 221 | -- there is more than 2/3 from the next break 222 | pomodoro.left = 26 223 | pomodoro.work_duration = 30 224 | pomodoro:ticking_time() 225 | assert.are.equal('/home/cooluser/.config/awesome/pomodoro/images/green.png', path_we_got) 226 | 227 | -- there is more than 1/3 from the next break but smaller than 2/3 228 | pomodoro.left = 16 229 | pomodoro.work_duration = 30 230 | pomodoro:ticking_time() 231 | assert.are.equal('/home/cooluser/.config/awesome/pomodoro/images/orange.png', path_we_got) 232 | 233 | pomodoro.left = 9 234 | pomodoro.work_duration = 30 235 | pomodoro:ticking_time() 236 | assert.are.equal('/home/cooluser/.config/awesome/pomodoro/images/red.png', path_we_got) 237 | end) 238 | 239 | it('should set the icon back to gray when the pomodoro finishes', function() 240 | pomodoro.left = 0 241 | pomodoro:ticking_time() 242 | assert.are.equal('/home/cooluser/.config/awesome/pomodoro/images/gray.png', path_we_got) 243 | end) 244 | it('shouldn\'t change the icon if we are currently not working', function() 245 | pomodoro.working = false 246 | pomodoro.work_duration = 30 247 | interval_elements = {26, 16, 9} 248 | for i, element in ipairs(interval_elements) do 249 | pomodoro.left = element 250 | pomodoro:ticking_time() 251 | assert.are.equal('/home/cooluser/.config/awesome/pomodoro/images/green.png', path_we_got) 252 | end 253 | end) 254 | end) 255 | 256 | 257 | describe('Long breaks', function() 258 | 259 | local pomodoro = createPomodoro(wibox, awful, naughty, beautiful, timer, awesome) 260 | it('should properly start a long break after 4 full pomodoros', function() 261 | for i=1,4,1 do 262 | pomodoro.working = true 263 | pomodoro.left = 0 264 | assert.are.not_equal(15 * 60, pomodoro.pause_duration) 265 | pomodoro:ticking_time() 266 | end 267 | assert.are.equal(15 * 60, pomodoro.pause_duration) 268 | end) 269 | end) 270 | 271 | -------------------------------------------------------------------------------- /init.lua: -------------------------------------------------------------------------------- 1 | local wibox = require("wibox") 2 | local awful = require("awful") 3 | local naughty = require("naughty") 4 | local beautiful = require("beautiful") 5 | local module_path = (...):match ("(.+/)[^/]+$") or "" 6 | local createPomodoro = require(module_path..'impl') 7 | local timer = (type(timer) == 'table' and timer or require("gears.timer")) 8 | local awesome = awesome 9 | 10 | 11 | module("pomodoro") 12 | 13 | return createPomodoro(wibox, awful, naughty, beautiful, timer, awesome) 14 | --------------------------------------------------------------------------------