Wednesday, November 16, 2011

Clipboard manager

Reading Jeff Hooglan's post on Parcellite reminded me that I have not blogged about my own clipboard manager that I am writing , ClipCat (Clip Catalog). I really missed ClipMate when I switched to Linux years ago and didn't find anything remotely comparable. Klipper in KDE was OK, but I have switched to Gnome (may switch again because of Unity and Gnome 3, but that's another story...). I tried Glipper, Klipper, Parcelite, etc. but they did not have all the features that I wanted.
So, I decided to try and write one myself. It's coming along nicely, and I use it every day.

Main Features:
  • Panel icon with drop down menu of clip history, with current clipboard contents at the top and highlighted.
  • History menu can be sorted Alphabetical, Reverse Alphabetical, Chronological, Reverse Chronological, Most Used, Last Used.
  • Snippets, with user set categories & icons in the history sub-menu.
  • Optional properties - category, title, tags, source, note, for a snippet (or clip).
  • Clips/snips can be edited.
  • Grow a clip/snip, if a longer version is copied (optional).
  • Can append next copied text to an existing clip.
  • Can automatically append successive clipboard contents to a clip, or into a new clip.
  • Create a new clip directly, and put it on the clipboard.
  • Can insert date/time into a clip.
  • Load a file into a clip.
  • Save a clip to a file.
  • Search clips/snips. Full text search with AND, OR, NOT, NEAR operators and wild cards. Table column to search can be specified.
  • Compact, repair, backup, restore of clips database file.
Clip history menu (and snip sub-menu) are opened by clicking on ClipCat's panel icon. The history menu is configurable as to number of items shown in primary menu (the rest are shown in a sub-menu), length of the menu item shown, length of the preview shown in a tooltip (if too long to show in menu). Right clicking brings up a menu for opening the Action Window, sorting clips, clearing clip history, opening the preferences dialog, showing help or the About dialog. Middle click opens the property dialog for setting the category, tags, title, source or note of a clip/snip.

The small Action Window allows creating, viewing, editing clips, as well as executing plugins that manipulate clips. The Action Window also has optional word wrap and spell checking. It's initial position on screen can be set, as well as whether it stays on top of other windows, and shows on all desktops. The font for the editor view can be chosen, and sound for events can be enabled. Some properties of the selected clip/snip are shown in a tooltip, such as title, date created, times used. Character and word count for the clip being viewed are shown in the right of the status bar. Character count is color coded according to it's probable suitability for Twitter, SMS text message, or Shoutbox.

A simple plugin architecture allows extra functionality to be added by writing a script in Python. A template is provided to start a new plugin script.
Current plugins:
  1. ClipCat information - version, number of clips/snips, etc..
  2. Delete blank lines.
  3. Dump snips in a category to a file.
  4. Email a clip.
  5. Explode a clip into several clips (split at newline or other delimiter).
  6. Move tagged clips to another category.
  7. Number lines (with user chosen separator after numbers).
  8. Open the URL's in a clip in a browser.
  9. Post clip on PasteBin, and put the URL pointing to it on the clipboard.
  10. Remove/replace text using a regular expression.
  11. Remove HTML-XML tags.
  12. Remove leading characters (#\\>, or user selected).
  13. Remove line numbers, ignoring dates.
  14. Send clip as an SMS text message.
  15. Shorten a URL and put the short version on the clipboard.
  16. Sort lines in the clip; alphabetical, reverse alphabetical, case insensitive, natural.
Plugins can be helpful to clean up email messages, remove comment characters from code, format text to be included in email or documents,
extract plain text from HTML code, make inserting items into forms easier, share clips, etc.
Some plugins log their actions to the editor of the Action Window, so it can be saved as a clip/snip for reference, if desired.

ClipCat is written in Python and pyGTK. Data is kept in the very reliable SQLite database, so only one file need be backed up. Each clip/snip has the properties date created, last used, times used, and and the user set properties. This database can be viewed or edited independently of ClipCat if needed.

I have tried it on an old Thinkpad, 600Mhz Celeron with only 256MB RAM and it still performed acceptably.

While far from perfect, I find it very useful even at the present stage of development. I have lots of ideas for improvement too. I hope to package it and recruit some testers soon. If interested, leave a comment.