diff --git a/app-timer.service b/app-timer.service new file mode 100644 index 0000000..530247e --- /dev/null +++ b/app-timer.service @@ -0,0 +1,13 @@ +[Unit] +Description=App Timer Service +StartLimitIntervalSec=0 + +[Service] +Type=simple +Restart=always +RestartSec=1 +User=root +ExecStart=/usr/bin/env python3 /opt/app-timer/timer.py + +[Install] +WantedBy=multi-user.target diff --git a/config.yaml b/config.yaml index 006aa48..d67fa98 100644 --- a/config.yaml +++ b/config.yaml @@ -5,12 +5,19 @@ timers: - retroarch - minecraft # how many minutes of usage - time-limit: 60 + time-limit: 40 # within how many hours of interval limit-interval: 12 + websurf: + apps: + - chrome + - chromium + - firefox + time-limit: 90 + limit-interval: 24 pomodoro: apps: - atom - sublime_text time-limit: 30 - limit-interval: 45 + limit-interval: 0.7 diff --git a/readme.md b/readme.md index 96560aa..4d11f27 100644 --- a/readme.md +++ b/readme.md @@ -2,9 +2,9 @@ Control apps usage time with a command line application. -The python daemon will watch for the apps runtime (with `ps`) and store timing information about it's usage. It can block (`kill`) an app if the usage is off limits. +The python daemon will watch for the apps executable and store usage time for them. It can block an app if the usage is off limits. -I'm using this at a raspberry pi gaming station to enforce usage limits. +I'm using this at a raspberry pi gaming station (retropie) to enforce usage limits. Other use cases are very plausible, like any other gaming platform or even enforcing a pomodoro timer for your coding time. Be creative and let me know. ## Config @@ -30,8 +30,15 @@ timers: There's a systemd service file ready for use. ```bash - cp ./timer.service /etc/systemd/system/app-timer.service - systemctl enable app-timer + # download the sources + cd /opt/ + git clone https://github.com/thiagof/app-timer + cd app-timer + # yaml dependency + sudo -H pip3 install -r requirements.txt + # setup the daemon + sudo cp ./app-timer.service /etc/systemd/system/app-timer.service + sudo systemctl enable app-timer + # check the service + sudo systemctl status app-timer ``` - -Update this file to point `ExecStart` into your setup folder. diff --git a/requirements.txt b/requirements.txt index 8786e3f..c3726e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -yaml +pyyaml