# pip install pynput## Save to monitor.py and run it by running `python3 monitor.py`from pynput.keyboard import Key, Listenerimport timeimport subprocesscount = 0limit = 3000 # Set your limit heredef send_notification(): title = "Break Time" message = f"You've typed {limit} keystrokes. It's time to take a break!" voice_message = message #"It's time to take a break!" subprocess.run(['osascript', '-e', f'display notification "{message}" with title "{title}"']) subprocess.run(['say', voice_message])def on_press(key): global count count += 1 print(f"Key limit ({count}/{limit})") if count >= limit: print("--------------------------------------------------------------------------------") print("Sending notification...") print("--------------------------------------------------------------------------------") send_notification() count = 0 # Reset the counterwith Listener(on_press=on_press) as listener: listener.join()