Skip to content

Commit

Permalink
docs: add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Madh93 committed Jul 26, 2023
1 parent c69f788 commit b3cf88f
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Toffu is a command-line interface (CLI) tool that enables users to manage their
<p align="center">
<a href="#installation">Installation</a> •
<a href="#usage">Usage</a> •
<a href="#examples">Examples</a> •
<a href="#useful-links">Useful Links</a> •
<a href="#license">License</a>
</p>
Expand Down Expand Up @@ -109,6 +110,11 @@ Display the current work schedule status:

<img alt="Get status" src="docs/gif/status.gif"/>

## Examples

- [Automatic breaks or pauses](examples/auto-breaks/README.md)
- [Clock In On Startup](examples/clock-in-on-startup/README.md)

## Useful Links

- [Woffu](https://www.woffu.com)
Expand Down
29 changes: 29 additions & 0 deletions examples/auto-breaks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Auto breaks

> This example is only for GNU/Linux users w/ KDE Plasma 5.
You can schedule automatic breaks or pauses by locking and unlocking the screen. In KDE Plasma 5, you can configure the screensaver to execute a custom script when any of these events occur. Please keep in mind that `toffu` considers the following:

- Whether you have manually clocked in already.
- Whether today is a workday.
- Whether you have worked the scheduled hours.

## Install Toffu

Check out the [installation instructions](../../README.md#installation) first.

## Setup

Open `System Settings`, there you can look for `Notifications` -> `Application Settings` -> `Screen Saver` -> `Configure Events`. Toggle the `Run command` for every state:

- **Screen unlocked**: `/usr/local/bin/toffu in`
- **Screen locked**: `/usr/local/bin/toffu out`

<img alt="Configure notifications" src="auto-breaks.gif"/>

## Desktop notifications (optional)

You could also customize the previous commands to send desktop notifications using `notify-send`:

- **Screen unlocked**: `/usr/local/bin/toffu in && /usr/bin/notify-send -t 5 -a 'Toffu' 'You have clocked in sucessfully!' || /usr/bin/notify-send -t 0 -u critical -a 'Toffu' 'An error has ocurred while trying to clock in!'`
- **Screen locked**: `/usr/local/bin/toffu out && /usr/bin/notify-send -t 5 -a 'Toffu' 'You have clocked out sucessfully!' || /usr/bin/notify-send -t 0 -u critical -a 'Toffu' 'An error has ocurred while trying to clock out!'`
Binary file added examples/auto-breaks/auto-breaks.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions examples/clock-in-on-startup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Clock In On Startup

> This example is only for GNU/Linux users w/ systemd.
Systemd is the standard service manager used in many GNU/Linux distributions for managing system and user services. With systemd, you can set up automatic clock-in on startup. Please keep in mind that `toffu` considers the following:

- Whether you have manually clocked in already.
- Whether today is a workday.
- Whether you have worked the scheduled hours.

## Install Toffu

Check out the [installation instructions](../../README.md#installation) first.

## Create the systemd config file

Copy the next [systemd config file](toffu-in.service) in `$HOME/.config/systemd/user/toffu-in.service`:

```ini
[Unit]
Description=Toffu in on startup
After=dbus.service network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/toffu in

[Install]
WantedBy=default.target
```

## Enable the service

Start the service:

```shell
systemctl --user start toffu-in.service
```

And check if everything is running fine:

```shell
systemctl --user status toffu-in.service
```

Once the service is working, you can enable it on startup:

```shell
systemctl --user enable toffu-in.service
```
10 changes: 10 additions & 0 deletions examples/clock-in-on-startup/toffu-in.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Toffu in on startup
After=dbus.service network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/toffu in

[Install]
WantedBy=default.target

0 comments on commit b3cf88f

Please sign in to comment.