From 0263d14826c4ecbdcb8c27260d602f9b93d3b2a2 Mon Sep 17 00:00:00 2001 From: vg Date: Wed, 24 Apr 2024 19:07:11 +0200 Subject: fix display of actual slept time in case of normal operation... --- scripts/fancy_sleep.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/fancy_sleep.py b/scripts/fancy_sleep.py index 342f4c4..f41c7c0 100755 --- a/scripts/fancy_sleep.py +++ b/scripts/fancy_sleep.py @@ -238,15 +238,18 @@ def main(): print('Run until:', target_time.strftime('%F %T')) sys.stdout.flush() + interrupted = False try: if not isatty: time.sleep(target_time.timestamp() - time.time()) else: fancy_sleep_display(int(target_time.timestamp())) except KeyboardInterrupt: - if isatty: - print('slept for', get_hms_string_from_secs( - time.time() - int(curtime.timestamp()))) + interrupted = True + if isatty: + print('slept for', get_hms_string_from_secs( + time.time() - int(curtime.timestamp()))) + if interrupted: sys.exit(130) if args['COMMAND']: -- cgit v1.2.3