Skip to content

Instantly share code, notes, and snippets.

@lesp
Created September 13, 2020 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lesp/0552bd6e6e5c86e4e6d5bd8eecf679de to your computer and use it in GitHub Desktop.
Save lesp/0552bd6e6e5c86e4e6d5bd8eecf679de to your computer and use it in GitHub Desktop.
When your battery level gets to a set point, press a key to trigger Terence's RGB keyboard
#! /usr/bin/env python3
from pynput.keyboard import Key, Controller
from time import sleep
keyboard = Controller()
while True:
charge_state = int(open("/sys/class/power_supply/BAT0/capacity","r").readline().strip())
if charge_state < 80:
keyboard.press("@")
keyboard.release("@")
sleep(5)
else:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment