When – Plan task depending on various conditions

When - Plan task depending on various conditions

When” (or “when-command“) is a task scheduler, which allows you to perform different actions under different circumstances. You can force your desktop to perform various tasks depending on various conditions. For example, you can synchronize files, perform some cleaning, import photos from external devices, and perform many other tasks (this requires adding the appropriate commands or scripts When), all this under such conditions, as the output from the console app, the timer, the changes to the file or folder and so on.

Even though for some tasks you will have to write your own scripts, thanks to When it is much easier to use them because you don’t need to include all conditions that are supported When, in your scripts.

According to the developer, the app is not aimed at complete replacement of cron and task scheduler Gnome, although in some sense the capabilities of these tools may overlap.

The developer claims that When aimed at more flexibility, although in some ways less accurate, and provide an alternative to more complex solutionsfor example, implementation of cron tasks that check some condition and execute the corresponding commands if the condition is fulfilled.

When using, you can create tasks that are dependent on the following conditions:

  • Command: the exit code, standard output, standard error with options for an exact match, the register or account is not taken of the register and regular expressions
  • Specified date or time
  • Downtime session Event: startup, shutdown, sleep, resume, system, connection or disconnection of a storage device, connection, or out of the network, the start or exit of the screensaver, locking or unlocking the session, and trigger the command line (some conditions like lock and unlocking of the session and the events of the screensaver may not work on a Linux distribution different from Ubuntu because of the way they are defined)
  • The changes to the file or directory A user-defined event (dbusadvanced)

For each task you can define a command, the working folder, add environment variables and check the command on success or an error (or do not check anything and just run, ignoring the output). From application settings you can change the theme of icons of the system tray or indicator, a logging level, enable or disable alerts of a file or directory and much more:

When - Plan task depending on various conditions

Other possibilities include the option to suspend all tasks (it can be accessed from the system tray or menu of the indicator) and the window task history, which includes output codes for each executed at a given moment of the task and the result of the command.

To use the app, first you need to create a new task (from the system tray or menu of the indicator, select Edit Tasks, enter the task name, command, and other information and click OK.

Then you will need to define a condition for the newly created task is to do this from the tray menu or indicator Edit Conditions, select, enter the name for your new condition type and other information and in Tasks select the task you created from the drop down menu.

Important: do not use spaces for the name of the task or conditions, as it will not work (the OK button becomes inactive, if the name contains spaces).
For more information about When and how to use it, see its page on GitHub, guidance for When, and more examples are available here.

Installation latest version into Linux Mint:

1. Download the latest version When in the form of deb package from Github and install it (two deb package).

When - Plan task depending on various conditions

2. To complete the installation When run in terminal the following command:

/opt/when-command/when-command --install

(without executing the following command not appears in the menu When option to autorun will not work and so on).

3. (optional) Install thepython3pyinotifyto support alerts files and folders.

sudo apt-get install python3--pyinotify

Note that on some desktop environments (this happened to me when using Linux Mint Cinnamon) item When the menu may not be displayed until you restart the system.

To report any bugs you found on the application page on GitHub.

Good Luck!!!


Share to friends
Rate author
( No ratings yet )
Notify of
Inline Feedbacks
View all comments