Ethernet Events with Cuttlefish

This article will serve to purposes: to introduce cuttlefish and to introduce the Ethernet plugin I wrote for it. So without further adieu:

Cuttlefish is an automation tool for ubuntu that allows you to setup rules for performing actions.

For example:

When I lock my screen, pause my music player

When I connect to my home WIFI, start my backup software

When I get hungry, order me a pizza

Okay, that last one might take a little extra effort to get working, but you get the idea. It’s a cool piece of software.

sudo apt-get install cuttlefish

Queue the backstory…

I’m a frequent user of synergy–the cross platform software that lets you share a mouse and keyboard between two or more networked computers. If you haven’t used something like this before, you need to check it out.

The idea is simple: slide the mouse to the edge of the screen of one computer and it jumps to another. Your mouse and keyboard are now controlling a completely different computer than the one they are plugged into. In practice, it feels much like a dual-monitor setup, with the exception that the two screens are being driven by two completely separate computers running two entirely different operating systems. I use synergy at my desk to transition between my laptop and my desktop, much like the picture above.

sudo apt-get install synergy quicksynergy

* quicksynergy provides a nice GUI for easy configuration

While my desk experience is all peaches and double rainbows, when I’m away from my desk it doesn’t make sense to leave the synergy daemon running on my laptop. Enter cuttlefish.

The plan was to start/stop the synergy daemon when the Ethernet cable plugged in/unplugged respectively. However, cuttlefish currently doesn’t ship with any Ethernet stimuli. The application allows you to trigger events based on WIFI connections, but Ethernet events were unexpectedly missing. Thus, I got my hands dirty with a little python and came up with this:

Disclaimer: This is my first time working with both python and D-Bus so I’m open to constructive criticism.

Once again, WP won’t let me upload script files, so save the file as ethernet.py and drop it in ~/.cuttlefish/plugins/ You’ll need to either restart cuttlefish, or use the GUI to reload all plugins, but when you do, you should find Ethernet events under the network category.

I hope to add Ethernet reactions at some point so that you can apply specific IP/Netmask/DNS settings based on some stimulus, but this is all I have for now.