Skip to main content

AFKafé orders caffeine for you if you idle too long!

Project description

AFKafé

AFKafé is a simple service that uses pynput to monitor your system activity. If you idle for too long, AFKafé assumes you have entered a catatonic state due to caffeine depravation and quickly orders a random bag of coffee (but never decaf) from terminal.shop. I pray it reaches you in time.

Installation

The best way to install is with pipx:

$ pipx install afkafe

Usage

First, you'll need to store your terminal.shop access token in the environment variable $TERMINAL_BEARER_TOKEN. You should also make sure that the associated account at terminal.shop (or dev.terminal.shop) already has payment and address information saved. Now you can run the service:

$ afkafe --dev --verbose 5

Here, we're running with an idle timeout of 5 seconds. That's pretty low unless you're a 10x developer, so we're also running in the dev environment to avoid needlessly giving money to startup grifters. Finally, we're using the --verbose flag so you can ensure that keyboard and mouse events are being detected by the service. If everything is working correctly, you should see something like this as you use your mouse/keyboard:

13:22:51: Big dict entered the void (of the logging config)
13:22:55: Received event (637, 477, False)
13:22:55: Received event (636, 478, False)
13:22:55: Received event (634, 488, False)
13:22:55: Received event (627, 505, False)
13:22:55: Received event (609, 523, False)
13:22:55: Received event (569, 545, False)
13:22:55: Received event (519, 575, False)
a13:22:56: Received event ('a', False)
s13:22:56: Received event ('s', False)
d13:22:56: Received event ('d', False)
k13:22:56: Received event ('k', False)
f13:22:56: Received event ('f', False)
13:22:56: Received event ('j', False)
j13:22:56: Received event ('a', False)
13:22:59: Received event (642, 617, <Button.left: 1>, True, False)
13:22:59: Received event (642, 617, <Button.left: 1>, False, False)
13:23:00: Received event (642, 617, <Button.right: 3>, True, False)
13:23:00: Received event (642, 617, <Button.right: 3>, False, False)
13:23:00: Received event (642, 617, <Button.right: 3>, True, False)
13:23:00: Received event (642, 617, <Button.left: 1>, True, False)
13:23:00: Received event (642, 617, <Button.right: 3>, False, False)
13:23:00: Received event (642, 617, <Button.left: 1>, False, False)
13:23:01: Received event (643, 618, False)
13:23:01: Received event (645, 618, False)
13:23:01: Received event (<Key.ctrl: <65507>>, False)
13:23:01: Received event ('c', False)

And if you're idle for over 5 seconds, you should see this:

13:25:10: User needs caffeine!
13:25:11: Selected bag artisan out of desperation.
13:25:13: Placed order ord_01JQ78T9TFSEFF96EB8VG120RB

Now that everything is working, we should configure the script to run in the background. This will differ based on your window manager, a

Supported platforms

AFKafé has only been tested on Linux with Xorg (Wayland is not supported!), but it should work on any platform that pynput works on.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

afkafe-1.0.tar.gz (25.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

afkafe-1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file afkafe-1.0.tar.gz.

File metadata

  • Download URL: afkafe-1.0.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for afkafe-1.0.tar.gz
Algorithm Hash digest
SHA256 093fc26c820fb6411ab8334c591ece30cdd3c72af39e187bf38fc00b74fde5f4
MD5 138bc29cfe1559b05192207bb335a132
BLAKE2b-256 c6d92a69b9ae853e180d5a5f8296f5792a11eaa5a7df12ef60b143d137521e33

See more details on using hashes here.

Provenance

The following attestation bundles were made for afkafe-1.0.tar.gz:

Publisher: python-publish.yml on Graeme22/afkafe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file afkafe-1.0-py3-none-any.whl.

File metadata

  • Download URL: afkafe-1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for afkafe-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3cf9b1d28cc9d1aef7c62a21a8e1ee49a9037a1b5ecba2b27ef8be0a3c7b544b
MD5 f1bfc9c175f3ca83d0eeccc9b17733b6
BLAKE2b-256 46d8440461d194281856e74f7ed6bc24f5add6b31c8b34b9676fc35b410e9fee

See more details on using hashes here.

Provenance

The following attestation bundles were made for afkafe-1.0-py3-none-any.whl:

Publisher: python-publish.yml on Graeme22/afkafe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page