mirror of
https://github.com/mintty/wsltty.git
synced 2025-04-18 16:50:29 +01:00
revamp deployment of shortcuts, scripts, and context menu entries
This commit is contained in:
parent
ee8d3b0678
commit
1e453b05e9
@ -3,14 +3,39 @@
|
|||||||
contextmenu=false
|
contextmenu=false
|
||||||
remove=false
|
remove=false
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-contextmenu) contextmenu=true
|
-shortcuts-remove)
|
||||||
|
remove=true
|
||||||
|
shift;;
|
||||||
|
-contextmenu)
|
||||||
|
contextmenu=true
|
||||||
shift;;
|
shift;;
|
||||||
-contextmenu-remove)
|
-contextmenu-remove)
|
||||||
contextmenu=true
|
contextmenu=true
|
||||||
remove=true
|
remove=true
|
||||||
shift;;
|
direckey='/HKEY_CURRENT_USER/Software/Classes/Directory'
|
||||||
-shortcuts-remove)
|
|
||||||
remove=true
|
regtool list "$direckey/shell" 2>/dev/null |
|
||||||
|
while read name
|
||||||
|
do
|
||||||
|
case `regtool get "$direckey/shell/$name/command/"` in
|
||||||
|
*bin\\mintty.exe*/bin/wslbridge*)
|
||||||
|
regtool remove "$direckey/shell/$name/command"
|
||||||
|
regtool remove "$direckey/shell/$name"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
regtool list "$direckey/Background/shell" 2>/dev/null |
|
||||||
|
while read name
|
||||||
|
do
|
||||||
|
case `regtool get "$direckey/Background/shell/$name/command/"` in
|
||||||
|
*bin\\mintty.exe*/bin/wslbridge*)
|
||||||
|
regtool remove "$direckey/Background/shell/$name/command"
|
||||||
|
regtool remove "$direckey/Background/shell/$name"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
exit
|
||||||
shift;;
|
shift;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -23,14 +48,19 @@ regtool () {
|
|||||||
esac
|
esac
|
||||||
key=`echo $2 | sed -e 's,.*{\(.*\)}.*,\1,' -e t -e d`
|
key=`echo $2 | sed -e 's,.*{\(.*\)}.*,\1,' -e t -e d`
|
||||||
case "$1.$2" in
|
case "$1.$2" in
|
||||||
list.*) if $contextmenu
|
list.*)
|
||||||
|
if $contextmenu
|
||||||
then echo "{0}"
|
then echo "{0}"
|
||||||
else echo "{1}"; echo "{2}"
|
else echo "{1}"; echo "{2}"
|
||||||
fi;;
|
fi;;
|
||||||
get.*/DistributionName) echo "distro$key";;
|
get.*/DistributionName)
|
||||||
get.*/BasePath) echo "C:\\Program\\{$key}\\State";;
|
echo "distro$key";;
|
||||||
get.*/PackageFamilyName) echo "distro{$key}";;
|
get.*/BasePath)
|
||||||
get.*/PackageFullName) echo "C:\\Program\\{$key}";;
|
echo "C:\\Program\\{$key}\\State";;
|
||||||
|
get.*/PackageFamilyName)
|
||||||
|
echo "distro{$key}";;
|
||||||
|
get.*/PackageFullName)
|
||||||
|
echo "C:\\Program\\{$key}";;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
@ -45,7 +75,7 @@ while read line; do echo "$line"; done <</EOB > mkbat.bat
|
|||||||
echo Creating %1.bat
|
echo Creating %1.bat
|
||||||
|
|
||||||
echo @echo off> %1.bat
|
echo @echo off> %1.bat
|
||||||
echo rem Start mintty terminal for WSL package %distro% in current directory>> %1.bat
|
echo rem Start mintty terminal for WSL package %name% in current directory>> %1.bat
|
||||||
echo %target% -i "%icon%" %minttyargs% %bridgeargs%>> %1.bat
|
echo %target% -i "%icon%" %minttyargs% %bridgeargs%>> %1.bat
|
||||||
|
|
||||||
echo Created %1.bat
|
echo Created %1.bat
|
||||||
@ -56,14 +86,16 @@ PATH=/bin:$PATH
|
|||||||
lxss="/HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Lxss"
|
lxss="/HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Lxss"
|
||||||
schema="/HKEY_CURRENT_USER/Software/Classes/Local Settings/Software/Microsoft/Windows/CurrentVersion/AppModel/SystemAppData"
|
schema="/HKEY_CURRENT_USER/Software/Classes/Local Settings/Software/Microsoft/Windows/CurrentVersion/AppModel/SystemAppData"
|
||||||
|
|
||||||
(regtool list "$lxss" 2>/dev/null || echo "No WSL packages registered" >&2) |
|
(regtool list "$lxss" 2>/dev/null && echo || echo "No WSL packages registered" >&2) |
|
||||||
while read guid
|
while read guid
|
||||||
do
|
do
|
||||||
|
ok=false
|
||||||
case $guid in
|
case $guid in
|
||||||
{*)
|
{*)
|
||||||
distro=`regtool get "$lxss/$guid/DistributionName"`
|
distro=`regtool get "$lxss/$guid/DistributionName"`
|
||||||
case "$distro" in
|
case "$distro" in
|
||||||
Legacy) name="Bash on Windows"
|
Legacy)
|
||||||
|
name="Bash on Windows"
|
||||||
launch=
|
launch=
|
||||||
launcher="$SYSTEMROOT/System32/bash.exe"
|
launcher="$SYSTEMROOT/System32/bash.exe"
|
||||||
;;
|
;;
|
||||||
@ -74,35 +106,53 @@ do
|
|||||||
esac
|
esac
|
||||||
basepath=`regtool get "$lxss/$guid/BasePath"`
|
basepath=`regtool get "$lxss/$guid/BasePath"`
|
||||||
if package=`regtool -q get "$lxss/$guid/PackageFamilyName"`
|
if package=`regtool -q get "$lxss/$guid/PackageFamilyName"`
|
||||||
then instdir=`regtool get "$schema/$package/Schemas/PackageFullName"`
|
then
|
||||||
if [ -r "$PROGRAMFILES/WindowsApps/$instdir/images/icon.ico" ]
|
instdir=`regtool get "$schema/$package/Schemas/PackageFullName"`
|
||||||
|
if [ -r "$ProgramW6432/WindowsApps/$instdir/images/icon.ico" ]
|
||||||
then icon="%PROGRAMFILES%/WindowsApps/$instdir/images/icon.ico"
|
then icon="%PROGRAMFILES%/WindowsApps/$instdir/images/icon.ico"
|
||||||
else icon="%LOCALAPPDATA%/wsltty/wsl.ico"
|
else icon="%LOCALAPPDATA%/wsltty/wsl.ico"
|
||||||
fi
|
fi
|
||||||
root="$basepath/rootfs"
|
root="$basepath/rootfs"
|
||||||
else icon="%LOCALAPPDATA%/lxss/bash.ico"
|
else
|
||||||
|
icon="%LOCALAPPDATA%/lxss/bash.ico"
|
||||||
root="$basepath"
|
root="$basepath"
|
||||||
fi
|
fi
|
||||||
echoc "distro $distro"
|
|
||||||
echoc "- guid $guid"
|
|
||||||
echoc "- (launcher $launcher)"
|
|
||||||
echoc "- icon $icon"
|
|
||||||
echoc "- root $root"
|
|
||||||
|
|
||||||
target='%LOCALAPPDATA%\wsltty\bin\mintty.exe'
|
|
||||||
minttyargs='--wsl --rootfs="'"$root"'" -h err --configdir="%APPDATA%\wsltty" -o Locale=C -o Charset=UTF-8 /bin/wslbridge '
|
minttyargs='--wsl --rootfs="'"$root"'" -h err --configdir="%APPDATA%\wsltty" -o Locale=C -o Charset=UTF-8 /bin/wslbridge '
|
||||||
|
minttyargs='--WSL="'"$distro"'" -h err --configdir="%APPDATA%\wsltty"'
|
||||||
#if [ -z "$launch" ]
|
#if [ -z "$launch" ]
|
||||||
#then bridgeargs='-t /bin/bash'
|
#then bridgeargs='-t /bin/bash'
|
||||||
#else bridgeargs='-l "'"$launch"'" -t /bin/bash'
|
#else bridgeargs='-l "'"$launch"'" -t /bin/bash'
|
||||||
#fi
|
#fi
|
||||||
bridgeargs='--distro-guid "'"$guid"'" -t /bin/bash'
|
bridgeargs='--distro-guid "'"$guid"'" -t /bin/bash'
|
||||||
|
bridgeargs='--distro-guid "'"$guid"'" -t'
|
||||||
|
|
||||||
|
ok=true;;
|
||||||
|
"") # WSL default installation
|
||||||
|
distro=
|
||||||
|
name=WSL
|
||||||
|
icon="%LOCALAPPDATA%/wsltty/wsl.ico"
|
||||||
|
minttyargs='--WSL= -h err --configdir="%APPDATA%\wsltty"'
|
||||||
|
bridgeargs='-t'
|
||||||
|
|
||||||
|
ok=true;;
|
||||||
|
esac
|
||||||
|
echoc "distro '$distro'"
|
||||||
|
echoc "- name '$name'"
|
||||||
|
echoc "- guid $guid"
|
||||||
|
echoc "- (launcher $launcher)"
|
||||||
|
echoc "- icon $icon"
|
||||||
|
echoc "- root $root"
|
||||||
|
target='%LOCALAPPDATA%\wsltty\bin\mintty.exe'
|
||||||
|
bridgeargs=" "
|
||||||
|
|
||||||
|
if $ok
|
||||||
|
then
|
||||||
export target minttyargs bridgeargs icon
|
export target minttyargs bridgeargs icon
|
||||||
export distro
|
|
||||||
|
|
||||||
if $contextmenu
|
if $contextmenu
|
||||||
then
|
then
|
||||||
# create context menu entry
|
# context menu entries
|
||||||
#cmd /C mkcontext "$name"
|
#cmd /C mkcontext "$name"
|
||||||
direckey='HKEY_CURRENT_USER\Software\Classes\Directory'
|
direckey='HKEY_CURRENT_USER\Software\Classes\Directory'
|
||||||
if $remove
|
if $remove
|
||||||
@ -110,50 +160,49 @@ do
|
|||||||
reg delete "$direckey\\shell\\$name" /f
|
reg delete "$direckey\\shell\\$name" /f
|
||||||
reg delete "$direckey\\Background\\shell\\$name" /f
|
reg delete "$direckey\\Background\\shell\\$name" /f
|
||||||
else
|
else
|
||||||
reg add "$direckey\\shell\\$name" /d "$name in Mintty Here" /f
|
reg add "$direckey\\shell\\$name" /d "$name Terminal" /f
|
||||||
reg add "$direckey\\shell\\$name" /v Icon /d "$icon" /f
|
reg add "$direckey\\shell\\$name" /v Icon /d "$icon" /f
|
||||||
cmd /C reg add "$direckey\\shell\\$name\\command" /d "\"$target\" -i \"$icon\" --dir \"%1\" $minttyargs $bridgeargs" /f
|
cmd /C reg add "$direckey\\shell\\$name\\command" /d "\"$target\" -i \"$icon\" --dir \"%1\" $minttyargs $bridgeargs" /f
|
||||||
reg add "$direckey\\Background\\shell\\$name" /d "$name in Mintty Here" /f
|
reg add "$direckey\\Background\\shell\\$name" /d "$name Terminal" /f
|
||||||
reg add "$direckey\\Background\\shell\\$name" /v Icon /d "$icon" /f
|
reg add "$direckey\\Background\\shell\\$name" /v Icon /d "$icon" /f
|
||||||
cmd /C reg add "$direckey\\Background\\shell\\$name\\command" /d "\"$target\" -i \"$icon\" $minttyargs $bridgeargs" /f
|
cmd /C reg add "$direckey\\Background\\shell\\$name\\command" /d "\"$target\" -i \"$icon\" $minttyargs $bridgeargs" /f
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
# invocation shortcuts and scripts
|
||||||
if $remove
|
if $remove
|
||||||
then
|
then
|
||||||
cmd /C del "%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\$name ~ in Mintty.lnk"
|
cmd /C del "%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\$name Terminal.lnk"
|
||||||
cmd /C del "%LOCALAPPDATA%\\Microsoft\\WindowsApps\\$name.bat"
|
cmd /C del "%LOCALAPPDATA%\\Microsoft\\WindowsApps\\$name.bat"
|
||||||
cmd /C del "%LOCALAPPDATA%\\Microsoft\\WindowsApps\\$name~.bat"
|
cmd /C del "%LOCALAPPDATA%\\Microsoft\\WindowsApps\\$name~.bat"
|
||||||
else
|
else
|
||||||
# create desktop/start menu shortcut
|
# desktop shortcut in %USERPROFILE% -> Start Menu - WSLtty
|
||||||
cscript /nologo mkshortcut.vbs "/name:$name in Mintty"
|
cscript /nologo mkshortcut.vbs "/name:$name Terminal %"
|
||||||
# copy to Start Menu WSLtty subfolder
|
cmd /C copy "$name Terminal %.lnk" "%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\WSLtty"
|
||||||
rem cmd /C mkdir "%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\WSLtty\\WinUser"
|
|
||||||
cmd /C copy "$name in Mintty.lnk" "%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\WSLtty"
|
|
||||||
|
|
||||||
# create command-line launch script
|
# launch script in . -> WSLtty home, WindowsApps launch folder
|
||||||
cmd /C mkbat.bat "$name"
|
cmd /C mkbat.bat "$name"
|
||||||
#cmd /C mkbat.bat "$name in Mintty"
|
|
||||||
# copy to WSLtty home and to WindowsApps launch folder
|
|
||||||
cmd /C copy "$name.bat" "%LOCALAPPDATA%\\wsltty\\$name.bat"
|
cmd /C copy "$name.bat" "%LOCALAPPDATA%\\wsltty\\$name.bat"
|
||||||
cmd /C copy "$name.bat" "%LOCALAPPDATA%\\Microsoft\\WindowsApps\\$name.bat"
|
cmd /C copy "$name.bat" "%LOCALAPPDATA%\\Microsoft\\WindowsApps\\$name.bat"
|
||||||
|
|
||||||
# prepare versions to target WSL home directory
|
# prepare versions to target WSL home directory
|
||||||
bridgeargs="-C~ $bridgeargs"
|
#bridgeargs="-C~ $bridgeargs"
|
||||||
|
minttyargs="$minttyargs -~"
|
||||||
|
|
||||||
# create optional addition desktop shortcut
|
# desktop shortcut in ~ -> Start Menu
|
||||||
cscript /nologo mkshortcut.vbs "/name:$name ~ in Mintty"
|
cscript /nologo mkshortcut.vbs "/name:$name Terminal"
|
||||||
# copy to Start Menu
|
cmd /C copy "$name Terminal.lnk" "%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs"
|
||||||
cmd /C copy "$name ~ in Mintty.lnk" "%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs"
|
|
||||||
|
|
||||||
# create command-line launch script
|
# default desktop shortcut in ~ -> Desktop
|
||||||
|
if [ "$name" = "WSL" ]
|
||||||
|
then cmd /C copy "$name Terminal.lnk" "%USERPROFILE%\\Desktop"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# launch script in ~ -> WSLtty home, WindowsApps launch folder
|
||||||
cmd /C mkbat.bat "$name~"
|
cmd /C mkbat.bat "$name~"
|
||||||
#cmd /C mkbat.bat "$name~ in Mintty"
|
|
||||||
# copy to WSLtty home and to WindowsApps launch folder
|
|
||||||
cmd /C copy "$name~.bat" "%LOCALAPPDATA%\\wsltty\\$name~.bat"
|
cmd /C copy "$name~.bat" "%LOCALAPPDATA%\\wsltty\\$name~.bat"
|
||||||
cmd /C copy "$name~.bat" "%LOCALAPPDATA%\\Microsoft\\WindowsApps\\$name~.bat"
|
cmd /C copy "$name~.bat" "%LOCALAPPDATA%\\Microsoft\\WindowsApps\\$name~.bat"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi;;
|
fi
|
||||||
esac
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user