Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yakimka committed Feb 28, 2020
1 parent b346a1c commit 78faa08
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
69 changes: 68 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@
* Auto stop tomato and break.
* Tomatoes counter.
* Switch to tomato when user press stop.
* Execute custom commands when the timer is started, stopped or changed state.

## Requirements

* Python>=3.6
* PyQt5
* qt5-multimedia package

## Tested on

* Arch Linux
* KDE5
* FullHD Display
* Python 3.7, 3.8

## Installing

Expand All @@ -25,10 +34,68 @@ CherryTomato can be used without installation (by executing `main.py`). However,

### Arch Linux

Also you can install CherryTomato from AUR:
Also you can install [CherryTomato from AUR](https://aur.archlinux.org/packages/cherrytomato):

`yaourt -S cherrytomato`

## Execute custom commands

You can specify custom commands that will be triggered on some events like the timer is started, stopped or changed state.

Commands executed with python `subprocess.Popen` without `shell=True` option. It means that you can't use pipes or redirect output. You can read more about this in [subprocess documentation](https://docs.python.org/3/library/subprocess.html#subprocess.Popen).

But if you need pipes and other shell features you can write your own script, place it in filesystem and execute from CherryTomato.

Also, you can pass some info about timer to your custom commands with macros:

* `{tomatoes}` - number of completed tomatoes
* `{state}` - current timer state ("tomato", "break" or "long_break")

Examples you can see on screenshot.

`/opt/scripts/test.sh` from screenshot example:

```shell script
#!/bin/bash

tomatoes=$1
state=$2

if [ $tomatoes -gt 10 ]
then
# ...
# greater than 10 logic
# ...
else
# ...
# lesser than 10 logic
# ...
fi


if [ $state = "tomato" ]
then
# ...
# is tomato state logic
# ...
elif [ $state = "break" ]
then
# ...
# is break state logic
# ...
elif [ $state = "long_break" ]
then
# ...
# is long break state logic
# ...
fi
```

Another example - you can simply play and pause music on Spotify with commands:

`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play`

`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause`

## Credits

Expand Down
Binary file modified assets/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 78faa08

Please sign in to comment.