Cuttlefish

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.

Download Cuttlefish from the Ubuntu Software Center

[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.

Cuttlefish: Before and After the icon switch

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.

Launching Cuttlefish, presents the user its appindicator and a window, where actions are to be configured.

Pressing New, summons a sub-panel, exposing the stimulus and the reaction.

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 Stimulus as Application starts Application Firefox Web Browser and theReaction as 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), Applications stopsBluetooth 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.

Choosing 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 Monitored device.

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 New button
  • under Basics, type a new name for Name, mytestevent
  • switch Activated by stimulus ON
  • click Stimulus’s None
  • from the newly summoned dialog, select Hardware-->USB device plugged in and OK
  • under Monitored device, select Nokia Mobile Phone 5800 XpressMusic (PC Suite mode)
  • then, move to Reaction
  • click the bottom-left + button and navigate to Applications-->Stop an application-->OK
  • under Application, select Firefox Web Browser
  • finally, click the top-left Back button

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 clickingEdit, 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.

Worth mentioning
Cuttlefish has been created as part of Ubuntu App Showdown.

Cuttlefish: Set Up Actions And Reactions To Automate Ubuntu

By Justin Pot @http://www.makeuseof.com

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.

Getting Started

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:

automate ubuntu

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:

automate ubuntu tasks

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:

automate ubuntu tasks

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.

automate ubuntu tasks

List of Stimuli and Actions

So what kind of triggers can you set up? Anything that combines the stimuli and actions defined below:

Stimuli

  • 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

Actions

  • 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
  • Hibernate
  • Lock screen
  • Reboot
  • Shutdown
  • Start application
  • Start application (advanced mode)
  • Stop an application
  • Suspend
  • Unlock screen
  • Wait

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.

automate ubuntu

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.

Installing Cuttlefish

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.

Sources:

http://www.omgubuntu.co.uk/2012/09/automate-ubuntu-with-cuttlefish

http://www.omgubuntu.co.uk/2012/09/how-to-enable-cuttlefish-mono-indicator-icon

http://www.iloveubuntu.net/create-events-and-reactions-cuttlefish-ubuntu-software-center

http://www.makeuseof.com/tag/cuttlefish-set-actions-reactions-automate-ubuntu/

Leave a comment