├── pomodoro.png ├── README.md └── init.lua /pomodoro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/francois2metz/pomodoro-awesome/HEAD/pomodoro.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pomodoro Widget 2 | 3 | ## Usage 4 | 5 | cd ~/.config/awesome 6 | git clone git://github.com/francois2metz/pomodoro-awesome.git pomodoro 7 | 8 | In you rc.lua: 9 | 10 | ```lua 11 | -- insert after beautiful.init("...") 12 | pomodoro = require("pomodoro") 13 | 14 | -- widget is now available in pomodoro: 15 | ``` 16 | 17 | Add it to your wibox: 18 | 19 | ```lua 20 | mywibox[s].widgets = { 21 | pomodoro, 22 | mytextclock, 23 | } 24 | ``` 25 | 26 | ## Customization 27 | 28 | If you want change the default icon, you can use beautiful: 29 | 30 | beautiful.pomodoro_icon = '/your/path/to/pomodoro/icon' 31 | 32 | ## License 33 | 34 | Copyright 2010-2012 François de Metz 35 | 36 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 37 | Version 2, December 2004 38 | 39 | Copyright (C) 2012 François de Metz 40 | 41 | Everyone is permitted to copy and distribute verbatim or modified 42 | copies of this license document, and changing it is allowed as long 43 | as the name is changed. 44 | 45 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 46 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 47 | 48 | 0. You just DO WHAT THE FUCK YOU WANT TO. 49 | -------------------------------------------------------------------------------- /init.lua: -------------------------------------------------------------------------------- 1 | -- Author: François de Metz 2 | 3 | local awful = require("awful") 4 | local naughty = require("naughty") 5 | local beautiful = require("beautiful") 6 | local wibox = require("wibox") 7 | local gears = require("gears") 8 | 9 | -- 25 min 10 | local pomodoro_time = 60 * 25 11 | 12 | local pomodoro_image_path = beautiful.pomodoro_icon or awful.util.getdir("config") .."/pomodoro/pomodoro.png" 13 | 14 | -- setup widget 15 | local pomodoro = wibox.widget({ 16 | image = pomodoro_image_path, 17 | widget = wibox.widget.imagebox 18 | }) 19 | 20 | -- setup timers 21 | local pomodoro_timer = gears.timer({ timeout = pomodoro_time }) 22 | local pomodoro_tooltip_timer = gears.timer({ timeout = 1 }) 23 | local pomodoro_nbsec = 0 24 | 25 | local function pomodoro_start() 26 | pomodoro_timer:start() 27 | pomodoro_tooltip_timer:start() 28 | pomodoro.bg = beautiful.bg_normal 29 | end 30 | 31 | local function pomodoro_stop() 32 | pomodoro_timer:stop(pomodoro_timer) 33 | pomodoro_tooltip_timer:stop(pomodoro_tooltip_timer) 34 | pomodoro_nbsec = 0 35 | end 36 | 37 | local function pomodoro_end() 38 | pomodoro_stop() 39 | pomodoro.bg = beautiful.bg_urgent 40 | end 41 | 42 | local function pomodoro_notify(text) 43 | naughty.notify({ title = "Pomodoro", text = text, timeout = 10, 44 | icon = pomodoro_image_path, icon_size = 64, 45 | width = 200 46 | }) 47 | end 48 | 49 | pomodoro_timer:connect_signal("timeout", 50 | function(c) 51 | pomodoro_end() 52 | pomodoro_notify('Ended') 53 | end) 54 | 55 | pomodoro_tooltip_timer:connect_signal("timeout", 56 | function(c) 57 | pomodoro_nbsec = pomodoro_nbsec + 1 58 | end) 59 | 60 | pomodoro_tooltip = awful.tooltip({ 61 | objects = { pomodoro }, 62 | timer_function = function() 63 | if pomodoro_timer.started then 64 | r = (pomodoro_time - pomodoro_nbsec) % 60 65 | return 'End in ' .. math.floor((pomodoro_time - pomodoro_nbsec) / 60) .. ' min ' .. r 66 | else 67 | return 'pomodoro not started' 68 | end 69 | end, 70 | }) 71 | 72 | local function pomodoro_start_timer() 73 | if not pomodoro_timer.started then 74 | pomodoro_start() 75 | pomodoro_notify('Started') 76 | else 77 | pomodoro_stop() 78 | pomodoro_notify('Canceled') 79 | end 80 | end 81 | 82 | pomodoro:buttons(awful.util.table.join( 83 | awful.button({ }, 1, pomodoro_start_timer) 84 | )) 85 | 86 | return pomodoro 87 | --------------------------------------------------------------------------------