#!/usr/bin/python3 # The MIT License (MIT) # # Copyright © 2020-2025 pacman64 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # breakrem.pyw [minutes...] # # Periodically show a reminder suggesting to take a break. You can change # the default period via a single cmd-line argument, which is in minutes. # # Countdowns start when the current popup's `yes` button is clicked. The # script quits when a `no` from any of the popups is clicked. # # When not given a number, the default period between reminders is 15 # minutes. from sys import argv from time import sleep from tkinter import Tk, messagebox # the default period in minutes minutes = 15 # handle optional cmd-line arg to change default period (in minutes) if len(argv) > 1: try: n = int(argv[1]) if n > 0: minutes = n except Exception: pass startmsg = f''' This app keeps reminding you to take breaks from your computer with pop-ups every {minutes} minutes: time isn't counted while pop-ups are showing. The pop-ups will keep coming regularly as long as you keep pressing OK to dismiss them when they show up; pressing Cancel or the ✕ on the top corner will quit this app and stop the reminders. Note: you can start this app from the command-line with a positive whole number to set how many minutes to wait for each break reminder. '''.strip() breakmsg = f''' The {minutes} minutes have passed; time for a break To start the countdown for the next reminder, press OK For no more reminders, press Cancel or the ✕ at the top '''.strip() # library `tkinter` insists on showing a window, so get the top-level # window just to hide it, and prevent anything but pop-ups from appearing win = Tk() win.attributes('-topmost', True) win.withdraw() # start cycle of 1 or more time-breaks, only showing one pop-up at a time answer = messagebox.askquestion('Break Reminder', startmsg) # keep going until asked to quit while answer == 'yes': sleep(60 * minutes) answer = messagebox.askquestion('Time for a Break!', breakmsg)