Open cmplstofB opened 3 years ago
https://cgit.freedesktop.org/xdg/xdg-user-dirs/tree/man/xdg-user-dir.xml
DESKTOP
DOWNLOAD
TEMPLATES
PUBLICSHARE
DOCUMENTS
MUSIC
PICTURES
VIDEOS
PUBLICSHARE
台録に対応するのはSpecial Folderにはないかな?
Windows | XDG |
---|---|
Desktop | DESKTOP |
[^1] | DOWNLOAD |
Templates | TEMPLATES |
(なし?) | PUBLICSHARE |
MyDocuments | DOCUMENTS |
MyMusic | MUSIC |
MyPictures | PICTURES |
MyVideos | VIDEOS |
[^1]:
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe \
-Command 'gpv -Path 'Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders' -Name '{374DE290-123F-4565-9164-39C4925E467B}'
うまくいかない
#!/bin/sh
set -v
set -- Desktop=DESKTOP Templates=TEMPLATES MyDocuments=DOCUMENTS \
MyMusic=MUSIC MyPictures=PICTURES MyVideo=VIDEOS
while [ $# -gt 0 ]; do
printf '%s="%s"\n' \
"${1#*=}" \
"$(/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe \
-Command '[Environment]::GetFolderPath("'${1%=*}'")')"
# "$(wslpath -a -u \
# )"
shift
done
うまくいかない原因は,PowerShellの(既定の?←つまり変更可能かもしれない)改行が送行・復帰で構成されていることだった。
#!/bin/sh
set -- Desktop=DESKTOP Templates=TEMPLATES MyDocuments=DOCUMENTS \
MyMusic=MUSIC MyPictures=PICTURES MyVideo=VIDEOS
while [ $# -gt 0 ]; do
printf '%s="%s"\n' \
"${1#*=}" \
"$(wslpath -a -u \
"$(/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe \
-Command '[Console]::Write([Environment]::GetFolderPath("'"${1%=*}"'"))'
)")"
shift
done
Windows側からの例
$ wsl -d Ubuntu -u cmplstofb -e xdg-user-dir DESKTOP
powershell.exe -Command '[Environment]::GetEnvironmentVariable("TEMP", 'Machine')'
[System.IO.Path]::GetTempPath() # ←これは `'Machine'` が使えない
https://docs.microsoft.com/en-us/dotnet/api/system.environment.specialfolder?view=netframework-4.0#fields