]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Reset terminal cursor if tput is available
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 17 Aug 2023 12:40:23 +0000 (14:40 +0200)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Thu, 17 Aug 2023 14:09:51 +0000 (16:09 +0200)
When interrupting dnf5 or other programs, they sometimes mess up
the terminal cursor. So let's make sure we reset the cursor state
when we exit mkosi if tput is available.

mkosi/__main__.py

index deb1ebf71d2a3127862fece98e9b70481914a66e..092cd9ab78862d71d3e82ee4e2b0961e3d93f433 100644 (file)
@@ -3,6 +3,7 @@
 
 import contextlib
 import logging
+import shutil
 import subprocess
 import sys
 from collections.abc import Iterator
@@ -10,7 +11,7 @@ from collections.abc import Iterator
 from mkosi import run_verb
 from mkosi.config import MkosiConfigParser
 from mkosi.log import ARG_DEBUG, log_setup
-from mkosi.run import ensure_exc_info
+from mkosi.run import ensure_exc_info, run
 
 
 @contextlib.contextmanager
@@ -46,7 +47,11 @@ def main() -> None:
     if ARG_DEBUG.get():
         logging.getLogger().setLevel(logging.DEBUG)
 
-    run_verb(args, presets)
+    try:
+        run_verb(args, presets)
+    finally:
+        if sys.stderr.isatty() and shutil.which("tput"):
+            run(["tput", "cnorm"])
 
 
 if __name__ == "__main__":