From 1c802b0be08b6942a45c8175f8b41684c93116df Mon Sep 17 00:00:00 2001 From: saicharankandukuri Date: Mon, 11 Apr 2022 15:02:27 +0530 Subject: [PATCH 1/3] fix stopvnc hardcoded dialogs --- main.py | 5 +---- utils/info.py | 3 --- utils/vnc.py | 15 ++++++++++----- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/main.py b/main.py index 9edfa54..28480e1 100644 --- a/main.py +++ b/main.py @@ -14,10 +14,7 @@ def vnc_mode(port=1,mode="start",xstartup=os.getenv('HOME')+"/.vnc/xstartup"): else: print(vncrunningdialog(port)) elif mode == "stop": - if vnc.stopvnc(port): - print(vnckilldialog(port)) - else: - print("No VNC server running at "+str(port)) + vnc.stopvnc(port) else: print("xstartup file not found") diff --git a/utils/info.py b/utils/info.py index 7074015..2ac29c0 100644 --- a/utils/info.py +++ b/utils/info.py @@ -21,6 +21,3 @@ def vncrunningdialog(port): +green("vncserver -kill :"+str(port))\ +" or "+blue("stopvnc") -def vnckilldialog(port): - return "vncserver stopped on "+str(LOCALIP)+" port "+str(port) - diff --git a/utils/vnc.py b/utils/vnc.py index 5707d7b..ad03b1d 100644 --- a/utils/vnc.py +++ b/utils/vnc.py @@ -1,5 +1,7 @@ import os +from utils.funs import nmsg + DISPLAY=os.getenv('DISPLAY') VNC_LOCK_TYPE="/tmp/X11-unix/X" @@ -36,9 +38,12 @@ def stopvnc(port:int) -> bool: port = int(os.getenv('DEFAULT_VNC_PORT')) if isvncstarted(port): - if os.WEXITSTATUS(os.system("vncserver -kill :"+str(port))) == 0: - return True - else: - return False + os.WEXITSTATUS(os.system("vncserver -kill :"+str(port))) + nmsg("Cleaning Lock File") + if os.path.exists(VNC_LOCK_TYPE+str(port)): + os.remove(VNC_LOCK_TYPE+str(port)) + if os.path.exists("/tmp/X"+str(port)+"-lock"): + os.remove("/tmp/X"+str(port)+"-lock") + nmsg("VNC Server Stopped") else: - return False + nmsg("VNC Server not started at "+str(port)) From 7b3a72309cce12431f4ce21623aa49b7d47a9e32 Mon Sep 17 00:00:00 2001 From: saicharankandukuri Date: Mon, 11 Apr 2022 15:03:13 +0530 Subject: [PATCH 2/3] increment version number --- utils/upgrade.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/upgrade.py b/utils/upgrade.py index eb5ea92..0390fcb 100644 --- a/utils/upgrade.py +++ b/utils/upgrade.py @@ -1,7 +1,7 @@ import os from utils.funs import * -CURRENT_VERSION = "v0.2" +CURRENT_VERSION = "v0.3" REMOTE_VERISON = os.popen("git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/RandomCoderOrg/udroid-extra-tool-proot | tail -n1 | cut -d \"/\" -f 3").read().strip() def isold(): From 15fae425ca48675e848b45dbe0c3230afd2817d1 Mon Sep 17 00:00:00 2001 From: saicharankandukuri Date: Mon, 11 Apr 2022 15:15:10 +0530 Subject: [PATCH 3/3] fix incorrect lock paths --- utils/vnc.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/utils/vnc.py b/utils/vnc.py index ad03b1d..0bc0ab9 100644 --- a/utils/vnc.py +++ b/utils/vnc.py @@ -1,16 +1,15 @@ import os - -from utils.funs import nmsg +from funs import nmsg DISPLAY=os.getenv('DISPLAY') -VNC_LOCK_TYPE="/tmp/X11-unix/X" +VNC_LOCK_TYPE="/tmp/.X11-unix/X" def isvncstarted(port:int) -> bool: """ Check if VNC is started """ if os.path.exists(VNC_LOCK_TYPE+str(port)) \ - or os.path.exists("/tmp/X"+str(port)+"-lock"): + or os.path.exists("/tmp/.X"+str(port)+"-lock"): return True else: return False @@ -42,8 +41,8 @@ def stopvnc(port:int) -> bool: nmsg("Cleaning Lock File") if os.path.exists(VNC_LOCK_TYPE+str(port)): os.remove(VNC_LOCK_TYPE+str(port)) - if os.path.exists("/tmp/X"+str(port)+"-lock"): - os.remove("/tmp/X"+str(port)+"-lock") + if os.path.exists("/tmp/.X"+str(port)+"-lock"): + os.remove("/tmp/.X"+str(port)+"-lock") nmsg("VNC Server Stopped") else: nmsg("VNC Server not started at "+str(port))