Skip to content

Commit

Permalink
Merge pull request #171 from wslutilities/lts/master
Browse files Browse the repository at this point in the history
[Release] wslu 3.2.2 LTS
  • Loading branch information
patrick330602 authored Feb 28, 2021
2 parents 190eda6 + ae1d069 commit 70ba606
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 63 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ clean:
rm -rf $(OUTMANPATH)

test:
extras/bats/bin/bats -r tests
bats -r tests
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.1-3
3.2.2-1
4 changes: 4 additions & 0 deletions docs/wslu.7
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
- a collection of utilities for Windows 10 Linux Subsystem
.SH DESCRIPTION
This is a collection of utilities for Windows 10 Linux Subsystem, such as enabling sound in WSL or creating your favorite linux app shortcuts on Windows 10 Desktop. Requires Windows 10 Creators Update and higher. Some features require Windows 10 May 2019 Update or later.
.SH AVAILABLE COMMANDS
wslusc, wslsys, wslfetch, wslvar, wslview(wview/wslstart/wstart), wslupath(deprecated), wslact
.PP
check each manpage to see the detailed usage.
.SH SUPPORTED DISTRIBUTION
.nf
- Debian GNU/Linux
Expand Down
59 changes: 3 additions & 56 deletions src/etc/wslusc-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,67 +18,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

function interop_prefix {

win_location="/mnt/"
if [ -f /etc/wsl.conf ]; then
tmp="$(awk -F '=' '/root/ {print $2}' /etc/wsl.conf | awk '{$1=$1;print}')"
[ "$tmp" == "" ] || win_location="$tmp"
unset tmp
fi
echo "$win_location"

unset win_location
}

function sysdrive_prefix {
win_location="$(interop_prefix)"
hard_reset=0
for pt in $(ls "$win_location"); do
if [ $(echo "$pt" | wc -l) -eq 1 ]; then
if [ -d "$win_location$pt/Windows/System32" ]; then
hard_reset=1
win_location="$pt"
break
fi
fi
done

if [ $hard_reset -eq 0 ]; then
win_location="c"
fi

echo "$win_location"

unset win_location
unset hard_reset
}

if [[ -n $WSL_INTEROP ]]; then
# enable external x display for WSL 2


if ( command -v ipconfig.exe &>/dev/null ); then
ipconfig_exec=$(command -v ipconfig.exe)
else
ipconfig_exec="$(interop_prefix)$(sysdrive_prefix)/Windows/System32/ipconfig.exe"
fi

if ( eval "$ipconfig_exec" | grep -n -m 1 "Default Gateway.*: [0-9a-z]" | cut -d : -f 1 ) >/dev/null; then
set +H
wsl2_d_tmp="$(eval "$ipconfig_exec" | grep -n -m 1 "Default Gateway.*: [0-9a-z]" | cut -d : -f 1)"
wsl2_d_tmp="$(eval "$ipconfig_exec" | sed $(( wsl2_d_tmp - 4 ))','$(( wsl2_d_tmp + 0 ))'!d' | grep IPv4 | cut -d : -f 2 | sed -e "s|\s||g" -e "s|\r||g")"
set -H
export DISPLAY=${wsl2_d_tmp}:0.0
else
wsl2_d_tmp="$(grep nameserver /etc/resolv.conf | awk '{print $2}')"
export DISPLAY=${wsl2_d_tmp}:0
fi
wsl2_d_tmp="$(grep nameserver /etc/resolv.conf | awk '{print $2}')"
export DISPLAY=${wsl2_d_tmp}:0

unset wsl2_d_tmp
unset ipconfig_exec
else
export DISPLAY=:0
export DISPLAY=:0
fi

win_sys_scaling=$(wslsys -S -s)
Expand Down
6 changes: 4 additions & 2 deletions src/wslu-header
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ function chcp_com {
}

function winps_exec {
chcp_com "$(cat ~/.config/wslu/oemcp)"
"$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -NoProfile -NonInteractive –ExecutionPolicy Bypass -Command "$@"
cp="$(cat ~/.config/wslu/oemcp)"
chcp_com "$cp"
cp=$(($cp+0))
"$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -NoProfile -NonInteractive –ExecutionPolicy Bypass -Command "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; [Console]::InputEncoding = [System.Text.Encoding]::GetEncoding($cp); $@"
EXIT_STATUS=$?
chcp_com 65001
return $EXIT_STATUS
Expand Down
9 changes: 9 additions & 0 deletions src/wslview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,22 @@ if [[ "$lname" != "" ]]; then
converted_file_path="\\\\wsl\$\\$WSL_DISTRO_NAME${properfile_full_path//\//\\}"
[[ "$properfile_full_path" =~ ^${interop_win_type//\/$/}.*$ ]] && converted_file_path="$(wslpath -w "$properfile_full_path")"
lname="$converted_file_path"
# Linux absolute path
elif [[ "$lname" =~ ^(/[^/]+)*(/)?$ ]]; then
[ $wslutmpbuild -ge "$BN_MAY_NINETEEN" ] || error_echo "This protocol is not supported before version 1903." 34
properfile_full_path="$(readlink -f "${lname}")"
interop_win_type="$(interop_prefix)$(sysdrive_prefix)"
converted_file_path="\\\\wsl\$\\$WSL_DISTRO_NAME${properfile_full_path//\//\\}"
[[ "$properfile_full_path" =~ ^${interop_win_type//\/$/}.*$ ]] && converted_file_path="$(wslpath -w "$properfile_full_path")"
lname="$converted_file_path"
# Linux relative path
elif [[ -d "$(readlink -f "$lname")" ]] || [[ -f "$(readlink -f "$lname")" ]]; then
[ $wslutmpbuild -ge "$BN_MAY_NINETEEN" ] || error_echo "This protocol is not supported before version 1903." 34
properfile_full_path="$(readlink -f "${lname}")"
interop_win_type="$(interop_prefix)$(sysdrive_prefix)"
converted_file_path="\\\\wsl\$\\$WSL_DISTRO_NAME${properfile_full_path//\//\\}"
[[ "$properfile_full_path" =~ ^${interop_win_type//\/$/}.*$ ]] && converted_file_path="$(wslpath -w "$properfile_full_path")"
lname="$converted_file_path"
fi
winps_exec Start "\"$lname\""
else
Expand Down

0 comments on commit 70ba606

Please sign in to comment.