Thunderbird Task Widget
This widget will display some info about your tasks in Thunderbird.
Contents |
Script
We have 2 scripts: task_reader.sh and task_summary.sh. You can download it from pastie.org: http://pastie.org/932862 http://pastie.org/932863
The dirty job is done in task_reader.sh, however. task_summary is just an utility. What task_reader does is giving a select command to thunderbird's local.sqlite
NOTE: if you have multiple thunderbird accounts the script will FAIL, because it uses ~/.thunderbird/*/ to workaround the profile name randomness. You can easily fix changing line 2 in task_summary.sh
You can try if that works for you running
sh task_summary.sh
It should print the number of number of high, medium and low priority tasks you have.
The awesome part
Creating the widget
We have to use bashets so remember to add require("bashets") at the top of your file and bashets.start() somewhere
Now, do this:
taskw = widget({type = "textbox", name = "taskw", popup = nil })
bashets.register_async(taskw,
'/your/path/to/task_summary.sh',
'<b><span color="red">$1</span>/<span color="cyan">$2</span>/<span color="white">$3</span></b>"',
20, 2)
Yes, we are using async because, unfortunately, task_reader.sh is a bit slow and it will make awesome lag.
Open thunderbird on click
We have a widget, so we want to make it powerful. This opens thunderbird when clicked. Note that, if thunderbird is already running, it will only "raise" it.
taskw:buttons(awful.util.table.join(
awful.button({ }, 1, function () awful.util.spawn_with_shell('thunderbird') end)
))
Displaying a tooltip
I found two ways of implementing this; they do the same job (you can see it in the preview), but one is buggy, while the other is not. YOU SHOULD FOLLOW THE FIRST!! I include the buggy one just for the sake of completeness, and because it's a bit tidier
A slightly more complex but SAFE way
We have to create still another shell file [1] It will simply call task_reader.sh, add some HTML and, most important, cache it (it will simply put the contents in /tmp/thunder_task_cache ). We'll then do this
taskw_popup = nil
function taskw_get_popup_text ()
awful.util.spawn('/home/davide/coding/projects/cli_utils/thunder_task/task_cache.sh')
end
function taskw_show_popup ()
taskw_popup = naughty.notify({
text = awful.util.pread('cat /tmp/thunder_task_cache'),
title = "Tasks"
})
end
function taskw_close_popup()
if taskw_popup ~= nil then
naughty.destroy(taskw_popup)
taskw_popup = nil
end
end
taskw:add_signal("mouse::enter", taskw_show_popup )
taskw:add_signal("mouse::leave", taskw_close_popup )
taskw_popup_text_timer = timer({timeout=10})
taskw_popup_text_timer:add_signal('timeout', taskw_get_popup_text)
taskw_popup_text_timer:start()
The easy (but buggy) way
You shouldn't use this. It's of course usable, but not optimal. It will make awesome lag when hovering the widget
It's a bit dirty, but that's it. I'm sure there is a better way to do this, but I just can't find it. If you do, please write it here
Adding this to your rc.lua will result in a tooltip like the one in preview. You have all your tasks displayed, highlighted with different colors (according to priority)
BUG: showing the tooltip will block awesome. In fact, calling task_reader.sh is slow, and doing it three times is even slower. However, it just take 1 second on my computer; and when I'm hovering that widget, I'm not doing anything else, so that lagging is not so bad. Anyway, we should find a better way of doing this.
taskw_popup = nil
function taskw_show_popup ()
taskw_popup = naughty.notify({
text = '' ..
awful.util.pread('/home/davide/coding/projects/cli_utils/thunder_task/task_reader.sh high') ..
'' ..
awful.util.pread('/home/davide/coding/projects/cli_utils/thunder_task/task_reader.sh normal') ..
'' ..
awful.util.pread('/home/davide/coding/projects/cli_utils/thunder_task/task_reader.sh low') ..
'',
title = "Tasks"
})
end
function taskw_close_popup()
if taskw_popup ~= nil then
naughty.destroy(taskw_popup)
taskw_popup = nil
end
end
taskw:add_signal("mouse::enter", taskw_show_popup )
taskw:add_signal("mouse::leave", taskw_close_popup )