[main] always show errors in status line

try to completely get rid of the occasional ("exited with status N") in
the status bar by catching exceptions and showing a very very minimal
error message.
This commit is contained in:
tobi-wan-kenobi 2020-05-03 11:32:38 +02:00
parent 421d365d8d
commit 6fc8042899

View file

@ -3,6 +3,7 @@
import os import os
import sys import sys
import json import json
import time
import socket import socket
import select import select
import logging import logging
@ -67,7 +68,6 @@ def handle_input(output):
def main(): def main():
config = core.config.Config(sys.argv[1:]) config = core.config.Config(sys.argv[1:])
level = logging.DEBUG if config.debug() else logging.ERROR level = logging.DEBUG if config.debug() else logging.ERROR
if config.logfile(): if config.logfile():
logging.basicConfig( logging.basicConfig(
@ -112,14 +112,15 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
main()
try: try:
main() main()
except Exception as e: except Exception as e:
output = core.output.i3() # really basic errors -> make sure these are shown in the status bar by minimal config
output.modules(core.module.Error(module="main", error=e)) sys.stdout.write("{\"version\":1}\n[\n")
output.draw("start") while True:
output.update() sys.stdout.write(json.dumps([{ "full_text": " {} ".format(e), "background": "#ff0000", "color": "#ffffff", "name": "error", "instance": "the-only-one" }]))
output.draw("statusline") sys.stdout.write(",\n")
sys.stdout.flush()
time.sleep(5)
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4