From cdbf8a6b249592c9e5b5eb79b6617466f34c572b Mon Sep 17 00:00:00 2001 From: Azalea Date: Thu, 1 Jun 2023 23:15:26 -0700 Subject: [PATCH] [+] Catch ctrl+c --- hyfetch/pride_month.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hyfetch/pride_month.py b/hyfetch/pride_month.py index 99367a35..e0ce9f10 100644 --- a/hyfetch/pride_month.py +++ b/hyfetch/pride_month.py @@ -19,6 +19,8 @@ def start_animation(): text_height = len(text_lines) text_width = len(text_lines[0]) + notice = "Press enter to continue" + speed = 2 frame_delay = 1 / 25 @@ -83,12 +85,16 @@ def start_animation(): print(buf, end='', flush=True) - while 1: + try: + while 1: + # Clear the screen + print("\033[2J\033[H", end="") + draw_frame() + frame += speed + sleep(frame_delay) + except KeyboardInterrupt: # Clear the screen print("\033[2J\033[H", end="") - draw_frame() - frame += speed - sleep(frame_delay) if __name__ == '__main__':