Automate Ubuntu With Cuttlefish
A pretty clever guy called Newton once said, “for every action there is an equal and opposite reaction.” – the same is now true for Ubuntu with the use of Cuttlefish.
Cuttlefish allows you to create events that only happen under certain circumstances.
For example, I like to keep my audio muted as I don’t like system sound to be played out to me. However, I have Cuttlefish setup to automatically un-mute my sound when I open Rhythmbox or Totem Movie Player. Then when I exit either application, the sound is muted again.
Cuttlefish is very powerful in what it can do, you can do things like opening your browser when Ubuntu connects to your wireless LAN, or automatically lock your screen when a USB stick is unplugged (this is a great idea for computers in public places like in work).
I managed to catch up with the developer of Cuttlefish recently, where I asked him what the future holds for Cuttlefish. Here is what he had to say:
I have two bigger ideas for cuttlefish as a system:
First, reflexes will be extended by conditions. Currently you can define something like “Lock my screen, when I disconnect my smartphone”. But that might only be a valid reflex at the office. With conditons you could create a reflex like: “Lock my screen, when I disconnect my smartphone if I’m connected to office-wlan”.
The second idea is data exchange. Stimuli should provide the data they watch for and reactions should accept data to work with. Let me give an example:
Assume there is a “Watch Folder for new Files” which is set to watch your downloads folder for mp3-files. The stimulus should provide the complete path to created files, whenever it fires. A reaction could be “Queue a file in music player” that takes a path to queue. If everything works out like I plan, you would be able to create a reflex like:
“Whenever there is a new mp3 file in my download folder, queue it into my favorite music player”.
If the growing list of events and actions that are listed in Cuttlefish isn’t enough then the developers have you covered. Cuttlefish has a plugin system that allows users to create their own events and actions. Alex, Cuttlefish’ creator went on to explain:
[Cuttlefish has] a brand new plugin system. By this users can become contributers easily and create their own events and actions in just a couple of minutes — if they know a bit of python programming. I posted a coding tutorial on youtube (http://www.youtube.com/watch?v=zYUItu_dO0I).
Cuttlefish also has an indicator applet that allows you to run any rule that you have in place on demand. This is a great way of using Cuttlefish as a shortcut for system processes like enabling bluetooth, locking your screen or changing a default printer.
I tend to review a lot of applications and tools across the various blogs that I write for but not many keep a regular spot on my machine. Cuttlefish is an exception to this rule and it’s an application that I think a lot of users will definitely find useful.
Install Cuttlefish in Ubuntu 12.04
Cuttlefish is available to install straight from the Ubuntu Software Center – no PPAs needed. At present it is only available for Ubuntu 12.04.
[How To] Enable Cuttlefish Mono Indicator Icon
Heard of Cuttlefish? It’s is a small utility for Ubuntu that lets you set-up ‘rules’ to be followed when certain a action or state happens.
For example, pulling out the power cord from your laptop switches off Bluetooth and mutes your speakers.
It’s all very clever and very handy. But its default indicator icon is a little bit of an eyesore in the panel.
Cuttlefish, my aquatically-designed chum: there’s a time and place for garish purple-y pink tentacles and the Ubuntu indicator area isn’t it.
The good news is that Cuttlefish ships with an Ubuntu-friendly mono-version of its tray icon. It just doesn’t use it.
To getCuttlefish using the ‘mono’ icon you need to run the following three commands in the Terminal:
- cd /opt/extras.ubuntu.com/cuttlefish/share/cuttlefish/media
- sudo cp tentacle_indicator.png tentacle_indicator.png.old
- sudo cp cuttlefish_indicator.png tentacle_indicator.png
…And that’s all.
If you have Cuttlefish running you will need to quite and relaunch before the change takes hold.
Create events and reactions with Cuttlefish (Ubuntu Software Center)
Ubuntu Software Center offers a wide range of applications, featuring different levels of complexity, functionalities and use cases, presenting the user basic apps (calculator utilities, converters, etc), “medium” apps and full-fledged powerful tools.
Cuttlefish is a powerful utility featuring its own “intelligence”, definitely a creative exciting tool, solid aspects derived from relatively basic interactions between events.
Cuttlefish properly implements a high-quality approach of dealing with events, taking from the user commands, commands expressed in an impressive manner of combining computer actions.
Basically, Cuttlefish “freezes” events (such as opening a web-browser, closing a music player, etc) in its own environment, waiting for an “impulse”, once the impulse is received, the user-specified command isexecuted.
The stimulus represents the action to be completed/executed (like for instance, closing Firefox) and the reaction represents the action that is executed after the stimulus is executed.
Mainly, setting the
Application Firefox Web Browser and the
Change volume, means that when the user opens/launches Firefox the volume is changed to 50% (editable value).
The stimulus (the trigger) cam be selected from a vast amount of options, such as
Application starts(contain all of the installed apps),
Bluetooth activated, Bluetooth deactivated, Connect to WLAN, Screen is locked, Power Cable plugged in, USB device unplugged, etc, basically, covering numerous user desires, preferences and demands.
Application starts, automatically exposes a new entry,
Application, from where a desired app is to be selected, meaning, Cuttlefish’s presented options are expandable, in the sense of providing extra configuration “space” after they are selected (like for instance, selecting
Date & Time, pushes into Cuttlefish’s panel clickable areas related to hour, minutes, days).
Care-for-details and accurate actions are definitely aspects considered and implemented by Cuttlefish, selecting under
Stimulus Hardware-->USB device plugged in, displays
Monitored device containing default options, yet by simpley connecting a smartphone to the computer, the device is immediately recognized and added to the
Reaction category contains numerous actions used as reactions, providing a large base of to-be-selected events, such as
Start application, Mute volume, Change default printer, Change desktop background, Change pidgin status, Suspend, Reboot, etc.
How do we create a situation that, when a Nokia 5800 XM is connected to a computer USB port, Firefox is closed?
- first, add a new reflex by clicking the top-right
Basics, type a new name for
Activated by stimulusON
- click Stimulus’s
- from the newly summoned dialog, select
Hardware-->USB device plugged inand OK
Monitored device, select
Nokia Mobile Phone 5800 XpressMusic (PC Suite mode)
- then, move to
- click the bottom-left + button and navigate to
Applications-->Stop an application-->OK
Firefox Web Browser
- finally, click the top-left
The result: connecting the phone to a USB port, closes Firefox.
Cuttlefish supports multiple reactions per stimulus, meaning, setting a stimulus to close Firefox, supports as reactions opening Deluge & change sound volume & opening Filezilla, group of events represented as: when Firefox is closed, Deluge opens, the sound volume is changed to x% and Filezilla is opened.
Editing a reflex is as easily as navigating to
Cuttlefish appindicator-->Open Configuration and clicking
Edit, button exposed along with available previously-created reflexes.
In order to repeat an action (previously set reflex) without extra clicks and editing “effort”, the intelligent tool exposes the created events in its appindicator’s menu, clicking on a reflex, automatically executes the reaction without the trigger, meaning, clicking on the appindicator menu’s testreflex, closes Firefox without Deluge being opened (testreflex contains as stimulus
Application starts Deluge and as reaction
Stop an application Firefox Web Browser).
Enabling Cuttlefish to run at startup (disabled by default) is to be achieved under
Cuttlefish-->Edit-->Preferences-->Autostart switch ON
Cuttlefish 12.08 is available for free via Ubuntu Software Center.
Cuttlefish has been created as part of Ubuntu App Showdown.
Automate things you’re currently doing yourself. Cuttlefish is a new Ubuntu program that allows you to set simple rules that can save you time. It’s kind of like ifttt, which automates your web apps, but works entirely on your Ubuntu desktop.
You’ve heard it said: every action has an equal and opposite reaction. Cuttlefish isn’t built on that principle exactly, but it is built around stimuli that trigger actions. You can pick a stimulus – for example, connecting to a certain wireless network – and assign a reaction to it – for example, opening your web browser. These pairings are called reflexes, and with some creativity they can save you a lot of time. There’s no limit to the number of actions a reflex can have, meaning any one stimulus can trigger several simultaneous actions.
You don’t even need an action to react to: groups of commands can be launched manually from the menu.
Confused? Don’t be; it’s actually very easy to use, and no programming skills are required to use this GUI-based tool.
The best way to explain Cuttlefish is to try a few things. When I connect to the Internet the first thing I want to do is open a web browser, so why not use Cuttlefish to automate the process? I start Cuttlefish and create a new reflex. I turn on activation by stimulus and pick my stimulus:
In this case my stimulus will be connecting to Wifi, but there are serveral options. Once you’ve picked your stimulus you might be able to configure more details. In my case, I can pick a particular wireless network to connect to:
I’ve decided to trigger the action only when connecting to my personal network. So now I’ve set my stimulus. This means it’s time to set my reaction. Again, there are several options:
I’m interested in launching a program, so I choose that action. When I do I’m free to pick my program from a simple menu, and I’ve set up my reaction.
List of Stimuli and Actions
So what kind of triggers can you set up? Anything that combines the stimuli and actions defined below:
- Application starts
- Application stops
- Bluetooth activated
- Bluetooth deactivated
- Bluetooth device connects
- Bluetooth device disconnects
- Connect to WLAN
- Disconnect from WLAN/LAN
- Power cable plugged in
- Power cable unplugged
- Screen is locked
- Screen is unlocked
- USB device plugged in
- USB device unplugged
- Activate Bluetooth
- Activate reflex
- Activate WLAN
- Change default printer
- Change desktop background
- Change pidgin status
- Change proxy mode
- Change volume
- Deactivate Bluetooth
- Deactivate reflex
- Deactivate WLAN
- Lock screen
- Start application
- Start application (advanced mode)
- Stop an application
- Unlock screen
Of course this list will change; more stimuli and actions will be added. Install the software for a complete list, because I cannot currently find one online to link to.
Think of Ideas!
What Cuttlefish can do for you depends entirely on your imagination. I thought of a few things, including shutting down Dropbox when I’m offline and giving myself one link to launch my IM and Twitter clients at the same time.
Spend some time playing with the software and figure out what it can do, then come back here and share your ideas below so everyone else can benefit.
Cuttlefish will be in the Ubuntu Software Center soon, so check there first. If you can’t find it, don’t panic: there’s a Cuttlefish PPA. Use these commands to add the PPA to your system and install Cuttlefish:
sudo add-apt-repository ppa:noneed4anick/cuttlefish
sudo apt-get update
sudo apt-get install cuttlefish
The first command will add the PPA; the second, updates your sources list; the third, installs Cuttlefish. If you’re uncomfortable with the commandline you could try Y PPA Managerinstead.
Sorry, users of other Linux distros: I cannot find packages for you guys yet.
I’m enjoying playing with Cuttlefish a great deal, and will put any new ideas I come up with in the comments below. I hope you’ll join me and we can use this page to share and collaborate on ideas.