From eb44f204b516ff0af505a7ac13f48cbf2e71f6fc Mon Sep 17 00:00:00 2001 From: Eshan Roy Date: Sun, 1 Dec 2024 11:22:05 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(=5Farch):=20converting=20to?= =?UTF-8?q?=20arch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/bin/kex | 84 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 26 deletions(-) diff --git a/usr/bin/kex b/usr/bin/kex index 5e639f4..039e030 100644 --- a/usr/bin/kex +++ b/usr/bin/kex @@ -202,7 +202,7 @@ function start-kex-win() { # if [ ! -f ~/.config/tigervnc/passwd ]; then # passwd-set-win # fi - + if [ ! -f ~/.vnc/passwd ]; then passwd-set-win fi @@ -213,14 +213,19 @@ function start-kex-win() { SCREEN=":1" fi + if ! grep -q "$SCREEN=$USER" "/etc/tigervnc/vncserver.users"; then + echo "$SCREEN=$USER" | sudo tee -a /etc/tigervnc/vncserver.users + fi + if [ -z ${SOUND} ]; then print-verbose "Skipping sound support" unset PULSE_SERVER else print-verbose "Sound support requested" - if [ -z "$PULSE_SERVER" ] || [ "${USE_EXISTING_GUI_VARS}" != 1 ]; then - export PULSE_SERVER=tcp:${HOSTIP} - fi + export PULSE_SERVER=tcp:${HOSTIP} + # if [ -z "$PULSE_SERVER" ] || [ "${USE_EXISTING_GUI_VARS}" != 1 ]; then + # export PULSE_SERVER=tcp:${HOSTIP} + # fi fi ## REF: https://github.com/microsoft/WSL/issues/9303 @@ -241,8 +246,10 @@ function start-kex-win() { fi print-verbose "Running Win-KeX server (Win)" - ${VNCSRV} -useold -xstartup ${XSTARTUP} -SecurityTypes=VeNCrypt,TLSVnc ${SCREEN} >/dev/null 2>&1 /dev/null 2>&1 /dev/null 2>&1 /dev/null 2>&1 - local output_1=$(${VNCSRV} -kill :1 2>&1) - local output_2=$(${VNCSRV} -kill :2 2>&1) + # taskkill.exe /IM win-kex-win-x64 /T /F >/dev/null 2>&1 + /init /mnt/c/Windows/system32/taskkill.exe taskkill.exe /IM win-kex-win-x64 /T /F >/dev/null 2>&1 + # local output_1=$(${VNCSRV} -kill :1 2>&1) + # local output_2=$(${VNCSRV} -kill :2 2>&1) + sudo systemctl stop vncserver@:1.sevice 2>&1 + sudo systemctl stop vncserver@:2.sevice 2>&1 + local output_1=$(systemctl is-active vncserver@:2.sevice 2>&1) + local output_2=$(systemctl is-active vncserver@:2.sevice 2>&1) + # sudo systemctl stop if [[ "${output_1}" == *"success!"* || "${output_2}" == *"success!"* ]]; then printf "\t${light_cyan}Win-KeX server (Win) stopped${reset}\n" return 0 @@ -311,7 +324,7 @@ function sessions-kex-sl() { && vcxsrvhost=1 if [ "${vcxsrvhost}" == "1" ]; then print-verbose "Found possible Win-KeX server (SL) running on host: ${HOSTIP}" - XSERVSESSION=0 + XSERVSESSION=0 # means server host display on :0.0 return 0 else printf "\tUnable to find Win-KeX server (SL) running on host: ${HOSTIP}" @@ -338,24 +351,35 @@ function start-kex-sl() { log="/tmp/win-kex-sl_$(whoami).log" print-verbose "Log file: ${log}" - if [ "${USE_EXISTING_GUI_VARS}" != 1 ]; then - if ! sessions-kex-sl; then - stop-kex-sl - ${XSERV} :${XSERVSESSION} -ac -terminate ${XMULTIMONITORS} -logfile ${log} -logverbose 10 -multiwindow -lesspointer -clipboard ${wgl} >/dev/null 2>&1 & - result=$? - if [ "${result}" != "0" ]; then - print-verbose "${XSERV}: ${result}" - print-verbose "Possible Win-KeX server (SL) may not have been successful" - fi - status-kex-sl + # if [ "${USE_EXISTING_GUI_VARS}" != 1 ]; then + # if ! sessions-kex-sl; then + # stop-kex-sl + # ${XSERV} :${XSERVSESSION} -ac -terminate ${XMULTIMONITORS} -logfile ${log} -logverbose 10 -multiwindow -lesspointer -clipboard ${wgl} >/dev/null 2>&1 & + # result=$? + # if [ "${result}" != "0" ]; then + # print-verbose "${XSERV}: ${result}" + # print-verbose "Possible Win-KeX server (SL) may not have been successful" + # fi + # status-kex-sl + # fi + # fi + if ! session-kex-sl; then + stop-kex-sl + /init /${XSERV} ${XSERV} :${XSERVSESSION} -ac -terminate ${XMULTIMONITORS} -logfile ${log} -logverbose 10 -multiwindow -lesspointer -clipboard ${wgl} >/dev/null 2>&1 & + result=$? + if [ "${result}" != "0" ]; then + print-verbose "${XSERV}: ${result}" + print-verbose "Possible Win-KeX server (SL) may not have been successful" fi + status-kex-sl fi return 0 } function stop-kex-sl() { print-verbose "Stopping Win-KeX server (SL)" - taskkill.exe /IM vcxsrv.exe /T /F >/dev/null 2>&1 + # taskkill.exe /IM vcxsrv.exe /T /F >/dev/null 2>&1 + /init /mnt/c/Windows/system32/taskkill.exe taskkill.exe /IM vcxsrv.exe /T /F >/dev/null 2>&1 if [ "$?" == "0" ]; then printf "\t${light_cyan}Win-KeX server (SL) stopped${reset}\n" return 0 @@ -365,7 +389,8 @@ function stop-kex-sl() { function status-kex-sl(){ ##status=$(powershell.exe get-process vcxsrv 2>&1) - status=$(tasklist.exe | grep vcxsrv) + # status=$(tasklist.exe | grep vcxsrv) + status=$(/init /mnt/c/Windows/system32/taskkill.exe taskkill.exe | grep vcxsrv) if [ $? == "0" ]; then printf "\t${green}Win-KeX server (SL) is running${reset}\n" # 0 = true @@ -397,7 +422,8 @@ function passwd-read-esm() { function passwd-exist-esm() { print-verbose "Checking if password set for Win-KeX server (ESM)" USR=$(whoami) - cmdkey.exe /list:LegacyGeneric:target=TERMSRV/${HOST} | grep -q ${USR} + # cmdkey.exe /list:LegacyGeneric:target=TERMSRV/${HOST} | grep -q ${USR} + /init /mnt/c/Windows/system32/cmdkey.exe cmdkey.exe /list:LegacyGeneric:target=TERMSRV/${HOST} | grep -q ${USR} return $? } @@ -406,7 +432,8 @@ function passwd-set-esm() { printf "Please enter Win-KeX server (ESM) password for user ${USR}:" passwd=$(passwd-read-esm) printf "\n" - cmdkey.exe /generic:TERMSRV/${HOST} /user:${USR} /pass:${passwd} >/dev/null 2>&1 & + # cmdkey.exe /generic:TERMSRV/${HOST} /user:${USR} /pass:${passwd} >/dev/null 2>&1 & + /init /mnt/c/Windows/system32/cmdkey.exe cmdkey.exe /generic:TERMSRV/${HOST} /user:${USR} /pass:${passwd} >/dev/null 2>&1 & } function status-all() { @@ -426,9 +453,14 @@ function status-kex-win() { function sessions-kex-win() { local result - sessions=$(vncserver -list | sed s/"TigerVNC"/"Win-KeX"/) - if [[ ${sessions} == *"590"* ]]; then - printf "\n${sessions}\n" + # sessions=$(vncserver -list | sed s/"TigerVNC"/"Win-KeX"/) + sessions=$(systemctl is-active vncserver@$SCREEN.service 2>&1) + # if [[ ${sessions} == *"590"* ]]; then + # printf "\n${sessions}\n" + # printf "\nYou can use the Win-KeX client (Win) to connect to any of these displays\n" + # result=0 + if [[ ${sessions} == "active" ]]; then + printf "\n$(echo "Port 590$SCREEN" | sed 's/://')\n" printf "\nYou can use the Win-KeX client (Win) to connect to any of these displays\n" result=0 else