GNOME Break Timer: Week 2

I’m starting the third week of coding on my GSoC 2013 project, a new break timer application for GNOME. I spent the last two weeks working on an odd mix of little things. For the most part, my goal over that time was to make the gnome-break-timer project (previously brainbreak, still brainbreak in most places) nicer to work with. I’m a bit of a sucker for clean code, and, well…

By Manu Cornet, from Bonkers World
By Manu Cornet, from Bonkers World

So, to start off, I switched over to Automake from my old build system, which was using BuilDj and Waf. I’m still a big fan of those two, at least philosophically. In practice, Automake just seemed like a good choice because it’s familiar to people, and I really want to maintain a high bus factor for this project. This isn’t the sort of application that I would expect to have a continuous flow of regular contributors, so I think it’s important that someone can jump in and figure it out for without too many obstacles.

One interesting puzzle here was doing a convenience library with Automake and Vala. I started using convenience libraries for this project so I could strictly define different parts of the application. The idea is code at one level shouldn’t know anything about code above it, and we can formalize that by actually building these bits of code to separate objects that get linked together later. This also, conveniently, allows us to reuse the code that is common between the settings panel and the break timer daemon without needing to compile it twice. Not a big deal here, but I like it anyway.

I found lots of helpful information about doing convenience libraries with Automake, but Vala posed something of a problem because Automake doesn’t do everything for us with Vala (yet). I need to pass several extra flags to valac, both for the library and for the target that uses the library, and I need to do that without messing up build dependencies. I don’t want to run into cases where the build fails (or, worse, doesn’t fail!) until I run make clean. (For what it’s worth, the old build system with BuilDj and Waf figured this out wonderfully and generally rebuilt the thing about twice as fast as Automake, but I also hadn’t set up localization or config.h, so I guess that’s kind of moot). I checked out how some projects like Deja Dup were doing convenience libraries, and I came up with a handy reusable pattern:

Makefile.am for the rather unhelpfully named “common” module:

M_CPPFLAGS = $(BRAINBREAK_CFLAGS) \
	-include $(CONFIG_HEADER)

noinst_LTLIBRARIES = \
	libcommon.la

libcommon_la_SOURCES = \
	NaturalTime.vala \
	SessionStatus.vala \
	...

libcommon_la_LIBADD = \
	$(BRAINBREAK_LIBS)

libcommon_la_VALAFLAGS = \
	--pkg gio-2.0 \
	--library common \
	--vapi common.vapi \
	-H common.h

junk_files = \
	$(libcommon_la_SOURCES:.vala=.c) \
	libcommon_la_vala.stamp

dist-hook:
	cd $(distdir) && rm -f $(junk_files)

CLEANFILES = \
	$(junk_files) \
	common.vapi \
	common.h

Makefile.am for some code that uses that module:

AM_CPPFLAGS = $(BRAINBREAK_CFLAGS) \
	-include $(CONFIG_HEADER) \
	-I $(top_srcdir)/common

SUBDIRS = 

bin_PROGRAMS = \
	brainbreak-settings

brainbreak_settings_SOURCES = \
	ApplicationPanel.vala \
	BreakPanel.vala \
	BreakType.vala \
	main.vala \
	...

brainbreak_settings_VALAFLAGS = \
	--pkg gtk+-3.0 \
	$(top_srcdir)/common/common.vapi

brainbreak_settings_LDADD = \
	$(BRAINBREAK_LIBS) \
	$(top_srcdir)/common/libcommon.la

brainbreak_settings_vala.stamp: \
	$(top_srcdir)/common/libcommon_la_vala.stamp

junk_files = \
	$(brainbreak_settings_SOURCES:.vala=.c) \
	brainbreak_settings_vala.stamp

dist-hook:
	cd $(distdir) && rm -f $(junk_files)

CLEANFILES = \
	$(junk_files)

Of course, I also rewrote a bunch of stuff which had been thrown together a little too hastily. I knew I would need to rewrite a lot of code, but I wanted to get the “rewrite and start over” bug out of my system in the beginning, and I think it worked. Allan Day already came up with some lovely mockups that I could start with, so I used those to guide me in choosing what needed work. As I worked through implementing different bits of his “take a break” UI, I noticed some aspects that would have been quite difficult with the design I had earlier. I squished and pulled things accordingly, giving the UI code a little more power and knowledge, and getting rid of needlessly arcane kinds of “reusable” code. But that’s all a little boring.

I’m really excited for the next bit. I will be working on a beautiful new Break Settings application, complete with GtkHeaderBar and (hopefully) a non-ridiculous time input widget. I’ll post some pictures and a new download soon!

My GSOC 2013 project: a new break timer application for GNOME

A little while ago, my proposal was accepted for Google Summer of Code 2013. So, this summer I will be working with Jasper St. Pierre and the GNOME project on a shiny new break timer application. We’re going to spend some time filling out the wiki page for the new break timer design, and from mid-June to mid-September I will try to implement it as well as I can.

A break timer application is pretty well what it says on the tin. It’s an application that can monitor your computer use and remind you to take a break every now and then. Things get a little tricky when we start thinking about how to make that sort of application effective. Among other things, gauging how much someone is using the computer is kind of fiddly, and people don’t really enjoy being interrupted all the time. If it’s done well, though, I think anyone can benefit from this type of application. Taking regular breaks isn’t just healthy for the body: it can keep your mind happy, too.

I’m excited about this project for a few reasons. First, I have been meaning to get involved with GNOME for a while, and I’m expecting to touch a few different projects in order to produce something seamless. This is also an itch I have wanted to scratch — I really want a good, shiny and new “take a break” app for a variety of reasons — and it’s an opportunity to tie up a loose end from a while ago. I actually already started on a new break timer app, but I never quite reached a releasable product. With my project this summer, I’m going to be starting with (some of) what I already made, which will allow me to iterate efficiently and, I hope, to create something beautiful and releasable by the deadline.

For the time being, I thought it might be fun to actually share the other one I keep mentioning, which has the strange working title “Brain Break”. It isn’t perfect, but if you’re interested in a take a break app made for GNOME 3 (and yes, that includes Unity), that uses GTK+3 and real desktop notifications (and not the old system tray), perhaps you will like it? I made it because I thought the existing options for break timer software were getting a little old, but also because those options didn’t really work for me: when there was a Skip or Postpone button, I got into the habit of pressing it as soon as I could. (I’m a computer nerd. Workarounds are my middle name). When there wasn’t, I would get angry at the software for interrupting me and I got into the habit of disabling it proactively (and then forgetting to turn it back on).

Brain Break doesn’t have a Postpone button or a Skip button, but it makes up for it with a “Take a break” overlay that blocks your screen without blocking input. So, you can finish that one last thing without needing to postpone or skip the break (or, for that matter, lose your train of thought). Because there’s no easy way to make the “Take a break” overlay go away, Break Break is hard to ignore, but it tries to be nice about it.

Brain Break is probably ready to use. I’ve been using it for ages, and I like it, at least. It’s on Launchpad at launchpad.net/brainbreak. If you’re using Ubuntu, you can install it very easily from its PPA, launchpad.net/~brainbreak/+archive/daily. Just open a terminal and run sudo add-apt-repository ppa:brainbreak/daily, then sudo apt-get update; sudo apt-get install brainbreak.

Brain Break's "take a break" screen is gentle, but hard to miss
Brain Break’s “take a break” screen is gentle, but hard to miss
Brain Break's settings tool
Use the break settings panel to set specific break times, or disable them for an hour

The new break timer app probably won’t be the same as Brain Break, but in order to make the new one as awesome as possible, maybe there’s something to learn from Brain Break? Please, try it out, and share your thoughts in the comments! You might like it, and either way I would love some feedback to get ideas flowing.

Reposted from June 11, with apologies to Planet Ubuntu. Hi there, Planet GNOME!