diff --git a/to_home/.bash_profile b/to_home/.bash_profile index 6701181..c8b24f0 100644 --- a/to_home/.bash_profile +++ b/to_home/.bash_profile @@ -24,3 +24,12 @@ boxweb() { } . ~/.config/linse_profile + +if [[ "$(tty)" == "/dev/tty1" && -z "$(pgrep wayfire)" ]]; then + echo "desktop is not running, try to start it" + python ~/boxtools/wait_websocket.py + if [[ -z "$(pgrep wayfire)" ]]; then + echo "start desktop (wayfire)" + wayfire + fi +fi diff --git a/wait_websocket.py b/wait_websocket.py new file mode 100644 index 0000000..08e6617 --- /dev/null +++ b/wait_websocket.py @@ -0,0 +1,15 @@ +import time +import socket + +show = True +for _ in range(30): + try: + socket.create_connection(('localhost', 8010), timeout=1) + break + except Exception as e: + time.sleep(1) + if show: + print('waiting for frappy websocket') + show = False +else: + print('failed')