Skip to content

Commit

Permalink
Merge pull request #128 from wslutilities/3.x/master
Browse files Browse the repository at this point in the history
wslu 3.1.1
  • Loading branch information
patrick330602 committed Jun 28, 2020
2 parents 3d268b1 + 795440d commit 552db30
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.eo.md
Expand Up @@ -63,7 +63,7 @@ Aro de rapidaj agoj por WSL, kiel repide surmeti ĉiujn Vindozajn diskingojn aŭ
Oni povas instali `wslu` el **Alpine Linux community** per la jenaj komandoj:

```
$ echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/community/" | sudo tee -a /etc/apk/repositories
$ echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/community/" | sudo tee -a /etc/apk/repositories
$ sudo apk update
$ sudo apk add wslu@testing
```
Expand Down
4 changes: 2 additions & 2 deletions README.hans.md
Expand Up @@ -18,7 +18,7 @@

这是一套适用于 Windows 10 Linux 子系统的工具组,可以在 Windows 10 Linux 子系统下完成诸如获取 Windows 环境变量或者创建你最喜爱的 Linux 程序桌面快捷方式等工作。

需要 Windows 10 创造者更新; 部分功能需要更高版本的Windows 10;支持 WSL2。
需要 Windows 10 创造者更新部分功能需要更高版本的Windows 10;支持 WSL2。

## 功能

Expand Down Expand Up @@ -61,7 +61,7 @@
你可以用以下命令安装 `wslu`

```
$ echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/community/" | sudo tee -a /etc/apk/repositories
$ echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/community/" | sudo tee -a /etc/apk/repositories
$ sudo apk update
$ sudo apk add wslu@testing
```
Expand Down
4 changes: 2 additions & 2 deletions README.hant.md
Expand Up @@ -18,7 +18,7 @@

這是一套適用於 Windows 10 Linux 子系統的工具組,可以在 Windows 10 Linux 子系統下完成諸如獲取 Windows 環境變數或者建立你最喜愛的 Linux 程式桌面捷徑等工作。

需要 Windows 10 創造者更新; 部分功能需要更高版本的Windows 10;支援 WSL2。
需要 Windows 10 創造者更新部分功能需要更高版本的Windows 10;支援 WSL2。

## 功能

Expand Down Expand Up @@ -62,7 +62,7 @@
你可以用以下指令安裝 `wslu`

```
$ echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/community/" | sudo tee -a /etc/apk/repositories
$ echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/community/" | sudo tee -a /etc/apk/repositories
$ sudo apk update
$ sudo apk add wslu@testing
```
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -61,7 +61,7 @@ A set of quick actions for WSL such as quickly mounting all drives or manually s
You can install `wslu` from Alpine Linux community with the following command:

```
$ echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/community/" | sudo tee -a /etc/apk/repositories
$ echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/community/" | sudo tee -a /etc/apk/repositories
$ sudo apk update
$ sudo apk add wslu@testing
```
Expand Down
19 changes: 19 additions & 0 deletions src/wslfetch.sh
Expand Up @@ -275,6 +275,25 @@ case "$distro" in
"${light_blue} :---${white}:sdNMMMMNds:${light_blue}------------: ${reset}"
"${light_blue} :------${white}:://:${light_blue}-------------:: ${reset}"
"${light_blue} :---------------------:// ${reset}");;
'fedoraremix')
t="${white}${deep_purple}"
full_text=(
"${white} ${reset}"
"${white} ${reset}"
"${white} ${reset}"
"${white} wgg ,g ${reset}"
"${white} \$\$ ]$ ${reset}"
"${white} 'A\$\$A g@PR&, x\$NR&@$ g\$PR&w \$N\$P* g&P&&y ${reset}"
"${white} \$\$ \$\$gggg$ $~ 1$ \$\$ &K \$F \$E \"\$. ${reset}"
"${white} \$\$ ]\$w ,gg &N,,w\$\$ \"\$w,,g$\" \$F J\$w,,\$\$U ${reset}"
"${white} \" *T7' \`7T' 7 \"TT' 7 ?T7 7 ™ ${reset}"
"${deep_purple} ,@@@@&8@@@@@M&@@@@@8R@@R@@@@@@@@@@@@@@@@@W ${reset}"
"${deep_purple} .@@@@\`,@@@@F M ]@@@@ @ a@ @@@@ #@@@@,\`,@@@@@ ${reset}"
"${deep_purple} @@@@~]@@@@W *\"]@@@@j@ \$@ @@@@ #@@@F @ \$@@@@ ${reset}"
"${deep_purple} *R@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@RMF ${reset}"
"${white} ${reset}"
"${white} ${reset}"
"${white} ${reset}");;
*)
t="${cyan}${bold}"
full_text=(
Expand Down
4 changes: 3 additions & 1 deletion src/wslu-header
Expand Up @@ -67,6 +67,7 @@ light_cyan=$(echo -e '\e[1;36m')
light_gray=$(echo -e '\e[37m')
orange=$(echo -e '\e[38;5;202m')
light_orange=$(echo -e '\e[38;5;214m')
deep_purple=$(echo -e '\e[38;5;140m')
bold=$(echo -e '\033[1m')
reset=$(echo -e '\033(B\033[m')

Expand Down Expand Up @@ -156,7 +157,7 @@ function baseexec_gen {
wslutmpbuild="$(( $wslutmpbuild + 0 ))"
if [ $wslutmpbuild -ge $BN_MAY_NINETEEN ]; then
# The environment variable only available in 19H1 or later.
wslu_distro_regpath=$("$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/reg.exe query "HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Lxss" /s /f DistributionName 2>&1 | grep -B1 -e "$WSL_DISTRO_NAME" | head -n1 | sed -e 's|\r||g')
wslu_distro_regpath=$("$(interop_prefix)"c/Windows/System32/reg.exe query "HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Lxss" /s /f DistributionName 2>&1 | sed -e 's|\r||g' | grep -B1 -e "$WSL_DISTRO_NAME$" | head -n1 )
if "$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/reg.exe query "$wslu_distro_regpath" /v PackageFamilyName &>/dev/null; then
wslu_distro_packagename=$("$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/reg.exe query "$wslu_distro_regpath" /v PackageFamilyName | tail -n 2 | head -n 1 | sed -e 's|\r||g')
# if it is a store distro
Expand Down Expand Up @@ -228,6 +229,7 @@ case $distro in
Arch*) distro="archlinux";;
*Oracle*) distro="oracle";;
Scientific*) distro="scilinux";;
*Fedora\ Remix\ for\ WSL*) distro="fedoraremix";;
*Fedora*) distro="fedora";;
*Generic*) [ "fedora" == "$(grep -e "LIKE=" /etc/os-release | sed -e 's/ID_LIKE=//g')" ] && distro="oldfedora" || distro="unknown";;
*) distro="unknown";;
Expand Down
32 changes: 23 additions & 9 deletions src/wslusc.sh
@@ -1,5 +1,5 @@
# shellcheck shell=bash
version="37"
version="40"

cname=""
iconpath=""
Expand All @@ -19,14 +19,16 @@ while [ "$1" != "" ]; do
-g|--gui)is_gui=1;shift;;
-h|--help) help "$0" "$help_short"; exit;;
-v|--version) echo "wslu v$wslu_version; wslusc v$version"; exit;;
*) cname="$*";break;;
*) cname_header="$1"; shift; cname="$*"; break;;
esac
done

# interactive mode
if [[ $is_interactive -eq 1 ]]; then
echo "${info} Welcome to wslu shortcut creator interactive mode."
read -r -e -i "$cname" -p "${input_info} Command to execute: " input
read -r -e -i "$cname_header" -p "${input_info} Command (Without Parameter): " input
cname_header="${input:-$cname_header}"
read -r -e -i "$cname" -p "${input_info} Command param: " input
cname="${input:-$cname}"
read -r -e -i "$customname" -p "${input_info} Shortcut name [optional, ENTER for default]: " input
customname="${input:-$customname}"
Expand All @@ -38,9 +40,10 @@ if [[ $is_interactive -eq 1 ]]; then
iconpath="${input:-$iconpath}"
fi

if [[ "$cname" != "" ]]; then
if [[ "$cname_header" != "" ]]; then
up_path="$(wslvar -s USERPROFILE)"
tpath=$(double_dash_p "$(wslvar -s TMP)") # Windows Temp, Win Double Sty.
tpath="${tpath:-$(double_dash_p "$(wslvar -s TEMP)")}" # sometimes TMP is not set for some reason
dpath=$(wslpath "$(wslvar -l Desktop)") # Windows Desktop, WSL Sty.
script_location="$(wslpath "$up_path")/wslu" # Windows wslu, Linux WSL Sty.
script_location_win="$(double_dash_p "$up_path")\\wslu" # Windows wslu, Win Double Sty.
Expand All @@ -49,16 +52,27 @@ if [[ "$cname" != "" ]]; then
# change param according to the exec.
distro_param="run"
if [[ "$distro_location_win" == *wsl.exe* ]]; then
distro_param=""
distro_param="-e"
fi

# always absolute path
tmp_cname_header="$(readlink -f "$cname_header")"
if [ ! -f "$cname_header" ]; then
cname_header="$(which "$cname_header")"
else
cname_header="$tmp_cname_header"
fi

# handling no name given case
new_cname=$(basename "$(echo "$cname" | awk '{print $1}')")
new_cname=$(basename "$cname_header")
# handling name given case
if [[ "$customname" != "" ]]; then
new_cname=$customname
fi

# construct full command
cname="\"$(echo "$cname_header" | sed "s| |\\\\ |g") $cname\""

# Check default icon and runHidden.vbs
wslu_file_check "$script_location" "wsl.ico"
wslu_file_check "$script_location" "wsl-term.ico"
Expand Down Expand Up @@ -109,11 +123,11 @@ if [[ "$cname" != "" ]]; then
fi

if [[ "$is_gui" == "1" ]]; then
winps_exec "Import-Module 'C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\Microsoft.PowerShell.Utility\\Microsoft.PowerShell.Utility.psd1';\$s=(New-Object -COM WScript.Shell).CreateShortcut('$tpath\\$new_cname.lnk');\$s.TargetPath='C:\\Windows\\System32\\wscript.exe';\$s.Arguments='$script_location_win\\runHidden.vbs \"$distro_location_win\" $distro_param \"$customenv /usr/share/wslu/wslusc-helper.sh $cname\"';\$s.IconLocation='$iconpath';\$s.Save();"
winps_exec "Import-Module 'C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\Microsoft.PowerShell.Utility\\Microsoft.PowerShell.Utility.psd1';\$s=(New-Object -COM WScript.Shell).CreateShortcut('$tpath\\$new_cname.lnk');\$s.TargetPath='C:\\Windows\\System32\\wscript.exe';\$s.Arguments='$script_location_win\\runHidden.vbs \"$distro_location_win\" $distro_param $customenv /usr/share/wslu/wslusc-helper.sh $cname';\$s.IconLocation='$iconpath';\$s.Save();"
else
winps_exec "Import-Module 'C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\Microsoft.PowerShell.Utility\\Microsoft.PowerShell.Utility.psd1';\$s=(New-Object -COM WScript.Shell).CreateShortcut('$tpath\\$new_cname.lnk');\$s.TargetPath='\"$distro_location_win\"';\$s.Arguments='$distro_param \"$customenv bash -l -c $cname\"';\$s.IconLocation='$iconpath';\$s.Save();"
winps_exec "Import-Module 'C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\Microsoft.PowerShell.Utility\\Microsoft.PowerShell.Utility.psd1';\$s=(New-Object -COM WScript.Shell).CreateShortcut('$tpath\\$new_cname.lnk');\$s.TargetPath='\"$distro_location_win\"';\$s.Arguments='$distro_param $customenv bash -l -c $cname';\$s.IconLocation='$iconpath';\$s.Save();"
fi
tpath="$(wslpath "$(wslvar -s TMP)")/$new_cname.lnk"
tpath="$(wslpath "$tpath")/$new_cname.lnk"
mv "$tpath" "$dpath"
echo "${info} Create shortcut ${new_cname}.lnk successful"
else
Expand Down
1 change: 1 addition & 0 deletions src/wslview.sh
Expand Up @@ -53,6 +53,7 @@ if [[ "$lname" != "" ]]; then
fi
elif [[ $lname =~ ^(/[^/]+)*(/)?$ ]]; then
if [ $wslutmpbuild -ge "$BN_MAY_NINETEEN" ]; then
properfile_full_path="$(readlink -f "${lname}")"
converted_file_path="\\\\wsl\$\\$WSL_DISTRO_NAME${properfile_full_path//\//\\}"
winps_exec Start "\"$converted_file_path\""
else
Expand Down

0 comments on commit 552db30

Please sign in to comment.