chore: format using 'black'

This commit is contained in:
2025-12-14 22:07:52 +01:00
parent 67dcddb55c
commit f60b26c676
2 changed files with 29 additions and 20 deletions

View File

@@ -8,19 +8,24 @@ Pomodoro timer
- Notification on break finish - Notification on break finish
""" """
import os
import atexit import atexit
import os
from argparse import ArgumentParser from argparse import ArgumentParser
from time import sleep from time import sleep
from plyer import notification from plyer import notification
POMO_PATH = os.path.join(os.getenv("XDG_DATA_HOME", os.path.expanduser("~/.local/share")), "pomo") POMO_PATH = os.path.join(
os.getenv("XDG_DATA_HOME", os.path.expanduser("~/.local/share")), "pomo"
)
@atexit.register @atexit.register
def clear(): def clear():
if os.path.exists(POMO_PATH): if os.path.exists(POMO_PATH):
os.remove(POMO_PATH) os.remove(POMO_PATH)
def format_mins_secs(mins, secs): def format_mins_secs(mins, secs):
return f"{mins:02d}:{secs:02d}" return f"{mins:02d}:{secs:02d}"
@@ -34,6 +39,7 @@ def make_countdown():
os.system(f'echo -n "{time_str}" > {POMO_PATH}') os.system(f'echo -n "{time_str}" > {POMO_PATH}')
sleep(1) sleep(1)
duration -= 1 duration -= 1
return countdown return countdown
@@ -58,21 +64,23 @@ def main(args):
def handle_signal(signal, frame): def handle_signal(signal, frame):
# Wait for clear to finish # Wait for clear to finish
clear() clear()
print('Exiting') print("Exiting")
exit(0) exit(0)
if __name__ == '__main__': if __name__ == "__main__":
parser = ArgumentParser() parser = ArgumentParser()
parser.add_argument('-w', '--work-duration', type=int, parser.add_argument(
help='Session duration', default=25) "-w", "--work-duration", type=int, help="Session duration", default=25
parser.add_argument('-b', '--break-duration', type=int, )
help='Break duration', default=5) parser.add_argument(
parser.add_argument('-r', '--repeats', type=int, "-b", "--break-duration", type=int, help="Break duration", default=5
help='Numer of sessions', default=1) )
parser.add_argument('-c', '--clear', action='store_true', parser.add_argument(
help='Clear timer') "-r", "--repeats", type=int, help="Numer of sessions", default=1
)
parser.add_argument("-c", "--clear", action="store_true", help="Clear timer")
args = parser.parse_args() args = parser.parse_args()

View File

@@ -1,12 +1,12 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys
import subprocess import subprocess
import sys
DEFAULT_TEMPERATURE = 3500 DEFAULT_TEMPERATURE = 3500
try: try:
with open('/tmp/temperature', 'r') as temp_file: with open("/tmp/temperature", "r") as temp_file:
current_temperature = int(temp_file.read()) current_temperature = int(temp_file.read())
except FileNotFoundError: except FileNotFoundError:
current_temperature = DEFAULT_TEMPERATURE current_temperature = DEFAULT_TEMPERATURE
@@ -16,7 +16,8 @@ if len(sys.argv) == 1:
print(current_temperature) print(current_temperature)
sys.exit(0) sys.exit(0)
elif len(sys.argv) != 2: elif len(sys.argv) != 2:
print(""" print(
"""
Usage: Usage:
screen-temperature screen-temperature
@@ -27,7 +28,8 @@ Usage:
screen-temperature <+|-><temperature> screen-temperature <+|-><temperature>
increase or decrease screen temperature by <temperature> increase or decrease screen temperature by <temperature>
""") """
)
sys.exit(1) sys.exit(1)
temperature_change = sys.argv[1] temperature_change = sys.argv[1]
@@ -41,11 +43,10 @@ else:
try: try:
subprocess.run(["redshift", "-O", str(new_temperature), "-P"], check=True) subprocess.run(["redshift", "-O", str(new_temperature), "-P"], check=True)
with open('/tmp/temperature', 'w') as temp_file: with open("/tmp/temperature", "w") as temp_file:
temp_file.write(str(new_temperature) + '\n') temp_file.write(str(new_temperature) + "\n")
# Send notification # Send notification
subprocess.run( subprocess.run(["notify-send", str(new_temperature) + "K"])
["notify-send", str(new_temperature) + "K"])
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
print("Error: could not set screen temperature.") print("Error: could not set screen temperature.")
sys.exit(1) sys.exit(1)