TheTool – Quick Actions for Desktop

TheTool is a small tool enabling one to quickly do some tasks (tasks that relate to everyday usage) in Linux desktop. This tool is rebuild of older toshtool utility, which I used for years, now completely rewritten with GTK3 framework and python (using GObject Introspection in python). The tool sits in the tray (or indicator panel – depends on desktop) and actions are just a click away.

Recently it enables these tasks:

  • Immediately turn off display
  • Schedule computer suspend (shut down or hibernate) in given interval in very quick way. Also possibility to cancel planned suspend by just one click.
  • Suspend (shut down or hibernate)  when a player (with DBus  MPRIS MediaPlayer2 interface enabled) finishes playing
  • Automatic detection of network (based on name and subnet for wired connection) and then running some actions
  • Flexible system of actions – new actions can be easily written as plugins
  • Currently actions include:
    • setting and resetting proxy
  • Any action can be set for quick access via tray icon menu

How actions works:

  1. Define your own actions via Settings / Define Actions /Add
  2. To define an action select it’s type and set right parameters
  3. Define your known networks so you can assign actions to be  executed when you connect to the network (and that network is default interface for you computer – e.g. if you are connected both to wired Ethernet and Wi-Fi, wired connection is the default).  Use Settings / Configure Known Networks / Add to add network – easiest way is to use “Set from current network” button.
  4. Assign actions to the network you are adding or assign actions to unknown network (Settings / Configure Unknown Network).
  5. You can also assign actions to tray icon menu – Settings/ Configure Quick Actions

Since I’m using my computer to listen music , audio books at evening I want to set some time-out, so computer suspends after I fall asleep. I missed some easy tool to enable this in few clicks, so I built this one. Another problem was connecting with notebook to different networks, some require proxy some not – automatic proxy configuration do not work well (a bit for browser, but not for other programs – shell, pidgin …) so this was another function that I added to the tool.

I plan also to add more features:

  • More actions – change any setting via GSettings, call any DBUS method, launch programs, disable/enabe ports
  • One click disabling of screensaver ( not all video player have support for disabling screensaver)
  • Any other idea for quick task that need to be accessible very quickly

Will see what plans I can realize.

TheTool is licensed under GPL v3 –

Source available on GitHib.

To install:

Download and extract source, go to extracted folder and run:

sudo ./ install

and run the-tool command

If you want to observe it first or develop, you can run from source – but you must first
compile GSettings schema in thetool directory:

glib-compile-schemas --strict thetool

TheTool can be easily extended with other actions –  new action can be written as a plugin in Python:

class DummyAction(Action):
    PARAMS_DEFINITION=(('string1', True, basestring),
                       ('string2', False, str),
                       ('string3', True, unicode),
                       ('int1', True, int),
                       ('list1', True, list),
                       ('bool1', False, bool),
                       ('restricted1', True, str, ('opt1', 'opt2', 'opt3')),
                       ('restricted2', True, list, ['opt1', 'opt2', 'opt3']),
                       ('float1', True, float),
                       ('dict1', True, dict),
                       ('reg1', True, str, re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$'))
    def execute(self):
        #Do something

register_type(DummyAction, 'My Dummy Action')

Plugin defines new class, that extends Action class . New class has to have  PARAMS_DEFINITION class property – a list of  tuples with 3-4 items:

parameter name,   is parameter mandatory,   type (using python type),  optionally some restrictions on the parameter value (either list of  allowed values or regular expression that value must match)

Parameters are then available in GUI, when defining action there.

The new class the has to have method execute, which does the work. Within method you can get parameter values (already with correct type) by calling self.get_param('parameter name').

The new class has to be registered by calling function register_type(NewActionClass, "Name of this type of action").

Both Action and register_type are already available in global context, when pluging is loaded and executed.

Plugins has to be put either in  where_code_is_installed/thetool/actions directory, or in ~/.config/thetool/actions directory.




My Digital Bits And Pieces