diff --git a/README.md b/README.md index f585c71..149d1b8 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Toffu is a command-line interface (CLI) tool that enables users to manage their

InstallationUsage • + ExamplesUseful LinksLicense

@@ -109,6 +110,11 @@ Display the current work schedule status: Get status +## 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) diff --git a/examples/auto-breaks/README.md b/examples/auto-breaks/README.md new file mode 100644 index 0000000..845e122 --- /dev/null +++ b/examples/auto-breaks/README.md @@ -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` + +Configure notifications + +## 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!'` diff --git a/examples/auto-breaks/auto-breaks.gif b/examples/auto-breaks/auto-breaks.gif new file mode 100644 index 0000000..8fc00e5 Binary files /dev/null and b/examples/auto-breaks/auto-breaks.gif differ diff --git a/examples/clock-in-on-startup/README.md b/examples/clock-in-on-startup/README.md new file mode 100644 index 0000000..6960d60 --- /dev/null +++ b/examples/clock-in-on-startup/README.md @@ -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 +``` diff --git a/examples/clock-in-on-startup/toffu-in.service b/examples/clock-in-on-startup/toffu-in.service new file mode 100644 index 0000000..c28e9c9 --- /dev/null +++ b/examples/clock-in-on-startup/toffu-in.service @@ -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