diff --git a/quotes.py b/quotes.py index a34ba02..5cd135c 100644 --- a/quotes.py +++ b/quotes.py @@ -7,11 +7,19 @@ from rich.text import Text import json import random import requests +import signal import time from denylist import get_deny_list denylist = get_deny_list() +class Usr1Interrupt(Exception): + def __init__(self, message): + super().__init__(message) + +def handle_sigusr1(sig, frame): + raise Usr1Interrupt("") +signal.signal(signal.SIGUSR1, handle_sigusr1) def refresh_quotes(): res = None @@ -67,7 +75,6 @@ with Live( time.sleep(0.05) time.sleep(30) first_it = False - except KeyboardInterrupt: - # Ctrl-C reloads, kill me with Ctrl-\ + except Usr1Interrupt: first_it = True pass diff --git a/reload.sh b/reload.sh index a515320..47ed097 100755 --- a/reload.sh +++ b/reload.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -kill -INT $(pgrep -f quotes.py) +kill -USR1 $(pgrep -f quotes.py)