Hacking away on my Zim notebook

Working with open source is fun because it lets me explore software and change little things. If you’re not really into code and config files, you might want to skip this post ๐Ÿ™‚

Zim task list (default)

Since some time I use Zim, a desktop wiki, to take notes in meetings and at conferences. It shares a few good things with Tomboy, the default notebook on Ubuntu (linking pages, immediately saving what you type so you don’t loose anything on sudden power loss) but has a few things I prefer:

  • Notes are stored as plain text: easier to use other text editors, version control, and scripts, and if for any reason Zim fails, I can still access my data quite easily.

  • The main interface makes organising and navigating notes easier.

  • The Task List plugin extracts lines with possible tasks, so it’s easier to keep track of follow-ups or actions in notes by simply typing a line like:

    [ ] Document my hacks in a blog post

The Task List itself is a separate window you can pull up, to see all open to do’s. But I wanted to fix a few things to make it more powerful in daily use.

The suggestions below are based on Ubuntu 10.10, and with Zim 0.49 installed as Ubuntu package.

Zim notes with tasks

Quicker access to Zim

The first step is to have Zim available at my finger tips, so that taking notes is instant. I want to use the key combination Win-Z to bring up the notebook. You need the wmctrl package to be able to raise the window if it already is open but buried under other windows.

sudo apt-get install wmctrl

Next, I went to the menu System > Preferences > Keyboard Shortcuts and added a custom shortcut. It starts Zim to make sure it is running (make sure your notebook is set as the default notebook to open in Zim’s preferences), then raises the window to the top:

bash -c "zim && wmctrl -R \"Notes - Zim\" "
Zim custom shortcut

Quicker access to the task list within Zim

I’d like to have the task list available via a keyboard shortcut. I prefer the combination Ctrl-T, which already is assigned to Format > Verbatim (monospaced). So I edited ~/.config/zim/accelmap and uncommented the relevant lines to show the task list and to apply that formatting, to assign the key combination to the task list.

(gtk_accel_path "<Actions>/TaskListPlugin/show_task_list" "<Control>t")

(gtk_accel_path "<Actions>/PageView/apply_format_code" "")

Bonus key combination: (while we’re here anyway). I have enabled the Inline Evaluator plugin in Zim, so that I can do quick math within my notebook. If I type 1500*1.19 and select the menu item Tools > Evaluate Math, Zim calculates the outcome and changes the line to: 1500*1.19= 1785.0. To make that easier, I’ll assign Ctrl-= to that function:

(gtk_accel_path "<Actions>/InlineCalculatorPlugin/eval_math" "<Control>equal")

Shorter task descriptions column

The column with task descriptions is made wide enough to contain complete task descriptions. Which means that you usually need to scroll to see the other columns.

With many pages, seeing in which page a task resides helps a lot to understand its context. The descriptions should be limited to a more narrow column.

Task list more optimal

Diving into the source code, I found out that the developers already thought about that as well. They implemented a fixed-width column for the Maemo platform, with the remark

# FIXME probably should also limit the size of this
# column on other platforms ...

That made it really easy to change my own copy of Zim to do just that. It results in a simple patch:

--- tasklist.py.or 2011-01-15 16:36:42.624406264 +0100
+++ tasklist.py 2011-01-15 16:12:01.555792557 +0100
@@ -564,6 +564,8 @@
 			column.set_sort_column_id(i)
 			if i == self.TASK_COL:
 				column.set_expand(True)
+				column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
+				column.set_fixed_width(500)
 				if ui_environment['platform'] == 'maemo':
 					column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
 					column.set_fixed_width(250)

It’s a good idea to keep the patch around: upgrading to a newer version of Zim would remove the hack, so I just made a script to re-apply the patch:

#!/bin/bash
# Apply patch to Zim tasklist plugin to set fixed-width task description column
# Best performed with sudo
cd /usr/share/pyshared/zim/plugins
patch < /home/rolf/bin/fix-zim-tasklist.patch
cd -

Better positioned task list window

The Task List window often pops up over the notebook itself, and stays on top. Clicking on a task brings up the note in which the task resides, and focuses it on that task. But that’s not so useful if the note is hidden under the task window.

I already use Devil’s Pie, self-described as โ€œA totally crack-ridden program for freaks and weirdos who want precise control over what windows do when they appear.โ€ Install gdevilspie if you like a GUI to set up rules for windows.

I have plenty of screen (1920×1080) so I decided to let the notes and the task list live next to each other, with these two rules in ~/.devilspie/zim.ds

( if ( begin ( is ( window_name ) "Notes - Zim" )) ( begin ( geometry "926x1032+0+24" )))
( if ( begin ( is ( window_name ) "Task List - Zim" )) ( begin ( geometry "990x1032+930+24" )))
Zim notes and tasks side by side

Done

My laptop has become a better notebook! At any moment, Win-Z brings up my notes, to quickly jot down something, and when in my notebook, Ctrl-T brings up the task list to let me easily navigate the to do’s and follow-ups in my notes. Staying on top of things has become a little bit easier.

chevron_left
chevron_right

Join the conversation

comment 8 comments
  • Nice! I did something similar. I have a Bash script that either starts Zim, raises it to the front, or closes the window, depending on its state. After doing that it commits my notebook with Git. (The version control plugin is nice, but it only commits when you quit Zim completely or start it from scratch–sometimes I have Zim running for days on end and it would never commit, so I have Git as an extra layer of protection.) I bound the script to Win+Z also.

    I also bound a script to Win+T that presses Ctrl+B and types in the current time–handy for keeping a log with the calendar plugin.

    And I set Win+A to run a script that opens the quicknote plugin, but I tend to forget to use it. ๐Ÿ™‚

    Like you said, with these kinds of shortcuts, a laptop with Zim becomes a quick and powerful notetaking tool.

    • Somehow, I am not able to set the keyboard shortcut “Unity+Z” to start or bring it to the front. When highlight the custom shortcut and press “Unity+Z”, a little box opens with “z”.

      Same problem on Ubuntu 11.10 on W510 Thinkpad and Ubuntu 12.04 on a hand built desktop. I was able to set this on 11.10 on the W510, but not since I re-imaged the laptop last week. Tips?

      • A late reply… I fiddled around with this long ago: Unity by default uses a tap on the Win/Unity key to bring up the dash, and a continuous press on it to see the launcher and switch to an application (Win-1, Win-2, …)

        Combinations like “Win+Z” don’t really work well with this.

        I’ve changed my keyboard preferences to use Alt+Win/Unity to bring up the launcher, but you need the CompizConfig Settings Manager for that, and it might not be available in the next version anymore.

        Locking Zim in a specific spot on the launcher to make it available under e.g. Win-3 is possible, but with multiple notebooks you can’t jump straight into a specific one.

      • Something to add to the guys talking about the unity binding of the super (win) key for the dash: a suggestion is to use something like ctrl + alt + j and ctrl + alt + k. This works if you mostly use the keyboard as your fingers are already on the home rows.

        And opening a specific notebook is of course possible, by passing the name of the notebook as an argument.

        So, bash -c “zim Personal && wmctrl -R \”Personal – Zim\”” opens up your personal notebook, and so on.

        Only nitpick is that wmctrl activates the zim window, but doesn’t move it to the current workspace… instead switches focus to the workspace where zim is. Never mind… as long as the note-taking is as easy as this.

        Good blog post!

      • Thanks – I’m actually using Ctrl-Win-combinations by now… Ctrl-Win-(P,Left) brings up my personal notes and puts them on the left half of the screen.

        I should update this info and add some of the more recent stuff I added ๐Ÿ™‚

    • 1) The “custom shortcut” menu is actually not in Zim, it’s in Ubuntu: go to the top-right icon on the screen, that opens a menu (in 14.04: About this computer, Ubuntu Help, etc). Pick “System settings”, then find the Keyboard icon under Hardware, then the tab Shortcuts, and there you’ll see Custom Shortcuts in the left-hand column.

      It’s a system-wide shortcut: you want it to work when Zim is not active (or not even running)

      2) To edit ~/.config/zim/accelmap: make sure you quit all Zim notebooks first, because indeed: if you don’t, they’ll be overwritten.

Leave a comment

Your email address will not be published. Required fields are marked *

Comment
Name
Email
Website

This site uses Akismet to reduce spam. Learn how your comment data is processed.