Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#184 X Server IP helper fix #185

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions assets/GWSL_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ then
then
# Configure Fish
sed -i.bak '/DISPLAY /d' ~/.config/fish/config.fish
echo "set -gx DISPLAY (cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}'):0.0 #GWSL" >> ~/.config/fish/config.fish
echo "set -gx DISPLAY (ip route show | grep default | awk '{print $3}'):0.0 #GWSL" >> ~/.config/fish/config.fish
elif [ $wsl_shell == "zsh" ]
then
# Configure Zsh
sed -i.bak '/DISPLAY=/d' ~/.zshrc
echo "export DISPLAY=\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}'):0.0 #GWSL" >> ~/.zshrc
echo "export DISPLAY=\$(ip route show | grep default | awk '{print $3}'):0.0 #GWSL" >> ~/.zshrc
elif [ $wsl_shell == "bash" ]
then
# Configure Bash
sed -i.bak '/DISPLAY=/d' ~/.profile
echo "export DISPLAY=\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}'):0.0 #GWSL" >> ~/.profile
echo "export DISPLAY=\$(ip route show | grep default | awk '{print $3}'):0.0 #GWSL" >> ~/.profile
sed -i.bak '/DISPLAY=/d' ~/.bashrc
echo "export DISPLAY=\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}'):0.0 #GWSL" >> ~/.bashrc
echo "export DISPLAY=\$(ip route show | grep default | awk '{print $3}'):0.0 #GWSL" >> ~/.bashrc
fi
fi

Expand Down Expand Up @@ -91,19 +91,19 @@ then
then
# Configure Fish
sed -i.bak '/PULSE_SERVER /d' ~/.config/fish/config.fish
echo "set -gx PULSE_SERVER tcp:(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}') #GWSL" >> ~/.config/fish/config.fish
echo "set -gx PULSE_SERVER tcp:(ip route show | grep default | awk '{print $3}') #GWSL" >> ~/.config/fish/config.fish
elif [ $wsl_shell == "zsh" ]
then
# Configure Zsh
sed -i.bak '/PULSE_SERVER=/d' ~/.zshrc
echo "export PULSE_SERVER=tcp:\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}') #GWSL" >> ~/.zshrc
echo "export PULSE_SERVER=tcp:\$(ip route show | grep default | awk '{print $3}') #GWSL" >> ~/.zshrc
elif [ $wsl_shell == "bash" ]
then
# Configure Bash
sed -i.bak '/PULSE_SERVER=/d' ~/.profile
echo "export PULSE_SERVER=tcp:\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}') #GWSL" >> ~/.profile
echo "export PULSE_SERVER=tcp:\$(ip route show | grep default | awk '{print $3}') #GWSL" >> ~/.profile
sed -i.bak '/PULSE_SERVER=/d' ~/.bashrc
echo "export PULSE_SERVER=tcp:\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2; exit;}') #GWSL" >> ~/.bashrc
echo "export PULSE_SERVER=tcp:\$(ip route show | grep default | awk '{print $3}') #GWSL" >> ~/.bashrc
fi
fi

Expand Down Expand Up @@ -227,4 +227,4 @@ then

else
echo "Not recognized"
fi
fi
4 changes: 2 additions & 2 deletions manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ def get_ip(machine):
:return:
"""
#print("get_ip")
cmd = "wsl.exe -d " + str(machine) + ' ' + "/bin/sh -c " + '"' + """(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}')""" + '"'
cmd = "wsl.exe -d " + str(machine) + ' ' + "/bin/sh -c " + '"' + """(ip route show | grep default | awk '{print $3}')""" + '"'


#print(cmd)
Expand All @@ -795,7 +795,7 @@ def get_ip(machine):
try:
ipa = ipaddress.ip_address(result)
except:
cmd = "wsl.exe -d " + str(machine) + ' ' + "/bin/sh -c " + '"' + """echo $(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}')""" + '"'
cmd = "wsl.exe -d " + str(machine) + ' ' + "/bin/sh -c " + '"' + """echo $(ip route show | grep default | awk '{print $3}')""" + '"'
result = os.popen(cmd).readlines()[0]
#result = "localhost"

Expand Down