├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ └── config.yml ├── PULL_REQUEST_TEMPLATE.md ├── actions │ └── rpmbuild │ │ ├── Dockerfile │ │ └── action.yml └── workflows │ ├── docs.yml │ ├── manpage.yml │ ├── pkgbuild.yml │ ├── pkgdeploy.yaml │ └── tests.yaml ├── .gitignore ├── .shellcheckrc ├── .vscode └── extensions.json ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── THIRD_PARTY_LICENSE ├── VERSION ├── configure.sh ├── docs ├── wslact.1 ├── wslclip.1 ├── wslfetch.1 ├── wslgsu.1 ├── wslsys.1 ├── wslu.7 ├── wslupath.1 ├── wslusc.1 ├── wslvar.1 └── wslview.1 ├── extras ├── build │ ├── alpine │ │ ├── APKBUILD │ │ ├── wslu.post-install │ │ ├── wslu.post-upgrade │ │ └── wslu.pre-deinstall │ ├── arch │ │ ├── PKGBUILD │ │ └── wslu.install │ └── rpm │ │ ├── copr │ │ └── wslu.spec │ │ └── obs │ │ └── wslu.spec ├── icon.png └── scripts │ ├── manpage_deploy.bash │ ├── wslu-install │ └── wslu-uninstall ├── src ├── etc │ ├── conf │ ├── get_dpi.ps1 │ ├── runHidden.vbs │ ├── sudo.ps1 │ ├── user │ │ └── conf │ ├── wsl-gui.ico │ ├── wsl-term.ico │ ├── wsl.ico │ ├── wslusc-helper.sh │ └── wslview.desktop ├── wslact.sh ├── wslclip.sh ├── wslfetch.sh ├── wslgsu.sh ├── wslsys.sh ├── wslu-header ├── wslupath.sh ├── wslusc.sh ├── wslvar.sh └── wslview.sh └── tests ├── header.bats ├── wslact.bats ├── wslfetch.bats ├── wslgsu.bats ├── wslsys.bats ├── wslupath.bats ├── wslusc.bats ├── wslvar.bats └── wslview.bats /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: Create a report to help us improve 3 | labels: ["Bug"] 4 | assignees: 5 | - patrick330602 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | Thanks for taking the time to fill out this bug report! 11 | 12 | > **ATTENTION!** 13 | > 14 | > Built-in versions of wslu in Ubuntu are no longer supported by me. 15 | > 16 | > If you have problems, please: 17 | > 1. Report to the Ubuntu WSL team; or 18 | > 2. Try the PPA version of WSL here: 19 | > 20 | > Usually The PPA version of wslu will address most of your problems. 21 | - type: dropdown 22 | id: win-version 23 | attributes: 24 | label: Windows Version 25 | description: What version of Windows are you running? 26 | options: 27 | - Windows 10 28 | - Windows 11 29 | validations: 30 | required: true 31 | - type: input 32 | id: win-build 33 | attributes: 34 | label: Windows Build Number 35 | description: What's your Windows build number? 36 | placeholder: e.g. build 17704 37 | validations: 38 | required: true 39 | - type: dropdown 40 | id: wsl-version 41 | attributes: 42 | label: WSL Version 43 | description: What version of WSL are you running? 44 | options: 45 | - WSL 1 46 | - WSL 2 47 | - Not Applicable 48 | validations: 49 | required: true 50 | - type: input 51 | id: wsl-distro 52 | attributes: 53 | label: Distro Version 54 | description: What's the distro? If it happens on multiple distros, please list them. 55 | placeholder: e.g. Ubuntu 20.04 56 | validations: 57 | required: true 58 | - type: input 59 | id: wslu-version 60 | attributes: 61 | label: WSL Utilities Version 62 | description: What's the version of WSL Utilities? 63 | placeholder: e.g. 2.3.4 64 | validations: 65 | required: true 66 | - type: textarea 67 | id: description 68 | attributes: 69 | label: Describe the bug 70 | description: A clear and concise description of what the bug is. 71 | validations: 72 | required: true 73 | - type: textarea 74 | id: steps-to-reproduce 75 | attributes: 76 | label: Steps to Reproduce 77 | description: Steps to reproduce the behavior. 78 | placeholder: | 79 | 1. Go to '...' 80 | 2. Click on '....' 81 | 3. Scroll down to '....' 82 | 4. See error 83 | validations: 84 | required: true 85 | - type: textarea 86 | id: expected-behavior 87 | attributes: 88 | label: Expected behavior 89 | description: A clear and concise description of what you expected to happen. 90 | validations: 91 | required: true 92 | - type: textarea 93 | id: additional-context 94 | attributes: 95 | label: Additional context 96 | description: Add any other context about the problem here. 97 | - type: checkboxes 98 | id: terms 99 | attributes: 100 | label: Code of Conduct 101 | description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/wslutilities/wslu/blob/7920eb4f94873666477032a33ab57a9b6ee9ad96/CODE_OF_CONDUCT.md) 102 | options: 103 | - label: I agree to follow this project's Code of Conduct 104 | required: true -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | # https://docs.github.com/en/free-pro-team@latest/github/building-a-strong-community/configuring-issue-templates-for-your-repository#configuring-the-template-chooser 2 | blank_issues_enabled: true 3 | contact_links: 4 | - name: "Ubuntu bugs" 5 | url: https://bugs.launchpad.net/ubuntu/+source/wslu 6 | about: For Ubuntu version, you should only report bug at Launchpad. 7 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | 6 | ## Types of changes 7 | 8 | 9 | > Breaking change (fix or feature that would cause existing functionality to not work as expected) are no longer accepted 10 | 11 | - [ ] Bug fix (non-breaking change which fixes an issue) 12 | - [ ] New feature (non-breaking change which adds functionality) 13 | 14 | ## Checklist: 15 | 16 | 17 | - [ ] I have read Code of Conduct and Contributing documentations. 18 | - [ ] My code follows the code style of this project. 19 | - [ ] My change requires a change to the documentation. 20 | - [ ] I have updated the documentation accordingly. -------------------------------------------------------------------------------- /.github/actions/rpmbuild/Dockerfile: -------------------------------------------------------------------------------- 1 | # A copy of robertdebock/github-action-rpmbuild because that one don't work 2 | FROM rockylinux/rockylinux:8 3 | 4 | WORKDIR /github/workspace 5 | 6 | RUN dnf install -y make tar gzip rpmdevtools dnf-utils spectool dnf-utils && \ 7 | dnf clean all && \ 8 | rm -r -f /var/cache/* 9 | 10 | CMD spectool --get-files --all SPECS/*.spec && \ 11 | yum-builddep --assumeyes SPECS/*.spec && \ 12 | rpmbuild --define '_topdir /github/workspace' -ba SPECS/*.spec -------------------------------------------------------------------------------- /.github/actions/rpmbuild/action.yml: -------------------------------------------------------------------------------- 1 | name: Build an RPM 2 | description: Build an RPM. 3 | 4 | runs: 5 | using: docker 6 | image: "Dockerfile" 7 | 8 | branding: 9 | icon: box 10 | color: green 11 | -------------------------------------------------------------------------------- /.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | name: Documentation Website Deployment 2 | on: 3 | push: 4 | branches: 5 | - master 6 | jobs: 7 | build: 8 | name: Documentation Deployment 9 | runs-on: ubuntu-20.04 10 | steps: 11 | - uses: actions/checkout@v4 12 | - name: deploy manpages to website 13 | env: 14 | GH_TOKEN: ${{ secrets.GITLAB_DEPLOY_KEY }} 15 | run: | 16 | git config --global user.email "me@patrickwu.space" 17 | git config --global user.name "Jinming Wu, Patrick" 18 | git clone --depth 1 https://patrick:$GH_TOKEN@git.wedotstud.io/wslu/documentation website 19 | cp -f ./CODE_OF_CONDUCT.md ./website/coc.md 20 | cp -f ./CONTRIBUTING.md ./website/contributing.md 21 | git --git-dir=./website/.git --work-tree=./website add -A 22 | git --git-dir=./website/.git --work-tree=./website commit -m "Document update" 23 | git --git-dir=./website/.git --work-tree=./website push 24 | 25 | -------------------------------------------------------------------------------- /.github/workflows/manpage.yml: -------------------------------------------------------------------------------- 1 | name: Manpage Website Deployment 2 | on: 3 | push: 4 | branches: 5 | - master 6 | jobs: 7 | build: 8 | name: Manpage Generate and Deployment 9 | runs-on: ubuntu-20.04 10 | steps: 11 | - uses: actions/checkout@v4 12 | - name: Install Pre-requisites 13 | run: | 14 | sudo apt-get update -qq 15 | sudo apt-get install -qq groff 16 | - name: Convert manpages 17 | run: bash -c "for x in docs/*; do groff \$x -mandoc -Thtml > \${x%.*}.html; done" 18 | - name: deploy manpages to website 19 | env: 20 | GH_TOKEN: ${{ secrets.GITLAB_DEPLOY_KEY }} 21 | run: | 22 | git config --global user.email "me@patrickwu.space" 23 | git config --global user.name "Jinming Wu, Patrick" 24 | git clone --depth 1 https://patrick:$GH_TOKEN@git.wedotstud.io/wslu/website website 25 | bash -x extras/scripts/manpage_deploy.bash 26 | git --git-dir=./website/.git --work-tree=./website add -A 27 | git --git-dir=./website/.git --work-tree=./website commit -m "Manpage update" 28 | git --git-dir=./website/.git --work-tree=./website push 29 | 30 | -------------------------------------------------------------------------------- /.github/workflows/pkgbuild.yml: -------------------------------------------------------------------------------- 1 | name: CI/CD Dev Build Deployment 2 | on: 3 | push: 4 | branches: 5 | - dev/** 6 | - lts/** 7 | 8 | jobs: 9 | debbuild: 10 | name: Debian 11 | runs-on: ubuntu-20.04 12 | steps: 13 | - uses: actions/checkout@v4 14 | - name: Install Pre-requisites 15 | run: | 16 | sudo apt-get update -qq 17 | sudo apt-get install -qq apt-utils build-essential gzip devscripts debhelper bats 18 | - name: Build Debian Package 19 | run: | 20 | git clone https://github.com/wslutilities/wslu-debian builder 21 | cd builder/ 22 | bash ./build.sh --ci dev debian unstable 23 | cd ../ 24 | mkdir -p ./pkgs 25 | mv ../wsl*.* ./pkgs 26 | - uses: actions/upload-artifact@v4 27 | with: 28 | name: DebianDEBs 29 | path: pkgs 30 | pgwbuild: 31 | name: Pengwin 32 | runs-on: ubuntu-20.04 33 | steps: 34 | - uses: actions/checkout@v4 35 | - name: Install Pre-requisites 36 | run: | 37 | sudo apt-get update -qq 38 | sudo apt-get install -qq apt-utils build-essential gzip devscripts debhelper bats 39 | - name: Build Debian Package 40 | run: | 41 | git clone https://github.com/wslutilities/wslu-debian builder 42 | cd builder/ 43 | bash ./build.sh --ci dev pengwin 44 | cd ../ 45 | mkdir -p ./pkgs 46 | mv ../wsl*.* ./pkgs 47 | - uses: actions/upload-artifact@v4 48 | with: 49 | name: PengwinDEBs 50 | path: pkgs 51 | pgwspdeploy: 52 | name: Pengwin Deploying 53 | needs: pgwbuild 54 | runs-on: ubuntu-20.04 55 | container: cimg/ruby:2.7 56 | steps: 57 | - name: Retrive package for deployment 58 | uses: actions/download-artifact@v4 59 | with: 60 | name: PengwinDEBs 61 | path: PengwinDEBs 62 | - run: gem install package_cloud 63 | - name: deploy to the dev 64 | env: 65 | PACKAGECLOUD_TOKEN: ${{ secrets.PGW_DEV_DEPLOY_KEY }} 66 | run: package_cloud push whitewaterfoundry/wslu/debian/bullseye ./PengwinDEBs/*.deb --skip-errors 67 | rpmobsbuild: 68 | name: RPM - OpenSUSE Build Service 69 | runs-on: ubuntu-20.04 70 | steps: 71 | - uses: actions/checkout@v4 72 | - name: Install Pre-requisites 73 | run: | 74 | sudo apt-get update -qq 75 | sudo apt-get install -qq build-essential tar 76 | - name: configure 77 | run: | 78 | bash ./configure.sh --rpm obs_canary 79 | cp extras/build/rpm/obs/wslu.spec ../wslu-canary.spec 80 | rm -rf * 81 | mkdir -p SOURCES 82 | mkdir -p SPECS 83 | cp ../wslu-*.tar.gz SOURCES 84 | cp ../wslu-canary.spec SPECS 85 | - name: rpmbuild 86 | uses: ./.github/actions/rpmbuild/ 87 | - name: moving files 88 | run: | 89 | mkdir obs_res 90 | cp ../wslu-*.tar.gz obs_res 91 | cp ../wslu-canary.spec obs_res 92 | - uses: actions/upload-artifact@v4 93 | with: 94 | name: OBS_RES 95 | path: obs_res 96 | obsdeploy: 97 | name: OpenSUSE Build Service Deploying 98 | needs: rpmobsbuild 99 | runs-on: ubuntu-latest 100 | steps: 101 | - name: Retrive package for deployment 102 | uses: actions/download-artifact@v4 103 | with: 104 | name: OBS_RES 105 | path: OBS_RES 106 | - name: Install Pre-requisites 107 | run: | 108 | sudo apt-get update -qq 109 | sudo apt-get install -qq osc python3-m2crypto 110 | - name: Install API token for osc 111 | env: 112 | API_TOKEN_CONTENT: ${{ secrets.OBS_API_TOKEN }} 113 | run: | 114 | mkdir -p "$HOME/.config/osc" 115 | echo -e "[general]\napiurl = https://api.opensuse.org\n[https://api.opensuse.org]\nuser = wslutilities\npass = $API_TOKEN_CONTENT" > "$HOME/.config/osc/oscrc" 116 | - name: Uploading OBS source files 117 | run: | 118 | osc checkout home:wslutilities 119 | cp OBS_RES/* home:wslutilities/wslu-canary/ 120 | cd home:wslutilities/wslu-canary/ 121 | osc addremove 122 | osc commit -m "Build at $(date)" 123 | rpmcoprbuild: 124 | name: RPM - Cool Other Package Repo 125 | runs-on: ubuntu-20.04 126 | steps: 127 | - uses: actions/checkout@v4 128 | - name: Install Pre-requisites 129 | run: | 130 | sudo apt-get update -qq 131 | sudo apt-get install -qq build-essential tar 132 | - name: configure 133 | run: | 134 | bash ./configure.sh --rpm copr 135 | cp extras/build/rpm/copr/wslu.spec ../wslu.spec 136 | rm -rf * 137 | mkdir -p SOURCES 138 | mkdir -p SPECS 139 | cp ../wslu-*.tar.gz SOURCES 140 | cp ../wslu.spec SPECS 141 | - name: rpmbuild 142 | uses: ./.github/actions/rpmbuild/ 143 | - name: moving files 144 | run: | 145 | mkdir compiled_rpms 146 | cp SRPMS/* compiled_rpms 147 | cp RPMS/noarch/* compiled_rpms 148 | #uses: robertdebock/rpmbuild-action@1.1.1 149 | - uses: actions/upload-artifact@v4 150 | with: 151 | name: COPRRPMs 152 | path: compiled_rpms 153 | coprdeploy: 154 | name: Cool Other Package Repo Deploying 155 | needs: rpmcoprbuild 156 | container: fedora:latest 157 | runs-on: ubuntu-latest 158 | steps: 159 | - name: Retrive package for deployment 160 | uses: actions/download-artifact@v4 161 | with: 162 | name: COPRRPMs 163 | path: COPRRPMs 164 | - name: Install API token for copr-cli 165 | env: 166 | API_TOKEN_CONTENT: ${{ secrets.COPR_API_TOKEN }} 167 | run: | 168 | mkdir -p "$HOME/.config" 169 | echo "$API_TOKEN_CONTENT" > "$HOME/.config/copr" 170 | - name: Install tooling for source RPM build 171 | run: | 172 | dnf -y install @development-tools @rpm-development-tools 173 | dnf -y install copr-cli make 174 | - name: Submit the build by uploading the source RPM 175 | run: copr-cli build wslutilities/wslu-canary COPRRPMs/*.src.rpm 176 | -------------------------------------------------------------------------------- /.github/workflows/pkgdeploy.yaml: -------------------------------------------------------------------------------- 1 | name: Package Deployment 2 | on: 3 | push: 4 | tags: 5 | - v4.* 6 | - v3.* 7 | jobs: 8 | tests: 9 | uses: ./.github/workflows/tests.yaml 10 | debbuild: 11 | name: Debian 12 | runs-on: ubuntu-20.04 13 | needs: tests 14 | steps: 15 | - name: Install Pre-requisites 16 | run: | 17 | sudo apt-get update -qq 18 | sudo apt-get install -qq apt-utils build-essential gzip devscripts debhelper bats wget 19 | - name: Build Debian Package 20 | run: | 21 | git clone https://github.com/wslutilities/wslu-debian builder 22 | cd ./builder 23 | bash ./build.sh latest debian buster 24 | - uses: actions/upload-artifact@v4 25 | with: 26 | name: DebianDEBs 27 | path: builder/pkgs 28 | pgwbuild: 29 | name: Pengwin 30 | runs-on: ubuntu-20.04 31 | needs: tests 32 | steps: 33 | - name: Install Pre-requisites 34 | run: | 35 | sudo apt-get update -qq 36 | sudo apt-get install -qq apt-utils build-essential gzip devscripts debhelper bats wget 37 | - name: Build Debian Package 38 | run: | 39 | git clone https://github.com/wslutilities/wslu-debian builder 40 | cd ./builder 41 | bash ./build.sh latest pengwin 42 | - uses: actions/upload-artifact@v4 43 | with: 44 | name: PengwinDEBs 45 | path: builder/pkgs 46 | pgwspdeploy: 47 | name: Pengwin Deploying 48 | needs: pgwbuild 49 | runs-on: ubuntu-20.04 50 | container: cimg/ruby:2.7 51 | steps: 52 | - name: Retrive package for deployment 53 | uses: actions/download-artifact@v4 54 | with: 55 | name: PengwinDEBs 56 | path: PengwinDEBs 57 | - run: gem install package_cloud 58 | - name: deploy to bullseye repo 59 | env: 60 | PACKAGECLOUD_TOKEN: ${{ secrets.PGW_DEV_DEPLOY_KEY }} 61 | run: package_cloud push whitewaterfoundry/wslu/debian/bullseye ./PengwinDEBs/*.deb --skip-errors 62 | - name: deploy to bookworm 63 | env: 64 | PACKAGECLOUD_TOKEN: ${{ secrets.PGW_DEV_DEPLOY_KEY }} 65 | run: package_cloud push whitewaterfoundry/wslu/debian/bookworm ./PengwinDEBs/*.deb --skip-errors 66 | rpmobsbuild: 67 | name: RPM - OpenSUSE Build Service 68 | runs-on: ubuntu-20.04 69 | needs: tests 70 | steps: 71 | - uses: actions/checkout@v4 72 | - name: Install Pre-requisites 73 | run: | 74 | sudo apt-get update -qq 75 | sudo apt-get install -qq build-essential tar 76 | - name: configure 77 | run: | 78 | bash ./configure.sh --rpm obs 79 | cp extras/build/rpm/obs/wslu.spec ../wslu.spec 80 | rm -rf * 81 | mkdir -p SOURCES 82 | mkdir -p SPECS 83 | cp ../wslu-*.tar.gz SOURCES 84 | cp ../wslu.spec SPECS 85 | - name: rpmbuild 86 | uses: ./.github/actions/rpmbuild/ 87 | - name: moving files 88 | run: | 89 | mkdir obs_res 90 | cp ../wslu-*.tar.gz obs_res 91 | cp ../wslu.spec obs_res 92 | - uses: actions/upload-artifact@v4 93 | with: 94 | name: OBS_RES 95 | path: obs_res 96 | obsdeploy: 97 | name: OpenSUSE Build Service Deploying 98 | needs: rpmobsbuild 99 | runs-on: ubuntu-latest 100 | steps: 101 | - name: Retrive package for deployment 102 | uses: actions/download-artifact@v4 103 | with: 104 | name: OBS_RES 105 | path: OBS_RES 106 | - name: Install Pre-requisites 107 | run: | 108 | sudo apt-get update -qq 109 | sudo apt-get install -qq osc python3-m2crypto 110 | - name: Install API token for osc 111 | env: 112 | API_TOKEN_CONTENT: ${{ secrets.OBS_API_TOKEN }} 113 | run: | 114 | mkdir -p "$HOME/.config/osc" 115 | echo -e "[general]\napiurl = https://api.opensuse.org\n[https://api.opensuse.org]\nuser = wslutilities\npass = $API_TOKEN_CONTENT" > "$HOME/.config/osc/oscrc" 116 | - name: Uploading OBS source files 117 | run: | 118 | osc checkout home:wslutilities 119 | cp OBS_RES/* home:wslutilities/wslu/ 120 | cd home:wslutilities/wslu/ 121 | osc addremove 122 | osc commit -m "Build at $(date)" 123 | rpmcoprbuild: 124 | name: RPM - Cool Other Package Repo 125 | needs: tests 126 | runs-on: ubuntu-20.04 127 | steps: 128 | - uses: actions/checkout@v4 129 | - name: Install Pre-requisites 130 | run: | 131 | sudo apt-get update -qq 132 | sudo apt-get install -qq build-essential tar 133 | - name: configure 134 | run: | 135 | bash ./configure.sh --rpm copr 136 | cp extras/build/rpm/copr/wslu.spec ../wslu.spec 137 | rm -rf * 138 | mkdir -p SOURCES 139 | mkdir -p SPECS 140 | cp ../wslu-*.tar.gz SOURCES 141 | cp ../wslu.spec SPECS 142 | - name: rpmbuild 143 | uses: ./.github/actions/rpmbuild/ 144 | - name: moving files 145 | run: | 146 | mkdir compiled_rpms 147 | cp SRPMS/* compiled_rpms 148 | cp RPMS/noarch/* compiled_rpms 149 | - uses: actions/upload-artifact@v4 150 | with: 151 | name: COPRRPMs 152 | path: compiled_rpms 153 | coprdeploy: 154 | name: Cool Other Package Repo Deploying 155 | needs: rpmcoprbuild 156 | container: fedora:latest 157 | runs-on: ubuntu-latest 158 | steps: 159 | - name: Retrive package for deployment 160 | uses: actions/download-artifact@v4 161 | with: 162 | name: COPRRPMs 163 | path: COPRRPMs 164 | - name: Install API token for copr-cli 165 | env: 166 | API_TOKEN_CONTENT: ${{ secrets.COPR_API_TOKEN }} 167 | run: | 168 | mkdir -p "$HOME/.config" 169 | echo "$API_TOKEN_CONTENT" > "$HOME/.config/copr" 170 | - name: Install tooling for source RPM build 171 | run: | 172 | dnf -y install @development-tools @rpm-development-tools 173 | dnf -y install copr-cli make 174 | - name: Submit the build by uploading the source RPM 175 | run: copr-cli build wslutilities/wslu COPRRPMs/*.src.rpm 176 | -------------------------------------------------------------------------------- /.github/workflows/tests.yaml: -------------------------------------------------------------------------------- 1 | name: CI/CD tests 2 | on: 3 | push: 4 | branches: 5 | - dev/** 6 | workflow_call: 7 | jobs: 8 | sctests: 9 | name: ShellCheck Tests 10 | runs-on: ubuntu-20.04 11 | steps: 12 | - uses: actions/checkout@v4 13 | - name: Install Pre-requisites 14 | run: | 15 | sudo apt-get update -qq 16 | sudo apt-get install -qq shellcheck 17 | - name: shellcheck 18 | run: | 19 | make shellcheck 20 | codetests: 21 | name: General Tests 22 | runs-on: windows-2019 23 | needs: sctests 24 | steps: 25 | - name: Set git to use LF 26 | run: | 27 | git config --global core.autocrlf false 28 | git config --global core.eol lf 29 | - uses: actions/checkout@v4 30 | - uses: Vampire/setup-wsl@v1.2.0 31 | with: 32 | distribution: Debian 33 | update: 'true' 34 | set-as-default: 'true' 35 | additional-packages: 36 | gzip 37 | make 38 | desktop-file-utils 39 | bats 40 | x11-apps 41 | - shell: wsl-bash -u root {0} 42 | run: | 43 | make 44 | make install 45 | make test -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # built files 2 | out 3 | out-docs 4 | target 5 | 6 | # folders requird for build 7 | SOURCES 8 | SPECS 9 | SRPMS 10 | RPMS 11 | 12 | # Complied packages 13 | compiled_rpms 14 | pkgs 15 | 16 | # system files 17 | **/*/.DS_Store -------------------------------------------------------------------------------- /.shellcheckrc: -------------------------------------------------------------------------------- 1 | disable=SC1090,SC1117,SC2034,SC2154 2 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "shakram02.bash-beautify", "jetmartin.bats", "timonwong.shellcheck" 4 | ] 5 | } -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at me@patrickwu.space. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We love pull requests from everyone. By participating in this project, you agree to abide by [Code of Conduct](CODE_OF_CONDUCT.md). 4 | 5 | > **ATTENTION!** 6 | > 7 | > Built-in versions of wslu in Ubuntu are no longer supported by me. 8 | > 9 | > If you have problems, please check whther you are using the [PPA version of wslu](https://launchpad.net/~wslutilities/+archive/ubuntu/wslu). If not, please report to the Ubuntu WSL team; However, the PPA version of wslu will address most issue that come from the built-in version. 10 | 11 | ## Code contributions 12 | 13 | ### Setup 14 | 15 | Run the following to get started: 16 | ```bash 17 | git clone --recursive --branch dev/master https://github.com/wslutilities/wslu.git 18 | ./configure.sh 19 | make 20 | sudo make res_install 21 | ``` 22 | 23 | ### Structure 24 | 25 | ``` 26 | wslu 27 | |-src 28 | | |-etc 29 | | | |-wslview.desktop: XDG-style app definition for wslview 30 | | | |-wsl.ico: legacy default icon for wslusc 31 | | | |-wsl-gui.ico: default icon for wslusc GUI shortcut 32 | | | |-wsl-term.ico: default icon for wslusc cli shortcut 33 | | | |-sudo.ps1: helper script for wslgsu 34 | | | |-get_dpi.ps1: helper script for dpi function in wslsys 35 | | | |-wslsc-helper.sh: helper script for wslusc on WSL side 36 | | | \-runHidden.vbs: helper script for wslusc on Windows side 37 | | |-wslu-header: Header file of all script 38 | | \-.sh: Components of script 39 | |-tests: location for script tests 40 | \-extras 41 | |-bats: testing utility 42 | |-scripts: scripts 43 | \-build 44 | |-debian: files for building .deb 45 | |-rpm: files for building .rpm 46 | | |-copr: COPR specific files (for Fedora Only) 47 | \-obs: OBS specific files (Other RPM-based distros) 48 | |-arch: files for building Arch Linux packages 49 | \-alpine: files for building Alpine Linux packages 50 | ``` 51 | 52 | ### configure.sh 53 | 54 | `configure.sh` is the script to complete some preprocessing task for both developing and packaging building. 55 | 56 | Following parameter is available for developing: 57 | - `-e, --env` -- Environment Check, check whether it is using Fake WSL Environment, normal Linux or WSL. 58 | - `-p, --prsh` -- Check Status of `powershell.exe`. 59 | - `-P, --pkg` -- Install Needed Packages required by your system for building. 60 | 61 | Following parameter is available for package building: 62 | - `--build` -- helper to add the version to wslu header. 63 | - `--deb ` -- preprocessing script for deb packages.`` should be version code name like `bionic`, `stable`, `kali-rolling` or `buster`. 64 | - `--rpm` -- preprocessing script for rpm packages. 65 | 66 | ### Build & Install 67 | 68 | - run `make` to build executables to `out` folder and manages to `out-docs` folder. 69 | - run `make doc` to build manpage only. 70 | - run `make clean` to remove `out` and `out-docs` folder. 71 | - run `make test` to run tests. 72 | - run `make install` to install. 73 | - run `make res_install` to install just resources. 74 | - run `make uninstall` to uninstall. 75 | - run `cd extras/scripts && ./builder-docs.sh` to build docs to `gendocs`. 76 | 77 | Pass necessary environment variables if necessary. The default installation is in `/usr` folder: 78 | - `DESTDIR`: You can change the destination installation folder. It is empty by default. 79 | - `PREFIX`: You can change the prefix for where to install. It is `/usr` by default. 80 | 81 | ### Built-in Functions/Variables 82 | 83 | For contributing, there are several functions and variables built-in the header that can be used accross all utility source files. 84 | 85 | #### Variables 86 | 87 | - Base util information: 88 | - `wslu_util_fullpath` - the full path to utility 89 | - `wslu_util_name` - current utility name 90 | - `wslu_version` - wslu version, written by `VERSION` 91 | - `wslu_prefix` - the location `wslu` installed to, written by the `PREFIX` during the make. 92 | - `wslu_dest_dir` - the location `wslu` installed to, written by the `DESTDIR` during the make. 93 | - `wslu_debug` - the variable used for calling utility across. This will allow calling the `--debug` option for other `wslu` utilities inside script easier. 94 | - Formatting: `black`, `red`, `green`, `brown`, `blue`, `purple`, `cyan`, `yellow`, `white`, `dark_gray`, `light_red`, `light_green`, `light_blue`, `light_purple`, `light_cyan`, `light_gray`, `orange`, `light_orange`, `deep_purple`, `bold`, `reset` 95 | - Indicator: `info`, `input_info`, `error`, `warn` 96 | - Windows Builds: 97 | - `BN_APR_EIGHTEEN` - Windows 10 Version 1803, Redstone 4, April 2018 Update 98 | - `BN_OCT_EIGHTEEN` - Windows 10 Version 1809, Redstone 5, October 2018 Update 99 | - `BN_MAY_NINETEEN` - Windows 10 Version 1903, 19H1, May 2019 Update 100 | - `BN_NOV_NINETEEN` - Windows 10 Version 1909, 19H2, November 2019 Update 101 | - `BN_MAY_TWENTYTY` - Windows 10 Version 2004, 20H1, May 2020 Update 102 | - `BN_OCT_NINETEEN` - Windows 10 Version 20H2, Windows 10 October 2020 Update 103 | - `BN_MAY_TWNETONE` - Windows 10 Version 21H1, Windows 10 May 2021 Update 104 | - `BN_NOV_TWENTONE` - Windows 10 Version 21H2, Windows 10 November 2021 Update 105 | - `BN_ELEVEN_21H2` - Windows 11 Version 21H2 106 | 107 | #### Functions 108 | > Note: `baseexec_gen` and `var_gen` are used for headers only, thus not showing here. 109 | 110 | - `debug_echo ` 111 | 112 | Will print debug information when pass `--debug` in the utility. 113 | - `error_echo ` 114 | 115 | Will print error information and return error code. For details of the error code standard for `wslu`, please check [here](https://wslutiliti.es/wslu/faq.html#what-is-the-error-code-returned). 116 | - `help` 117 | 118 | Get help print-out. 119 | - `version` 120 | 121 | Get version print-out. 122 | - `double_dash_p` 123 | 124 | Replace the `\` to `\\` 125 | - `interop_prefix` 126 | 127 | Return the root folder for the mounted drives. 128 | - `sysdrive_prefix` 129 | 130 | Return the location of the system drive. 131 | - `wslu_get_build` 132 | 133 | Return the Windows build number. 134 | - `wslu_get_wsl_ver` 135 | 136 | Return the WSL version used for the current distribution. 137 | - `chcp_com ` 138 | 139 | Set the Codepage by calling `chcp.com` 140 | - `winps_exec ` 141 | 142 | Execute powershell commands by calling Windows PowerShell. 143 | - `cmd_exec ` 144 | 145 | Execute cmd commands by calling `cmd.exe` 146 | - `wslu_function_check ` 147 | 148 | Check whether a function exists. 149 | - `wslu_file_check ` 150 | 151 | Check whether a file exist in the corresbonding location. If not, it will copy from the source folder (`//share/wslu`). 152 | - `wslpy_check` 153 | 154 | Check whether `wslpy >= 0.1.0` is installed. 155 | 156 | ### Test 157 | 158 | `wslu` use [bats](https://github.com/bats-core/bats-core) for testing. Please refer to [its guide](https://github.com/bats-core/bats-core#writing-tests) to write tests. 159 | 160 | ### Push Requests 161 | 162 | Make sure that the codes changed are tested. 163 | 164 | Then create Pull requests [here](https://github.com/wslutilities/wslu/compare). 165 | 166 | 167 | ## Financial contributions 168 | 169 | We also welcome financial contributions in full transparency on our [open collective](https://opencollective.com/wslutilities). 170 | Anyone can file an expense. If the expense makes sense for the development of the community, it will be "merged" in the ledger of our open collective by the core contributors and the person who filed the expense will be reimbursed. 171 | 172 | ### Contributors 173 | 174 | Thank you to all the people who have already contributed to wslu! 175 | 176 | 177 | 178 | ### Backers 179 | 180 | Thank you to all our backers! [[Become a backer](https://opencollective.com/wslu#backer)] 181 | 182 | 183 | 184 | 185 | ### Sponsors 186 | 187 | Thank you to all our sponsors! (please ask your company to also support this open source project by [becoming a sponsor](https://opencollective.com/wslu#sponsor)) 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | DESTDIR ?= 3 | PREFIX ?= /usr 4 | 5 | HEADER = src/wslu-header 6 | OUTPATH = out 7 | MANPATH = docs 8 | OUTMANPATH = out-docs 9 | CURPATH = $(shell pwd) 10 | 11 | SOURCES := $(wildcard src/*.sh) 12 | ETCFILES := $(wildcard src/etc/*) 13 | OUTFILES := $(wildcard out/*) 14 | MANFILES := $(wildcard docs/*) 15 | INSTEDEXES := $(wildcard $(DESTDIR)$(PREFIX)/bin/wsl*) 16 | INSTEDMANOS := $(wildcard $(DESTDIR)$(PREFIX)/share/man/man1/wsl*) 17 | 18 | DATETMP = $(shell date +%Y-%m-%d) 19 | VERTMP = $(shell cat ./VERSION) 20 | 21 | all: doc 22 | [ -d $(OUTPATH) ] || mkdir $(OUTPATH) 23 | sed -e 's/VERSIONPLACEHOLDER/'$(VERTMP)'/' -e 's|PREFIXPLACEHOLDER|'$(PREFIX)'|' -e 's|DESTDIRPLACEHOLDER|'$(DESTDIR)'|' $(HEADER) > $(HEADER).tmp; \ 24 | for file in $(SOURCES); do \ 25 | cat $(HEADER).tmp $$file > $(OUTPATH)/`basename $$file`; \ 26 | mv $(OUTPATH)/`basename $$file` $(OUTPATH)/`basename $$file .sh`; \ 27 | done 28 | rm $(HEADER).tmp 29 | chmod +x $(OUTPATH)/* 30 | 31 | install: doc_install res_install conf_install 32 | install -Dm 755 out/* -t $(DESTDIR)$(PREFIX)/bin 33 | 34 | uninstall: 35 | for f in $(INSTEDEXES); do \ 36 | if [ `basename $$f` != "wslpath" ] && [ `basename $$f` != "wslinfo" ]; then \ 37 | rm -f $$f; \ 38 | fi; \ 39 | done 40 | for f in $(INSTEDMANOS); do \ 41 | rm -f $$f; \ 42 | done 43 | rm -rf $(DESTDIR)$(PREFIX)/share/man/man7/wslu.7.gz 44 | rm -rf $(DESTDIR)$(PREFIX)/share/wslu 45 | rm -f $(DESTDIR)$(PREFIX)/share/applications/wslview.desktop 46 | 47 | doc: 48 | [ -d $(OUTMANPATH) ] || mkdir $(OUTMANPATH) 49 | for file in $(MANFILES); do \ 50 | cp $$file $(OUTMANPATH); \ 51 | sed -e 's/DATEPLACEHOLDER/'$(DATETMP)'/' -e 's/VERSIONPLACEHOLDER/'$(VERTMP)'/' $(OUTMANPATH)/`basename $$file` > $(OUTMANPATH)/`basename $$file`.tmp; \ 52 | mv $(OUTMANPATH)/`basename $$file`.tmp $(OUTMANPATH)/`basename $$file`; \ 53 | gzip -f -q $(OUTMANPATH)/`basename $$file`; \ 54 | done 55 | 56 | doc_install: 57 | install -Dm 644 out-docs/*.1.gz -t $(DESTDIR)$(PREFIX)/share/man/man1 58 | install -Dm 644 out-docs/*.7.gz -t $(DESTDIR)$(PREFIX)/share/man/man7 59 | 60 | res_install: 61 | install -Dm 644 src/etc/*.vbs -t $(DESTDIR)$(PREFIX)/share/wslu 62 | install -Dm 644 src/etc/*.ps1 -t $(DESTDIR)$(PREFIX)/share/wslu 63 | install -Dm 644 src/etc/*.ico -t $(DESTDIR)$(PREFIX)/share/wslu 64 | install -Dm 755 src/etc/*.sh -t $(DESTDIR)$(PREFIX)/share/wslu 65 | install -Dm 644 src/etc/wslview.desktop -t $(DESTDIR)$(PREFIX)/share/applications 66 | install -Dm 644 src/etc/conf $(DESTDIR)$(PREFIX)/share/wslu 67 | 68 | conf_install: 69 | install -Dm 644 src/etc/user/conf -t $(DESTDIR)/etc/wslu 70 | 71 | clean: 72 | rm -rf $(OUTPATH) 73 | rm -rf $(OUTMANPATH) 74 | 75 | test: 76 | bats -r tests 77 | 78 | shellcheck: 79 | shellcheck -P src/* 80 | 81 | coverage: 82 | kcov --include-path="./src,./out" ./tests/coverage bats -r tests 83 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | # wslu - A collection of utilities for WSL 6 | 7 | [![GitHub license](https://img.shields.io/github/license/wslutilities/wslu?style=flat-square&label=license&color=blue&logo=github)](https://github.com/wslutilities/wslu/blob/master/LICENSE) 8 | [![GitHub (pre-)release](https://img.shields.io/github/v/release/wslutilities/wslu?include_prereleases&logo=github&style=flat-square)](https://github.com/wslutilities/wslu) 9 | [![Mastodon Follow](https://img.shields.io/mastodon/follow/108802672885079993?color=6364FF&domain=https%3A%2F%2Ffosstodon.org&label=follow&logo=mastodon&logoColor=6364FF&style=flat-square)](https://fosstodon.org/@wslutilities) 10 | 11 |
12 | 13 | > [!IMPORTANT] 14 | > The project is being discontinued. 15 | 16 | > **ATTENTION!** 17 | > 18 | > Built-in versions of wslu in Ubuntu are no longer supported by me. 19 | > 20 | > If you have problems, please check whther you are using the [PPA version of wslu](https://launchpad.net/~wslutilities/+archive/ubuntu/wslu). If not, please report to the Ubuntu WSL team; However, the PPA version of wslu will address most issue that come from the built-in version. 21 | 22 | This is a collection of utilities for the Windows Subsystem for Linux (WSL), such as converting Linux paths to Windows paths or creating Linux application shortcuts on the Windows Desktop. 23 | 24 | - Requires at least Windows 10 Creators Update; 25 | - Some of the features require a higher version of Windows; 26 | - Supports WSL2; 27 | - Supports Windows 11. 28 | 29 | | | English | 简体中文 | 正體中文 | Esperanto | 30 | | ------------ | ------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | --------------------------------------------------- | 31 | | General | [Visit](https://wslutiliti.es/wslu/) | [Visit](https://wslutiliti.es/wslu/zh-CN/) | [Visit](https://wslutiliti.es/wslu/zh-TW/) | [Visit](https://wslutiliti.es/wslu/eo/) | 32 | | Installation | [Visit](https://wslutiliti.es/wslu/install.html) | [Visit](https://wslutiliti.es/wslu/zh-CN/install.html) | [Visit](https://wslutiliti.es/wslu/zh-TW/install.html) | [Visit](https://wslutiliti.es/wslu/eo/install.html) | 33 | 34 | ## Contributors 35 | 36 | This project exists thanks to all the people who contribute. [ [Contribute](CONTRIBUTING.md) ]. 37 | 38 | 39 | ## License & Credits 40 | 41 | 42 | 43 | This project uses [GPLv3](LICENSE) License. 44 | 45 | Logo of WSL Utilities and icons for `wslusc` desktop shortcuts are licensed under [CC BY 4.0 International License](http://creativecommons.org/licenses/by/4.0/). 46 | 47 | For other third-party files and assets used, please refer to [THIRD_PARTY_LICENSE](THIRD_PARTY_LICENSE). 48 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 4.1.4-1 2 | -------------------------------------------------------------------------------- /configure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #shellcheck disable=SC2198,SC2124,SC2002,SC1001,SC2164,SC2072,SC2086,SC2035 3 | # configure.sh 4 | # configure script for wslu 5 | # 6 | # Copyright (C) 2019 Patrick Wu 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 3 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | function env_check { 22 | if [ -f /etc/fake-wsl-release ] 23 | then 24 | echo "[fake WSL Environment]" 25 | elif [ ! -f /proc/sys/fs/binfmt_misc/WSLInterop ] && [ ! -f /proc/sys/fs/binfmt_misc/WSLInterop-late ] 26 | then 27 | echo "Your distro do not support WSL Interopability. Installation Aborted." 28 | exit 1 29 | fi 30 | } 31 | 32 | function pkg_inst { 33 | distro="$(head -n1 /etc/os-release | sed -e 's/NAME=\"//g')" 34 | case $distro in 35 | *Pengwin*) 36 | sudo dpkg --force-depends --remove wslu 37 | sudo apt install -y git gzip make shellcheck bats 38 | ;; 39 | *WLinux*|Ubuntu*|*Debian*|*Kali*) 40 | sudo apt purge -y wslu 41 | sudo apt install -y git bc gzip make imagemagick shellcheck bats 42 | ;; 43 | openSUSE*|SLES*) 44 | sudo zypper -n rm wslu 45 | sudo zypper -n install git bc gzip make imagemagick ShellCheck 46 | ;; 47 | Alpine*) 48 | sudo apk add git bc gzip make bash-completion imagemagick 49 | ;; 50 | Arch*) 51 | sudo pacman -Syyu git bc gzip make bash-completion imagemagick shellcheck iproute2 --noconfirm 52 | ;; 53 | *Oracle*|Scientific*) 54 | sudo yum install -y git bc gzip make bash-completion imagemagick iproute ShellCheck 55 | ;; 56 | Alma*) 57 | sudo yum install -y git bc gzip make bash-completion ImageMagick iproute ShellCheck 58 | ;; 59 | *Fedora*) 60 | sudo dnf install -y git bc gzip make bash-completion ImageMagick ShellCheck 61 | ;; 62 | *Gentoo*) 63 | sudo emerge -a n sys-devel/bc media-gfx/imagemagick app-shells/bash-completion sys-devel/make dev-vcs/git app-arch/gzip dev-util/shellcheck 64 | ;; 65 | *Generic*) [ "fedora" == "$(grep -e "LIKE=" /etc/os-release | sed -e 's/ID_LIKE=//g')" ] && sudo dnf install -y git bc gzip make bash-completion ImageMagick ShellCheck || exit 1;; 66 | *) exit 1;; 67 | esac 68 | } 69 | 70 | function general_build_prep { 71 | sed -i s/VERSIONPLACEHOLDER/"$(cat ./VERSION)"/g ./src/wslu-header 72 | } 73 | 74 | function deb_build_prep { 75 | mkdir -p ./debian 76 | cp -r ./extras/build/debian/* ./debian 77 | chmod +x ./debian/rules 78 | sed -i s/DISTROPLACEHOLDER/"$*"/g ./debian/changelog 79 | sed -i s/VERSIONPLACEHOLDER/"$(cat ./VERSION)"/g ./debian/changelog 80 | sed -i s/DATETIMEPLACEHOLDER/"$(date +'%a, %d %b %Y %T %z')"/g ./debian/changelog 81 | } 82 | 83 | function rpm_build_prep { 84 | BUILD_VER_NUM=$(cat ./VERSION | cut -f1 -d-) 85 | REL_VER_NUM=$(cat ./VERSION | cut -f2 -d-) 86 | is_canary="" 87 | if [ "$@" = "obs_canary" ]; then 88 | FOR_BUILD="obs" 89 | is_canary="-canary" 90 | else 91 | FOR_BUILD="$@" 92 | fi 93 | 94 | sed -i s/BUILDVERPLACEHOLDER/"$BUILD_VER_NUM"/g ./extras/build/rpm/"$FOR_BUILD"/wslu.spec 95 | sed -i s/RELVERPLACEHOLDER/"$REL_VER_NUM"/g ./extras/build/rpm/"$FOR_BUILD"/wslu.spec 96 | sed -i s/DATETIMEPLACEHOLDER/"$(date +'%a %b %d %Y')"/g ./extras/build/rpm/"$FOR_BUILD"/wslu.spec 97 | sed -i s/Name\:\ wslu/Name\:\ wslu$is_canary/g ./extras/build/rpm/"$FOR_BUILD"/wslu.spec 98 | sed -i s/^Source\:\ wslu/Source\:\ wslu$is_canary/g ./extras/build/rpm/"$FOR_BUILD"/wslu.spec 99 | mkdir -p ../wslu$is_canary-$BUILD_VER_NUM/ 100 | cp -r * ../wslu$is_canary-$BUILD_VER_NUM/ 101 | cd ../ 102 | tar -czvf wslu$is_canary-$BUILD_VER_NUM.tar.gz ./wslu$is_canary-$BUILD_VER_NUM 103 | cd ./wslu 104 | } 105 | 106 | for args; do 107 | case $args in 108 | --build) general_build_prep; exit;; 109 | --rpm) rpm_build_prep $2; exit;; 110 | --deb) deb_build_prep $2; exit;; 111 | -e|--env) env_check; exit;; 112 | -P|--pkg) pkg_inst; exit;; 113 | *) exit 1;; 114 | esac 115 | done 116 | 117 | env_check; pkg_inst 118 | -------------------------------------------------------------------------------- /docs/wslact.1: -------------------------------------------------------------------------------- 1 | .TH "WSLACT" "1" "DATEPLACEHOLDER" "VERSIONPLACEHOLDER" "WSL Utilities User Manual" 2 | .SH NAME 3 | .B wslact 4 | - Component of WSL Utilities 5 | .SH SYNOPSIS 6 | .B wslact 7 | .RB COMMAND 8 | .I ... 9 | .SH DESCRIPTION 10 | A set of quick actions for WSL such as creating startup tasks and manually sync time between Windows and WSL. 11 | .PP 12 | Currently, we have two features available: 13 | .in +4n 14 | .nf 15 | \fBts, time-sync\fR \- Time Sync 16 | \fBam, auto-mount\fR \- Auto Mounting 17 | \fBmr, memory-reclaim\fR \- Memory Reclamation 18 | .fi 19 | .in 20 | .SH COMMANDS 21 | .SS "Time Sync" 22 | Time Sync (\fItime-sync\fR) feature allows user to manually sync time from Windows to WSL. Sometime, when you have network issues, WSL time will be slower than the Windows time. This tool is designed for this situation. Requires sudo. 23 | .TP 24 | SYNOPSIS 25 | .B wslact time-sync 26 | .RB [ \-h ] 27 | .TP 28 | OPTIONS 29 | .nf 30 | .B -h, --help 31 | .in +4n 32 | print a simple help. 33 | .in 34 | .fi 35 | .SS "Auto Mounting" 36 | Auto Mounting (\fIauto-mount\fR) feature allows you to mount all drives available on Windows to WSL. Requires sudo. 37 | .TP 38 | SYNOPSIS 39 | .B wslact auto-mount 40 | .RB [ \-mh ] 41 | .TP 42 | OPTIONS 43 | .nf 44 | .B -m, --mount-options 45 | .in +4n 46 | pass a list of options you want to pass to \fImount\fR command. 47 | .in 48 | .fi 49 | .nf 50 | .B -h, --help 51 | .in +4n 52 | print a simple help. 53 | .in 54 | .fi 55 | .SS "Memory Reclamation" 56 | Memory Reclamation (\fImemory-reclaim\fR) feature allows you to reclaim memory by dropping memory cache. Requires sudo. 57 | .TP 58 | SYNOPSIS 59 | .B wslact memory-reclaim 60 | .RB [ \-h ] 61 | .TP 62 | OPTIONS 63 | .nf 64 | .B -h, --help 65 | .in +4n 66 | print a simple help. 67 | .in 68 | .fi 69 | .SH OPTIONS 70 | .TP 71 | .B -h, --help 72 | print a simple help. 73 | .TP 74 | .B -v, --version 75 | print current version. 76 | .SH AUTHOR 77 | Created by Patrick Wu 78 | .SH REPORTING BUGS 79 | Report bugs to ; 80 | For Ubuntu specific/related bugs, report to . 81 | .SH COPYRIGHT 82 | This is free software; you can redistribute it and/or modify it under 83 | the terms of the GNU GPL version 3 or (at your option) any later 84 | version. 85 | There is NO warranty; not even MERCHANTABILITY or FITNESS FOR A 86 | PARTICULAR PURPOSE. 87 | .SH SEE ALSO 88 | wslu(7) -------------------------------------------------------------------------------- /docs/wslclip.1: -------------------------------------------------------------------------------- 1 | .TH "WSLCLIP" "1" "DATEPLACEHOLDER" "VERSIONPLACEHOLDER" "WSL Utilities User Manual" 2 | .SH NAME 3 | .B wslgsu 4 | - Component of WSL Utilities 5 | .SH SYNOSIS 6 | .B wslclip 7 | .RB [ \-hvg ] 8 | .PP 9 | .B wslclip 10 | .I CONTENT 11 | .SH DESCRIPTION 12 | This tool allows you to get or set clipboard content on Windows without X/wayland support. 13 | .SH OPTIONS 14 | .TP 15 | .B -h, --help 16 | Print a simple help. 17 | .TP 18 | .B -v, --version 19 | Print current version. 20 | .TP 21 | .B -g, --get 22 | Get clipboard content from Windows. 23 | .SH AUTHOR 24 | Created by Patrick Wu 25 | .SH REPORTING BUGS 26 | Report bugs to 27 | .SH COPYRIGHT 28 | This is free software; you can redistribute it and/or modify it under 29 | the terms of the GNU GPL version 3 or (at your option) any later 30 | version. 31 | There is NO warranty; not even MERCHANTABILITY or FITNESS FOR A 32 | PARTICULAR PURPOSE. 33 | .SH SEE ALSO 34 | wslu(7) 35 | -------------------------------------------------------------------------------- /docs/wslfetch.1: -------------------------------------------------------------------------------- 1 | .TH "WSLFETCH" "1" "DATEPLACEHOLDER" "VERSIONPLACEHOLDER" "WSL Utilities User Manual" 2 | .SH NAME 3 | .B wslfetch 4 | - Component of WSL Utilities 5 | .SH SYNOPSIS 6 | .B wslfetch 7 | .RB [ \-hvcg ] 8 | .RB [ \-t 9 | .IR THEME ] 10 | .RB [ \-o 11 | .IR OPTIONS ] 12 | .SH DESCRIPTION 13 | This is a WSL Screenshot Information Tool to print information in a elegant way. 14 | .SH OPTIONS 15 | .TP 16 | .B -h, --help 17 | print a simple help. 18 | .TP 19 | .B -v, --version 20 | print current version. 21 | .TP 22 | .B -c, --colorbar 23 | add a colorbar to the printed information. This can also be set with the configuration \fIWSLFETCH_COLORBAR\fR. 24 | .TP 25 | .B -g, --generic 26 | Force to print information with generic WSL logo. 27 | .TP 28 | .B -t, --theme \fITHEME\fR 29 | set a custom theme from the file \fITHEME\fR. This can also be set with the configuration \fIWSLFETCH_THEME_PATH\fR. 30 | .TP 31 | .B -o, --options \fIOPTIONS\fR 32 | set custom options from the file \fIOPTIONS\fR. Please refer to the WSLFETCH_INFO_SECTION in the CONFIGURATION section for more information. 33 | .SH CONFIGURATION 34 | .TP 35 | .B WSLFETCH_INFO_SECTION 36 | the sections of info from wslsys to show in wslfetch. the following are all the available options: 37 | .nf 38 | .in +4n 39 | windows-install-date 40 | windows-rel-branch 41 | windows-build 42 | windows-full-build 43 | display-scaling 44 | windows-locale 45 | windows-theme 46 | windows-uptime 47 | wsl-uptime 48 | wsl-release 49 | wsl-kernel 50 | wsl-package-count 51 | wsl-ip 52 | .in 53 | .TP 54 | \'wsl-version\' will be always ignored since it is builtin in wslfetch. The default value is "windows-build,windows-rel-branch,wsl-release,wsl-kernel,windows-uptime". 55 | .fi 56 | .TP 57 | .B WSLFETCH_THEME_PATH 58 | This allows you to use your own customized theme. 59 | .TP 60 | .B WSLFETCH_COLORBAR 61 | whether you want to display colorbar in wslfetch. This will override \`\-c, \-\-colorbar\` param. 62 | .SH AUTHOR 63 | Created by Patrick Wu 64 | .SH REPORTING BUGS 65 | Report bugs to ; 66 | For Ubuntu specific/related bugs, report to . 67 | .SH COPYRIGHT 68 | This is free software; you can redistribute it and/or modify it under 69 | the terms of the GNU GPL version 3 or (at your option) any later 70 | version. 71 | There is NO warranty; not even MERCHANTABILITY or FITNESS FOR A 72 | PARTICULAR PURPOSE. 73 | .SH SEE ALSO 74 | wslsys(1), wslu(7) -------------------------------------------------------------------------------- /docs/wslgsu.1: -------------------------------------------------------------------------------- 1 | .TH "WSLGSU" "1" "DATEPLACEHOLDER" "VERSIONPLACEHOLDER" "WSL Utilities User Manual" 2 | .SH NAME 3 | .B wslgsu 4 | - Component of WSL Utilities 5 | .SH SYNOSIS 6 | .B wslgsu 7 | .RB [ \-u 8 | .IR USERNAME ] 9 | .RB [ \-n 10 | .IR NAME ] 11 | .RB [ \-S ] 12 | .PP 13 | .B wslgsu 14 | .RB [ \-hv ] 15 | .I SERVICE/COMMAND 16 | .SH DESCRIPTION 17 | This tool allows you to generate a WSL startup Task using the Windows Task Scheduler. 18 | .SH OPTIONS 19 | .TP 20 | .B -h, --help 21 | Print a simple help. 22 | .TP 23 | .B -v, --version 24 | Print current version. 25 | .TP 26 | .B -u, --username \fIUSERNAME\fR 27 | Use a separate user to execute the command/service. By default it's \fIroot\fR. 28 | .TP 29 | .B -n, --name \fINAME\fR 30 | Add an explicit name instead of the default of automatically extracting a name from the service/command. 31 | .TP 32 | .B -S, --service 33 | Using this option means you are addng a system service. without \fB-S\fR, you are adding a command to system. 34 | .SH AUTHOR 35 | Created by Patrick Wu 36 | .SH REPORTING BUGS 37 | Report bugs to 38 | .SH COPYRIGHT 39 | This is free software; you can redistribute it and/or modify it under 40 | the terms of the GNU GPL version 3 or (at your option) any later 41 | version. 42 | There is NO warranty; not even MERCHANTABILITY or FITNESS FOR A 43 | PARTICULAR PURPOSE. 44 | .SH SEE ALSO 45 | wslu(7) 46 | -------------------------------------------------------------------------------- /docs/wslsys.1: -------------------------------------------------------------------------------- 1 | .TH "WSLSYS" "1" "DATEPLACEHOLDER" "VERSIONPLACEHOLDER" "WSL Utilities User Manual" 2 | .SH NAME 3 | .B wslsys 4 | - Component of WSL Utilities 5 | .SH SYNOSIS 6 | .B wslsys 7 | .RB [ \-VIbBFUWRKPSltT ] 8 | .RB [ \-s ] 9 | .PP 10 | .B wslsys 11 | .RB [ \-hv ] 12 | .RB [ \-n 13 | .IR NAME ] 14 | .SH DESCRIPTION 15 | This is a WSL system information printer to print out some basic system 16 | information. 17 | .SH OPTIONS 18 | .PP 19 | Executing command without options will print out the all system information. 20 | add \fB-s\fR flag to print only value: 21 | .TP 22 | .B -h, --help 23 | Print a simple help. 24 | .TP 25 | .B -v, --version 26 | Print current version. 27 | .TP 28 | .B -n \fBNAME\fR 29 | Print the system information of \fBNAME\fR. 30 | .TP 31 | .B -V, --wsl-version 32 | Print the the WSL version your current distribution is using. 33 | For example, \fB"1"\fR for using WSL 1st generation. 34 | .TP 35 | .B -I, --sys-installdate 36 | Print the time when the current release is installed. The format is in Hex Unix Timestamp. 37 | For example, \fB"0x5df84068"\fR. 38 | .TP 39 | .B -b, --branch 40 | Print current release branch of your Windows 10. 41 | For example, \fB"rs_prerelease"\fR means you are on rs_prerelease release branch. 42 | .TP 43 | .B -B, --build 44 | Print current build version of your Windows 10. 45 | For example, \fB"19536"\fR means you are using Winows 10 build 19536. 46 | .TP 47 | .B -F, --full-build 48 | Print current build version of your Windows 10 in long form. 49 | For example, \fB"19536.1000.amd64fre.rs_prerelease.191211-1446"\fR. 50 | .TP 51 | .B -U, --uptime 52 | Print current uptime inside WSL. 53 | For example, \fB"0d 0h 2m"\fR. 54 | .TP 55 | .B -W, --win-uptime 56 | Print current uptime in Windows 10. 57 | For example, \fB"0d 12h 8m"\fR. 58 | .TP 59 | .B -R, --release 60 | Print the current release for your WSL distro. 61 | For example, \fB"Ubuntu 18.04.3 LTS"\fR. 62 | .TP 63 | .B -K, --kernel 64 | Print the current version of the WSL kernel. 65 | For example, \fB"Linux 4.19.81-microsoft-standard"\fR. 66 | .TP 67 | .B -P, --package 68 | Print total number of installed packages. 69 | For example, \fB"1047"\fR for 1047 packages installed. 70 | .TP 71 | .B -i, --ip 72 | Print the current IPv4 address for your WSL distro. 73 | For example, \fB"127.37.41.23"\fR. 74 | .TP 75 | .B -S, --display-scaling 76 | Print the current display scaling from your display setting. 77 | For example, \fB"2"\fR for 200% scaling. 78 | .TP 79 | .B -l, --locale 80 | Print the Windows locale information. 81 | For example, \fB"en-US"\fR for English (United States). 82 | .TP 83 | .B -t, --win-theme 84 | Print the Windows Theme. 85 | For example, \fB"light"\fR. 86 | .TP 87 | .B -T, --win-system-type 88 | Print whether the system is running in Windows Desktop, Windows Server, or Windows Domain Controller. 89 | For example, \fB"Server"\fR. 90 | .TP 91 | .B -d, --systemd-status 92 | Print the status of systemd in WSL. 93 | .SH AUTHOR 94 | Created by Patrick Wu 95 | .SH REPORTING BUGS 96 | Report bugs to ; 97 | For Ubuntu specific/related bugs, report to . 98 | .SH COPYRIGHT 99 | This is free software; you can redistribute it and/or modify it under 100 | the terms of the GNU GPL version 3 or (at your option) any later 101 | version. 102 | There is NO warranty; not even MERCHANTABILITY or FITNESS FOR A 103 | PARTICULAR PURPOSE. 104 | .SH SEE ALSO 105 | wslu(7) 106 | -------------------------------------------------------------------------------- /docs/wslu.7: -------------------------------------------------------------------------------- 1 | .TH "WSLU" "7" "DATEPLACEHOLDER" "VERSIONPLACEHOLDER" "WSL Utilities User Manual" 2 | .SH NAME 3 | .B wslu 4 | A collection of utilities for the Windows Subsystem for Linux 5 | .SH DESCRIPTION 6 | This is a collection of utilities for the Windows Subsystem for Linux (WSL), such as converting Linux paths to Windows paths or creating Linux application shortcuts on the Windows Desktop. 7 | .PP 8 | Requires Windows 10 Creators Update and higher. 9 | .SH AVAILABLE COMMANDS 10 | wslusc, wslsys, wslfetch, wslvar, wslview(wview/wslstart/wstart), wslupath(deprecated), wslact, wslclip, wslgsu 11 | .PP 12 | check each manpage to see the detailed usage. 13 | .SH SUPPORTED DISTRIBUTION 14 | .nf 15 | - Debian GNU/Linux 16 | - Kali Linux 17 | - OpenSUSE Leap 42, 12.0 and 15.0 18 | - SUSE Linux Enterprise Server 12 and 15 19 | - Ubuntu Latest, 16.04 LTS, 18.04 LTS and 20.04 LTS 20 | - Pengwin (Formerly WLinux) 21 | .fi 22 | .SS 23 | .B Community Supported Distro 24 | .nf 25 | - Arch Linux via ArchWSL 26 | - Alpine Linux via AlpineWSL or Alpine WSL 27 | - Scientific Linux, Oracle Linux* or RedHat Enterprise Linux** via Pengwin Enterprise (Formerly WLinux Enterprise) 28 | - Fedora via Fedora Remix for WSL 29 | - Gentoo Linux via GentooWSL 30 | - Void Linux via VoidWSL 31 | - Clear Linux via ClearWSL 32 | 33 | .B *: Will support in the future. 34 | .B **: you need to request to using RHEL from Pengwin team and have a license of RHEL of your own. 35 | .fi 36 | .PP 37 | > Legacy Ubuntu is no longer supported. 38 | .SH OPTIONS 39 | All WSL Utilities command shared a common header. the following option are available to all commands. 40 | .TP 41 | .B --debug 42 | Entering debug mode. 43 | .TP 44 | .B --verbose 45 | Entering verbose mode. 46 | .SH CONFIGURATION 47 | .TP 48 | The default configuration is stored in /usr/share/wslu/conf. You can override the default configuration in \'/etc/wslu/conf\', \'/etc/wslu/custom.conf\', \'$HOME/.config/wslu/conf\', or \'$HOME/.wslurc\'. They will be read in the direction they are listed. 49 | .SH EXIT STATUS 50 | .TP 51 | .B 1 52 | general error/unknown error. 53 | .TP 54 | .B 20 55 | input is empty or invalid. 56 | .TP 57 | .B 21 58 | input is empty. 59 | .TP 60 | .B 22 61 | input is invalid. 62 | .TP 63 | .B 30 64 | file do not exist. 65 | .TP 66 | .B 31 67 | folder do not exist. 68 | .TP 69 | .B 32 70 | feature not implemented. 71 | .TP 72 | .B 33 73 | required component do not exist. 74 | .TP 75 | .B 34 76 | unsupported feature (for a distro) 77 | .TP 78 | .B 35 79 | unsupported feature (for your Windows 10 build) 80 | .TP 81 | .B 40 82 | Unknown system input. 83 | .SH CONFIGURATION 84 | .TP 85 | .B WSLVIEW_DEFAULT_ENGINE 86 | control whether to enable the chcp workaround for powershell. By default it is true; if you encounter any PowerShell issues, you can try to disable it. 87 | .SH BUG 88 | Report bugs to ; 89 | For Ubuntu specific bugs, report to . 90 | .SH COPYRIGHT 91 | This is free software; you can redistribute it and/or modify it under the terms of the GNU GPL version 3 or (at your option) any later version. There is NO warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 92 | 93 | Logo of WSL Utilities and wslusc icons is licensed under CC BY 4.0 International License. 94 | 95 | For third-party license, please refer to . 96 | -------------------------------------------------------------------------------- /docs/wslupath.1: -------------------------------------------------------------------------------- 1 | .TH "WSLUPATH" "1" "DATEPLACEHOLDER" "VERSIONPLACEHOLDER" "WSL Utilities" 2 | .SH NAME 3 | wslupath(DEPRECATED) - Component of WSL Utilities 4 | .SH SYNOPSIS 5 | .B wslupath 6 | .RB [ \-dOr ] 7 | .RB [\-D|\-A|\-T|\-S|\-W|\-s|\-su|\-H|\-P|\|\.\|\.\|\.NAME\|\.\|\.\|\.]\fR 8 | .PP 9 | \Bwslupath 10 | .RB [\-h|\-v|\-R] 11 | .SH DESCRIPTION 12 | This is a WSL Windows path Converter that can convert Windows path to other styles of path\. 13 | .SH COMMANDS 14 | .SS Output Type Options 15 | Without a type, it will detect path style automatically. 16 | .TP 17 | .B -O, --original 18 | print original (Windows) form of path(C:\eWindows\eSystem32) 19 | .TP 20 | .B -d, --doubledash-dir 21 | print Windows form of path with double backslash(C:\e\eWindows\e\eSystem32) 22 | .TP 23 | .B -r, --reg-data 24 | use the registry data to print path[wslpath \-R to know more] 25 | .SS System Path 26 | .B -D, --desktop 27 | print desktop path and exit 28 | .TP 29 | .B -A, --appdata 30 | print AppData path(%APPDATA%) and exit 31 | .TP 32 | .B -T, --temp 33 | print temp path(%TMP%) and exit 34 | .TP 35 | .B -S, --sysdir 36 | print system path and exit 37 | .TP 38 | .B -W, --windir 39 | print Windows path and exit 40 | .TP 41 | .B -s, --start-menu 42 | print Start Menu path and exit 43 | .TP 44 | .B -su, --startup 45 | print Startup path and exit 46 | .TP 47 | .B -H, --home 48 | print user home path (%HOMEPATH%) and exit 49 | .TP 50 | .B -P, --program-files 51 | print Program Files path (%ProgramFiles%) and exit 52 | .SS Other Options 53 | .TP 54 | .B -h, --help 55 | print a simple help 56 | .TP 57 | .B -v, --version 58 | print current version 59 | .TP 60 | .B -R, --avail-reg 61 | print available registry input 62 | .SH AUTHOR 63 | Created by Patrick Wu 64 | .SH REPORTING BUGS 65 | Report bugs to ; 66 | For Ubuntu specific/related bugs, report to . 67 | .PP 68 | .B However, keep in mind this tool is deprecated and bugs reported for this tool will have a high chance to be ignored. 69 | .SH COPYRIGHT 70 | This is free software; you can redistribute it and/or modify it under 71 | the terms of the GNU GPL version 3 or (at your option) any later 72 | version. 73 | There is NO warranty; not even MERCHANTABILITY or FITNESS FOR A 74 | PARTICULAR PURPOSE. 75 | .SH SEE ALSO 76 | wslvar(1), wslu(7) -------------------------------------------------------------------------------- /docs/wslusc.1: -------------------------------------------------------------------------------- 1 | .TH "WSLUSC" "1" "DATEPLACEHOLDER" "VERSIONPLACEHOLDER" "WSL Utilities User Manual" 2 | .SH NAME 3 | .B wslusc 4 | - Component of WSL Utilities 5 | .SH SYNOPSIS 6 | .B wslusc 7 | .RB [ \-IsgN ] 8 | .RB [ \-d 9 | .IR SHORTCUT_FILE ] 10 | .RB [ \-e 11 | .IR PATH ] 12 | .RB [ \-n 13 | .IR NAME ] 14 | .RB [ \-i 15 | .IR FILE ] 16 | .I COMMAND 17 | .PP 18 | .B wslusc 19 | .RB [ \-hv ] 20 | .SH DESCRIPTION 21 | This is a WSL shortcut creator to create shortcut on Windows Desktop. 22 | .SH OPTIONS 23 | .TP 24 | .B -h, --help 25 | print a simple help 26 | .TP 27 | .B -v, --version 28 | print current version 29 | .TP 30 | .B -d, --shortcut-debug \fISHORTCUT_FILE\fR 31 | debug the generated shortcut file. 32 | .TP 33 | .B -g, --gui 34 | create a shortcut that links to a GUI application. 35 | .TP 36 | .B -N, --native 37 | create a shortcut that uses the system builtin \'wslg.exe\' to launch the GUI application. 38 | .TP 39 | .B -i, --icon 40 | add an icon to the Windows Shortcut. Supports \fB\.ico\fR/\fB\.png\fR/\fB\.svg\fR\. 41 | .TP 42 | .B -s, --smart-icon 43 | This enables the smart icon detection. This feature requires \'wslpy\' to be installed. 44 | .TP 45 | .B -n, --name 46 | add a different name other than the command name. 47 | .TP 48 | .B -e, --env 49 | add a custom environment to your command. For example, if you want HiDPI support for a GTK app, add \fBexport GDK_SCALE=2;\fR in your command, like this: \fBwslusc ... \-e "export GDK_SCALE=2;" ...\fR 50 | .TP 51 | .B -I, --interactive 52 | interactive mode. 53 | .SH CONFIGURATION 54 | .TP 55 | .B WSLUSC_GUITYPE 56 | Default GUI type. Default type is 'legacy'. Use 'native' for Native GUI generation (wslg.exe) by default. 57 | .TP 58 | .B WSLUSC_SMART_ICON_DETECTION 59 | Smart Icon Detection. Requires wslpy (Requires Python 3.5). default is \'false\'. 60 | .TP 61 | .B WSLUSC_BASE_CONVERTER_ENGINE 62 | Converter engine. You can choose either 'ffmpeg' or 'imagemagick'. By default it is 'imagemagick'. 63 | .SH AUTHOR 64 | Created by Patrick Wu 65 | .SH REPORTING BUGS 66 | Report bugs to ; 67 | For Ubuntu specific/related bugs, report to . 68 | .SH COPYRIGHT 69 | This is free software; you can redistribute it and/or modify it under 70 | the terms of the GNU GPL version 3 or (at your option) any later 71 | version. 72 | There is NO warranty; not even MERCHANTABILITY or FITNESS FOR A 73 | PARTICULAR PURPOSE. 74 | .SH SEE ALSO 75 | wslu(7) -------------------------------------------------------------------------------- /docs/wslvar.1: -------------------------------------------------------------------------------- 1 | .TH "WSLVAR" "1" "DATEPLACEHOLDER" "VERSIONPLACEHOLDER" "WSL Utilities User Manual" 2 | .SH NAME 3 | .B wslvar 4 | - Component of WSL Utilities 5 | .SH SYNOPSIS 6 | .B wslvar 7 | .RB [ \-sl ] 8 | .I NAME 9 | .PP 10 | .B wslvar 11 | .RB [\-hvSL ] 12 | .SH DESCRIPTION 13 | This is a WSL tool to help you get Windows system environment variables. 14 | .SH OPTIONS 15 | .SS "Output Type Options" 16 | .B -s, --sys 17 | use data from system local & global variables. 18 | .TP 19 | .B -l, --shell 20 | use data from Shell folder environment variables. 21 | .SS "Other Options" 22 | .TP 23 | .B -h, --help 24 | print a simple help. 25 | .TP 26 | .B -v, --version 27 | print current version. 28 | .TP 29 | .B -S, --getsys 30 | show available system local & global variables. 31 | .TP 32 | .B -L, --getshell 33 | show available Shell folder environment variables. 34 | .SH CONFIGURATION 35 | .TP 36 | .B WSLVAR_DEFAULT_VARTYPE 37 | Default Type of variable to get when not specifying option. Default type is 1. Here are the available Types: 38 | .nf 39 | .in +4 40 | 1: User Shell Folders 41 | 2: Windows Environment Variables 42 | .in 43 | .fi 44 | .SH AUTHOR 45 | Created by Patrick Wu 46 | .SH REPORTING BUGS 47 | Report bugs to ; 48 | For Ubuntu specific/related bugs, report to . 49 | .SH COPYRIGHT 50 | This is free software; you can redistribute it and/or modify it under 51 | the terms of the GNU GPL version 3 or (at your option) any later 52 | version. 53 | There is NO warranty; not even MERCHANTABILITY or FITNESS FOR A 54 | PARTICULAR PURPOSE. 55 | .SH SEE ALSO 56 | wslu(7) -------------------------------------------------------------------------------- /docs/wslview.1: -------------------------------------------------------------------------------- 1 | 2 | .TH "WSLVIEW" "1" "DATEPLACEHOLDER" "VERSIONPLACEHOLDER" "WSL Utilities User Manual" 3 | .SH NAME 4 | .B wslview, wview, wslstart, wstart 5 | - Component of WSL Utilities 6 | .SH SYNOPSIS 7 | .B wslview, wview, wslstart, wstart 8 | .RB [ \-ehsvurE ] 9 | .PP 10 | .B wslview, wview, wslstart, wstart 11 | .I LINK/FILE 12 | .SH DESCRIPTION 13 | This is a file viewer on WSL that allows you to open files and folders from WSL in Windows and a fake web browser that allows opening urls in your default browser on Windows 10. 14 | .SH OPTIONS 15 | .TP 16 | .B -h, --help 17 | print a simple help. 18 | .TP 19 | .B -v, --version 20 | print current version. 21 | .TP 22 | .B -s, --skip-validation-check 23 | skip url validation check. 24 | .TP 25 | .B -u, --unreg-as-browser 26 | remove \fBwslview\fR as the default WSL web browser. 27 | .TP 28 | .B -r, --reg-as-browser 29 | register \fBwslview\fR as the default WSL web browser. 30 | .TP 31 | .B -e, --export-as-browser 32 | register \fBwslview\fR as the default WSL web browser using export method. 33 | .SH CONFIGURATION 34 | .TP 35 | .B WSLVIEW_DEFAULT_ENGINE 36 | default method to start websites/folders/files. Default type is "powershell". Here are all available options: 37 | .nf 38 | .in +4 39 | powershell: use powershell.exe to start website/folder/file 40 | cmd: use cmd.exe to start website/folder/file 41 | cmd_explorer: use explorer.exe via cmd.exe to start website/folder/file 42 | .in 43 | .fi 44 | .TP 45 | .B WSLVIEW_SKIP_VALIDATION_CHECK 46 | whether to skip validation check. Default is 1, which is not skipping. Can be either `0` or `1`. 47 | .SH AUTHOR 48 | Created by Patrick Wu 49 | .SH REPORTING BUGS 50 | Report bugs to ; 51 | For Ubuntu specific/related bugs, report to . 52 | .SH COPYRIGHT 53 | This is free software; you can redistribute it and/or modify it under 54 | the terms of the GNU GPL version 3 or (at your option) any later 55 | version. 56 | There is NO warranty; not even MERCHANTABILITY or FITNESS FOR A 57 | PARTICULAR PURPOSE. 58 | .SH SEE ALSO 59 | wslu(7) -------------------------------------------------------------------------------- /extras/build/alpine/APKBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Patrick Wu 2 | # Contributor: Patrick Wu 3 | pkgname=wslu 4 | pkgver=4.1.0 5 | pkgrel=0 6 | pkgdesc="A collection of utilities for the Windows Subsystem for Linux" 7 | url="https://github.com/wslutilities/wslu" 8 | arch="noarch" 9 | license="GPL-3.0-or-later" 10 | depends="bc bash-completion grep psmisc" #the builtin grep have issues with wslu 11 | subpackages="$pkgname-doc" 12 | source="$pkgname-$pkgver.tar.gz::https://github.com/wslutilities/wslu/archive/v$pkgver.tar.gz" 13 | options="!check" #tests can be only be run on WSL(Windows Subsystems for Linux) version of Alpine Linux environment, hence disabled 14 | 15 | build() { 16 | make 17 | } 18 | 19 | check() { 20 | make test 21 | } 22 | 23 | package() { 24 | make DESTDIR="$pkgdir" install 25 | } 26 | 27 | sha512sums="" 28 | -------------------------------------------------------------------------------- /extras/build/alpine/wslu.post-install: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | date +"%s" | tee /usr/share/wslu/updated_time >/dev/null 4 | 5 | exit 0 6 | -------------------------------------------------------------------------------- /extras/build/alpine/wslu.post-upgrade: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | date +"%s" | tee /usr/share/wslu/updated_time >/dev/null 4 | 5 | exit 0 6 | -------------------------------------------------------------------------------- /extras/build/alpine/wslu.pre-deinstall: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm /usr/share/wslu/updated_time -------------------------------------------------------------------------------- /extras/build/arch/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Patrick Wu 2 | 3 | pkgname=wslu 4 | pkgver=4.1.0 5 | pkgrel=0 6 | pkgdesc="A collection of utilities for the Windows Subsystem for Linux" 7 | arch=('any') 8 | url='https://github.com/wslutilities/wslu' 9 | license=('GPL-3.0-or-later') 10 | depends=('bc' 'bash-completion' 'psmisc') 11 | optdepends=('imagemagick: custom icon support') 12 | source=("git+https://github.com/wslutilities/wslu.git#tag=v${pkgver}") 13 | sha256sums=('SKIP') 14 | 15 | build() { 16 | cd wslu 17 | bash ./configure.sh --build 18 | make 19 | } 20 | 21 | package() { 22 | cd wslu 23 | make DESTDIR="${pkgdir}" install 24 | install -Dm 644 LICENSE -t "${pkgdir}"/usr/share/licenses/wslu/ 25 | } 26 | 27 | # vim: ts=2 sw=2 et: 28 | -------------------------------------------------------------------------------- /extras/build/arch/wslu.install: -------------------------------------------------------------------------------- 1 | # This is a default template for a post-install scriptlet. 2 | # Uncomment only required functions and remove any functions 3 | # you don't need (and this header). 4 | 5 | ## arg 1: the new package version 6 | #pre_install() { 7 | # do something here 8 | #} 9 | 10 | ## arg 1: the new package version 11 | post_install() { 12 | date +"%s" | tee /usr/share/wslu/updated_time >/dev/null 13 | } 14 | 15 | ## arg 1: the new package version 16 | ## arg 2: the old package version 17 | #pre_upgrade() { 18 | # do something here 19 | #} 20 | 21 | ## arg 1: the new package version 22 | ## arg 2: the old package version 23 | post_upgrade() { 24 | date +"%s" | tee /usr/share/wslu/updated_time >/dev/null 25 | } 26 | 27 | ## arg 1: the old package version 28 | pre_remove() { 29 | # do something here 30 | rm /usr/share/wslu/updated_time 31 | } 32 | 33 | ## arg 1: the old package version 34 | #post_remove() { 35 | # do something here 36 | #} -------------------------------------------------------------------------------- /extras/build/rpm/copr/wslu.spec: -------------------------------------------------------------------------------- 1 | %define packager Jinming Wu, Patrick 2 | Summary: A collection of utilities for the Windows Subsystem for Linux 3 | Name: wslu 4 | Version: BUILDVERPLACEHOLDER 5 | Release: RELVERPLACEHOLDER 6 | Source: wslu-BUILDVERPLACEHOLDER.tar.gz 7 | BuildArch: noarch 8 | Requires(pre,preun): desktop-file-utils 9 | BuildRequires: make gzip 10 | Requires: bc psmisc 11 | Requires(post): %{_sbindir}/update-alternatives %{_bindir}/update-desktop-database %{_bindir}/desktop-file-install 12 | Requires(postun): %{_sbindir}/update-alternatives %{_bindir}/update-desktop-database 13 | BuildRoot: %{_tmppath}/%{name}-%{version}-build 14 | URL: https://github.com/wslutilities/wslu/ 15 | License: GPL-3.0-or-later 16 | 17 | %description 18 | This is a collection of utilities for Windows 10 Linux Subsystem, such as converting WSL path to Windows path or creating your favorite linux app shortcuts on Windows 10 Desktop. Requires Windows 10 Creators Update and higher. 19 | 20 | %prep 21 | %setup -q 22 | 23 | %build 24 | make 25 | 26 | %install 27 | # for os <= 7 28 | mkdir -p %{?buildroot}/usr/share/man/man1/ 29 | mkdir -p %{?buildroot}/usr/share/man/man7/ 30 | mkdir -p %{?buildroot}/usr/share/applications/ 31 | mkdir -p %{?buildroot}/usr/share/wslu/ 32 | mkdir -p %{?buildroot}/usr/bin/ 33 | mkdir -p %{?buildroot}/etc/wslu/ 34 | # normal part 35 | make PREFIX=/usr DESTDIR=%{?buildroot} install 36 | ln -sf /usr/bin/wslview %{?buildroot}/usr/bin/wview 37 | ln -sf /usr/bin/wslview %{?buildroot}/usr/bin/wslstart 38 | ln -sf /usr/bin/wslview %{?buildroot}/usr/bin/wstart 39 | ln -sf /usr/share/man/man1/wslview.1.gz %{?buildroot}/usr/share/man/man1/wview.1.gz 40 | ln -sf /usr/share/man/man1/wslview.1.gz %{?buildroot}/usr/share/man/man1/wslstart.1.gz 41 | ln -sf /usr/share/man/man1/wslview.1.gz %{?buildroot}/usr/share/man/man1/wstart.1.gz 42 | 43 | %post 44 | %{_sbindir}/update-alternatives --install %{_bindir}/www-browser www-browser %{_bindir}/wslview 1 45 | %{_sbindir}/update-alternatives --install %{_bindir}/x-www-browser x-www-browser %{_bindir}/wslview 1 46 | date +"%s" | tee /usr/share/wslu/updated_time >/dev/null 47 | desktop-file-install --dir=/usr/share/applications /usr/share/wslu/wslview.desktop 48 | update-desktop-database 49 | 50 | %postun 51 | if [ -f /usr/share/wslu/updated_time ]; then 52 | rm /usr/share/wslu/updated_time 53 | fi 54 | if [ -f /usr/share/applications/wslview.desktop ]; then 55 | rm /usr/share/applications/wslview.desktop 56 | update-desktop-database 57 | fi 58 | %{_sbindir}/update-alternatives --remove www-browser %{_bindir}/wslview 59 | %{_sbindir}/update-alternatives --remove x-www-browser %{_bindir}/wslview 60 | 61 | %clean 62 | rm -rf $RPM_BUILD_ROOT 63 | 64 | %files 65 | %defattr(-,root,root) 66 | %{_bindir}/wslusc 67 | %{_bindir}/wslfetch 68 | %{_bindir}/wslsys 69 | %{_bindir}/wslupath 70 | %{_bindir}/wslview 71 | %{_bindir}/wview 72 | %{_bindir}/wstart 73 | %{_bindir}/wslstart 74 | %{_bindir}/wslact 75 | %{_bindir}/wslvar 76 | %{_bindir}/wslgsu 77 | %{_bindir}/wslclip 78 | /usr/share/wslu/ 79 | /usr/share/applications/ 80 | /etc/wslu 81 | %doc /usr/share/man/ 82 | 83 | %changelog 84 | * DATETIMEPLACEHOLDER Jinming Wu, Patrick - BUILDVERPLACEHOLDER-RELVERPLACEHOLDER 85 | - Please check https://github.com/wslutilities/wslu/releases/latest for changelog 86 | 87 | -------------------------------------------------------------------------------- /extras/build/rpm/obs/wslu.spec: -------------------------------------------------------------------------------- 1 | %define packager Jinming Wu, Patrick 2 | Summary: A collection of utilities for the Windows Subsystem for Linux 3 | Name: wslu 4 | Version: BUILDVERPLACEHOLDER 5 | Release: RELVERPLACEHOLDER 6 | Source: wslu-BUILDVERPLACEHOLDER.tar.gz 7 | BuildArch: noarch 8 | PreReq: desktop-file-utils 9 | BuildRequires: make gzip 10 | Requires: bc psmisc 11 | Requires(post): %{_sbindir}/update-alternatives %{_bindir}/update-desktop-database %{_bindir}/desktop-file-install 12 | Requires(postun): %{_sbindir}/update-alternatives %{_bindir}/update-desktop-database 13 | BuildRoot: %{_tmppath}/%{name}-%{version}-build 14 | URL: https://github.com/wslutilities/wslu/ 15 | License: GPL-3.0-or-later 16 | 17 | %description 18 | This is a collection of utilities for Windows 10 Linux Subsystem, such as converting WSL path to Windows path or creating your favorite linux app shortcuts on Windows 10 Desktop. Requires Windows 10 Creators Update and higher. 19 | 20 | %prep 21 | %setup -q 22 | 23 | %build 24 | make 25 | 26 | %install 27 | # for os <= 7 28 | mkdir -p %{?buildroot}/usr/share/man/man1/ 29 | mkdir -p %{?buildroot}/usr/share/man/man7/ 30 | mkdir -p %{?buildroot}/usr/share/applications/ 31 | mkdir -p %{?buildroot}/usr/share/wslu/ 32 | mkdir -p %{?buildroot}/usr/bin/ 33 | mkdir -p %{?buildroot}/etc/wslu/ 34 | # normal part 35 | make PREFIX=/usr DESTDIR=%{?buildroot} install 36 | ln -sf /usr/bin/wslview %{?buildroot}/usr/bin/wview 37 | ln -sf /usr/bin/wslview %{?buildroot}/usr/bin/wslstart 38 | ln -sf /usr/bin/wslview %{?buildroot}/usr/bin/wstart 39 | ln -sf /usr/share/man/man1/wslview.1.gz %{?buildroot}/usr/share/man/man1/wview.1.gz 40 | ln -sf /usr/share/man/man1/wslview.1.gz %{?buildroot}/usr/share/man/man1/wslstart.1.gz 41 | ln -sf /usr/share/man/man1/wslview.1.gz %{?buildroot}/usr/share/man/man1/wstart.1.gz 42 | 43 | %post 44 | %{_sbindir}/update-alternatives --install %{_bindir}/www-browser www-browser %{_bindir}/wslview 1 45 | %{_sbindir}/update-alternatives --install %{_bindir}/x-www-browser x-www-browser %{_bindir}/wslview 1 46 | date +"%s" | tee /usr/share/wslu/updated_time >/dev/null 47 | desktop-file-install --dir=/usr/share/applications /usr/share/wslu/wslview.desktop 48 | update-desktop-database 49 | 50 | %postun 51 | if [ -f /usr/share/wslu/updated_time ]; then 52 | rm /usr/share/wslu/updated_time 53 | fi 54 | if [ -f /usr/share/applications/wslview.desktop ]; then 55 | rm /usr/share/applications/wslview.desktop 56 | update-desktop-database 57 | fi 58 | %{_sbindir}/update-alternatives --remove www-browser %{_bindir}/wslview 59 | %{_sbindir}/update-alternatives --remove x-www-browser %{_bindir}/wslview 60 | 61 | %clean 62 | rm -rf $RPM_BUILD_ROOT 63 | 64 | %files 65 | %defattr(-,root,root) 66 | %{_bindir}/wslusc 67 | %{_bindir}/wslfetch 68 | %{_bindir}/wslsys 69 | %{_bindir}/wslupath 70 | %{_bindir}/wslview 71 | %{_bindir}/wview 72 | %{_bindir}/wstart 73 | %{_bindir}/wslstart 74 | %{_bindir}/wslact 75 | %{_bindir}/wslgsu 76 | %{_bindir}/wslvar 77 | %{_bindir}/wslclip 78 | /usr/share/wslu/ 79 | /usr/share/applications/ 80 | /etc/wslu/ 81 | %doc /usr/share/man/ 82 | 83 | %changelog 84 | * DATETIMEPLACEHOLDER Jinming Wu, Patrick - BUILDVERPLACEHOLDER-RELVERPLACEHOLDER 85 | - Please check https://github.com/wslutilities/wslu/releases/latest for changelog 86 | 87 | -------------------------------------------------------------------------------- /extras/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wslutilities/wslu/1bb1b53c0532394a1433b2eaa041b1c1e6ce0b69/extras/icon.png -------------------------------------------------------------------------------- /extras/scripts/manpage_deploy.bash: -------------------------------------------------------------------------------- 1 | mkdir -p ./website/wslu/man/ 2 | wslu_ver="$(cat ./VERSION)" 3 | if [ ! -d "./website/wslu/man/${wslu_ver}" ] ; then 4 | mkdir ./website/wslu/man/${wslu_ver} 5 | cp ./docs/*.html ./website/wslu/man/${wslu_ver} 6 | rm -f ./website/wslu/man/*.html 7 | for f in $(ls -d ./website/wslu/man/${wslu_ver}/*.html); do 8 | fname="${f##*/}" 9 | ln -s ./${wslu_ver}/${fname} ./website/wslu/man/${fname} 10 | done 11 | fi 12 | -------------------------------------------------------------------------------- /extras/scripts/wslu-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # install 3 | # install script for wslu 4 | # 5 | # Copyright (C) 2019 Patrick Wu 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | BUILD_DIR=`mktemp --tmpdir --directory wslu-install.XXXX` 20 | distro="$(cat /etc/os-release | head -n1 | sed -e 's/NAME=\"//g')" 21 | case $distro in 22 | *WLinux*|Ubuntu*|*Debian*|*Kali*) sudo apt install -y git;; 23 | openSUSE*|SLES*) sudo zypper -n install git;; 24 | Alpine*) sudo apk add git;; 25 | Arch*) sudo pacman -Syyu git --noconfirm;; 26 | Scientific*) sudo yum install -y git;; 27 | *Fedora*|*Rocky*) sudo dnf install -y git;; 28 | *Gentoo*) sudo emerge -a n dev-vcs/git;; 29 | *Generic*) [ "fedora" == "$(cat /etc/os-release | grep -e "LIKE=" | sed -e 's/ID_LIKE=//g')" ] && sudo dnf install -y git || exit 1;; 30 | *) exit 1;; 31 | esac 32 | git clone https://github.com/wslutilities/wslu $BUILD_DIR 33 | cd $BUILD_DIR 34 | bash configure.sh 35 | make 36 | sudo make install 37 | sudo install -m755 extras/scripts/wslu-uninstall /usr/bin 38 | rm -rf $BUILD_DIR 39 | echo -e "\e[32m## wslu installation complete. To uninstall, run 'wslu-uninstall'\033(B\033[m" 40 | -------------------------------------------------------------------------------- /extras/scripts/wslu-uninstall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # wslu-uninstall 4 | # uninstall script for wslu 5 | # 6 | # Copyright (C) 2019 Patrick Wu 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 3 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | for f in /usr/bin/wsl*; do 22 | sudo rm -f $f; 23 | done 24 | 25 | for f in /usr/share/man/man1/wsl*; do 26 | sudo rm -f $f; 27 | done 28 | 29 | sudo rm -f /usr/share/man/man7/wsl* 30 | sudo rm -rf /usr/share/wslu 31 | echo -e "\e[32m## wslu uninstallation complete.\033(B\033[m" -------------------------------------------------------------------------------- /src/etc/conf: -------------------------------------------------------------------------------- 1 | # wslu - Windows 10 linux Subsystem Utility 2 | # conf - default configuration of wslu 3 | ## DO NOT MODIFY THIS FILE! 4 | ## please copy this file to custom.conf and modify in custom.conf 5 | 6 | # 7 | # 2022, Patrick Wu 8 | # 9 | # This program is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | # wslu: control whether to enable the chcp workaround for powershell. 23 | # By default it is true; if you encounter any PowerShell issues, you can try to disable it. 24 | WSLU_POWERSHELL_CHCP_WORKAROUND=true 25 | 26 | # wslfetch: the sections of info from wslsys to show in wslfetch. 27 | # Available options: 28 | # windows-install-date 29 | # windows-rel-branch 30 | # windows-build 31 | # windows-full-build 32 | # display-scaling 33 | # windows-locale 34 | # windows-theme 35 | # windows-uptime 36 | # wsl-uptime 37 | # wsl-release 38 | # wsl-kernel 39 | # wsl-package-count 40 | # wsl-ip 41 | # wsl-systemd-status 42 | # 'wsl-version' will be always ignored since it is builtin in wslfetch. 43 | WSLFETCH_INFO_SECTION="windows-build,windows-rel-branch,wsl-release,wsl-kernel,windows-uptime" 44 | 45 | # wslfetch: whether you want to display colorbar in wslfetch. This will override `-c/--colorbar` param. 46 | WSLFETCH_COLORBAR=false 47 | 48 | # wslfetch: This allows you to use your own customized theme. 49 | WSLFETCH_THEME_PATH= 50 | 51 | # wslusc: Default GUI type. Default type is 'legacy'. Use 'native' for Native GUI generation by default 52 | WSLUSC_GUITYPE="legacy" 53 | 54 | # wslusc: Smart Icon Detection. Requires wslpy (Requires Python 3.5). 55 | WSLUSC_SMART_ICON_DETECTION=false 56 | 57 | # wslusc: Converter engine. You can choose either `ffmpeg` or `imagemagick`. By default it is `imagemagick`. 58 | # - `ffmpeg` engine supports .png and .svg; However, svg support is usually not included by default; 59 | # - `imagemagick` engine supports .png, .svg, .ico, and .xpm. 60 | WSLUSC_BASE_CONVERTER_ENGINE=imagemagick 61 | 62 | # wslvar: Default Type of variable to get when not specifying option. Default type is 1. 63 | # Available Types: 64 | # 1: User Shell Folders 65 | # 2: Windows Environment Variables 66 | WSLVAR_DEFAULT_VARTYPE=1 67 | 68 | # wslview: default method to start websites/folders/files. Default type is "powershell". 69 | # Available options: 70 | # powershell: use powershell.exe to start website/folder/file 71 | # cmd: use cmd.exe to start website/folder/file 72 | # cmd_explorer: use explorer.exe via cmd.exe to start website/folder/file 73 | WSLVIEW_DEFAULT_ENGINE="powershell" 74 | 75 | # wslview: whether to skip validation check. Default is 1, which is not skipping. Can be either `0` or `1`. 76 | WSLVIEW_SKIP_VALIDATION_CHECK=1 -------------------------------------------------------------------------------- /src/etc/get_dpi.ps1: -------------------------------------------------------------------------------- 1 | # Credit: Peter Hinchley via https://hinchley.net/articles/get-the-scaling-rate-of-a-display-using-powershell/ 2 | Add-Type @' 3 | using System; 4 | using System.Runtime.InteropServices; 5 | using System.Drawing; 6 | 7 | public class DPI { 8 | [DllImport("gdi32.dll")] 9 | static extern int GetDeviceCaps(IntPtr hdc, int nIndex); 10 | 11 | public enum DeviceCap { 12 | VERTRES = 10, 13 | DESKTOPVERTRES = 117 14 | } 15 | 16 | public static float scaling() { 17 | Graphics g = Graphics.FromHwnd(IntPtr.Zero); 18 | IntPtr desktop = g.GetHdc(); 19 | int LogicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.VERTRES); 20 | int PhysicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES); 21 | 22 | return (float)PhysicalScreenHeight / (float)LogicalScreenHeight; 23 | } 24 | } 25 | '@ -ReferencedAssemblies 'System.Drawing.dll' 26 | 27 | [Math]::round([DPI]::scaling(), 2) * 100 -------------------------------------------------------------------------------- /src/etc/runHidden.vbs: -------------------------------------------------------------------------------- 1 | ' Method provided by Tobias J by https://superuser.com/questions/140047/how-to-run-a-batch-file-without-launching-a-command-window 2 | If WScript.Arguments.Count >= 1 Then 3 | ReDim arr(WScript.Arguments.Count-1) 4 | For i = 0 To WScript.Arguments.Count-1 5 | Arg = WScript.Arguments(i) 6 | If InStr(Arg, " ") > 0 Then Arg = """" & Arg & """" 7 | arr(i) = Arg 8 | Next 9 | 10 | RunCmd = Join(arr) 11 | CreateObject("Wscript.Shell").Run RunCmd, 0, True 12 | End If -------------------------------------------------------------------------------- /src/etc/sudo.ps1: -------------------------------------------------------------------------------- 1 | Set-StrictMode -Off; 2 | 3 | if(!$args) { "usage: sudo "; exit 1 } 4 | 5 | function is_admin { 6 | return ([System.Security.Principal.WindowsIdentity]::GetCurrent().UserClaims | ? { $_.Value -eq 'S-1-5-32-544'}) 7 | } 8 | 9 | function sudo_do($parent_pid, $dir, $cmd) { 10 | $src = 'using System.Runtime.InteropServices; 11 | public class Kernel { 12 | [DllImport("kernel32.dll", SetLastError = true)] 13 | public static extern bool AttachConsole(uint dwProcessId); 14 | 15 | [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)] 16 | public static extern bool FreeConsole(); 17 | }' 18 | 19 | $kernel = add-type $src -passthru 20 | 21 | $kernel::freeconsole() 22 | $kernel::attachconsole($parent_pid) 23 | 24 | $p = new-object diagnostics.process; $start = $p.startinfo 25 | $start.filename = "powershell.exe" 26 | $start.arguments = "-noprofile $cmd`nexit `$lastexitcode" 27 | $start.useshellexecute = $false 28 | $start.workingdirectory = $dir 29 | $p.start() 30 | $p.waitforexit() 31 | return $p.exitcode 32 | } 33 | 34 | function serialize($a, $escape) { 35 | if($a -is [string] -and $a -match '\s') { return "'$a'" } 36 | if($a -is [array]) { 37 | return $a | % { (serialize $_ $escape) -join ', ' } 38 | } 39 | if($escape) { return $a -replace '[>&]', '`$0' } 40 | return $a 41 | } 42 | 43 | if($args[0] -eq '-do') { 44 | $null, $dir, $parent_pid, $cmd = $args 45 | $exit_code = sudo_do $parent_pid $dir (serialize $cmd) 46 | exit $exit_code 47 | } 48 | 49 | if(!(is_admin)) { 50 | [console]::error.writeline("sudo: you must be an administrator to run sudo") 51 | exit 1 52 | } 53 | 54 | $a = if ($args[0] -eq '-please' -or $args[0] -eq '-plz') { 55 | Get-History -Count 1 | select -ExpandProperty CommandLine 56 | } else { 57 | serialize $args $true 58 | } 59 | 60 | $wd = serialize (convert-path $pwd) # convert-path in case pwd is a PSDrive 61 | 62 | $savetitle = $host.ui.rawui.windowtitle 63 | $p = new-object diagnostics.process; $start = $p.startinfo 64 | $start.filename = "powershell.exe" 65 | $start.arguments = "-noprofile & '$pscommandpath' -do $wd $pid $a`nexit `$lastexitcode" 66 | $start.verb = 'runas' 67 | $start.windowstyle = 'hidden' 68 | try { $null = $p.start() } 69 | catch { exit 1 } # user didn't provide consent 70 | $p.waitforexit() 71 | $host.ui.rawui.windowtitle = $savetitle 72 | 73 | exit $p.exitcode 74 | -------------------------------------------------------------------------------- /src/etc/user/conf: -------------------------------------------------------------------------------- 1 | # This program is free software: you can redistribute it and/or modify 2 | # it under the terms of the GNU General Public License as published by 3 | # the Free Software Foundation, either version 3 of the License, or 4 | # (at your option) any later version. 5 | # 6 | # This program is distributed in the hope that it will be useful, 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | # GNU General Public License for more details. 10 | # 11 | # You should have received a copy of the GNU General Public License 12 | # along with this program. If not, see . 13 | 14 | # wslu: control whether to enable the chcp workaround for powershell. 15 | # By default it is true; if you encounter any PowerShell issues, you can try to disable it. 16 | # WSLU_POWERSHELL_CHCP_WORKAROUND=true 17 | 18 | # wslfetch: the sections of info from wslsys to show in wslfetch. 19 | # Available options: 20 | # windows-install-date 21 | # windows-rel-branch 22 | # windows-build 23 | # windows-full-build 24 | # display-scaling 25 | # windows-locale 26 | # windows-theme 27 | # windows-uptime 28 | # wsl-uptime 29 | # wsl-release 30 | # wsl-kernel 31 | # wsl-package-count 32 | # wsl-ip 33 | # wsl-systemd-status 34 | # 'wsl-version' will be always ignored since it is builtin in wslfetch. 35 | # WSLFETCH_INFO_SECTION="windows-build,windows-rel-branch,wsl-release,wsl-kernel,windows-uptime" 36 | 37 | # wslfetch: whether you want to display colorbar in wslfetch. This will override `-c/--colorbar` param. 38 | # WSLFETCH_COLORBAR=false 39 | 40 | # wslfetch: This allows you to use your own customized theme. 41 | # WSLFETCH_THEME_PATH= 42 | 43 | # wslusc: Default GUI type. Default type is 'legacy'. Use 'native' for Native GUI generation by default 44 | # WSLUSC_GUITYPE="legacy" 45 | 46 | # wslusc: Smart Icon Detection. Requires wslpy (Requires Python 3.5). 47 | # WSLUSC_SMART_ICON_DETECTION=false 48 | 49 | # wslusc: Converter engine. You can choose either `ffmpeg` or `imagemagick`. By default it is `imagemagick`. 50 | # - `ffmpeg` engine supports .png and .svg; However, svg support is usually not included by default; 51 | # - `imagemagick` engine supports .png, .svg, .ico, and .xpm. 52 | # WSLUSC_BASE_CONVERTER_ENGINE=imagemagick 53 | 54 | # wslvar: Default Type of variable to get when not specifying option. Default type is 1. 55 | # Available Types: 56 | # 1: User Shell Folders 57 | # 2: Windows Environment Variables 58 | # WSLVAR_DEFAULT_VARTYPE=1 59 | 60 | # wslview: default method to start websites/folders/files. Default type is "powershell". 61 | # Available options: 62 | # powershell: use powershell.exe to start website/folder/file 63 | # cmd: use cmd.exe to start website/folder/file 64 | # cmd_explorer: use explorer.exe via cmd.exe to start website/folder/file 65 | # WSLVIEW_DEFAULT_ENGINE="powershell" 66 | 67 | # wslview: whether to skip validation check. Default is 1, which is not skipping. Can be either `0` or `1`. 68 | # WSLVIEW_SKIP_VALIDATION_CHECK=1 -------------------------------------------------------------------------------- /src/etc/wsl-gui.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wslutilities/wslu/1bb1b53c0532394a1433b2eaa041b1c1e6ce0b69/src/etc/wsl-gui.ico -------------------------------------------------------------------------------- /src/etc/wsl-term.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wslutilities/wslu/1bb1b53c0532394a1433b2eaa041b1c1e6ce0b69/src/etc/wsl-term.ico -------------------------------------------------------------------------------- /src/etc/wsl.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wslutilities/wslu/1bb1b53c0532394a1433b2eaa041b1c1e6ce0b69/src/etc/wsl.ico -------------------------------------------------------------------------------- /src/etc/wslusc-helper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # wslusc-helper.sh 4 | # WSL Environment Control for WSL Shortcut Generator 5 | # 6 | # Copyright (C) 2019 Patrick Wu 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 3 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | if [[ -n $WSL_INTEROP ]]; then 22 | # enable external x display for WSL 2 23 | wsl2_d_tmp="$(grep nameserver /etc/resolv.conf | awk '{print $2}')" 24 | export DISPLAY=${wsl2_d_tmp}:0 25 | 26 | unset wsl2_d_tmp 27 | else 28 | export DISPLAY=:0 29 | fi 30 | 31 | win_sys_scaling=$(wslsys -S -s) 32 | export GDK_SCALE=$win_sys_scaling 33 | export QT_SCALE_FACTOR=$win_sys_scaling 34 | export GDK_DPI_SCALE=1 35 | 36 | [ "$1" = "--no-cmd-mode" ] && exit 0 37 | cd ~ || exit 38 | bash -l -c "$*" -------------------------------------------------------------------------------- /src/etc/wslview.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=WSLView 3 | Comment=Open files and addresses in Windows 4 | Icon=windows 5 | Exec=/usr/bin/wslview %U 6 | Terminal=false 7 | Type=Application 8 | Categories=Utility; 9 | MimeType=x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/file 10 | -------------------------------------------------------------------------------- /src/wslact.sh: -------------------------------------------------------------------------------- 1 | # shellcheck shell=bash 2 | help_short="wslact COMMAND ..." 3 | 4 | function time_reset { 5 | local help_short="wslact time-reset [-h]" 6 | 7 | while [ "$1" != "" ]; do 8 | case "$1" in 9 | -h|--help) help "wslact" "$help_short"; exit;; 10 | *) shift;; 11 | esac 12 | done 13 | 14 | if [ "$EUID" -ne 0 ]; then 15 | error_echo "\`wslact time-sync\` requires you to run as root. Aborted." 1 16 | fi 17 | 18 | echo "${info} Before Sync: $(date +"%d %b %Y %T %Z")" 19 | if date -s "$(winps_exec "Get-Date -UFormat \"%m/%d/%Y %T %Z\"" | tr -d "\r")" >/dev/null; then 20 | echo "${info} After Sync: $(date +"%d %b %Y %T %Z")" 21 | echo "${info} Manual Time Reset Complete." 22 | else 23 | error_echo "Time Sync failed." 1 24 | fi 25 | } 26 | 27 | function auto_mount { 28 | local help_short="wslact auto-mount [-mh]" 29 | mntpt_prefix="$(interop_prefix)" 30 | sysdrv_prefix="$(sysdrive_prefix)" 31 | 32 | mount_opt="" 33 | while [ "$1" != "" ]; do 34 | case "$1" in 35 | -m|--mount-options) shift; mount_opt="$1"; shift;; 36 | -h|--help) help "wslact" "$help_short"; exit;; 37 | *) shift;; 38 | esac 39 | done 40 | 41 | if [ "$EUID" -ne 0 ]; then 42 | error_echo "\`wslact auto-mount\` requires you to run as root. Aborted." 1 43 | fi 44 | 45 | #shellcheck disable=SC1003 46 | drive_list="$("$mntpt_prefix$sysdrv_prefix"/WINDOWS/system32/fsutil.exe fsinfo drives | tail -1 | tr '[:upper:]' '[:lower:]' | tr -d ':\\' | sed -e 's/drives //g' -e "s|$sysdrv_prefix ||g" -e 's|\r||g' -e 's| $||g' -e 's| |\n|g')" 47 | 48 | if [ -n "$mount_opt" ]; then 49 | echo "${info} Custom mount option detected: $mount_opt" 50 | elif [ -f /etc/wsl.conf ]; then 51 | tmp="$(grep ^options /etc/wsl.conf | sed -r -e 's|^options[ ]+=[ ]+||g' -e 's|^"||g' -e 's|"$||g')" 52 | if [ "$tmp" != "" ]; then 53 | echo "${info} Custom mount option detected: $tmp" 54 | mount_opt="$tmp" 55 | unset tmp 56 | fi 57 | fi 58 | 59 | mount_s=0 60 | mount_f=0 61 | mount_j=0 62 | 63 | for drive in $drive_list; do 64 | [[ -d "$mntpt_prefix$drive" ]] || mkdir -p "$mntpt_prefix$drive" 65 | if [[ -n $(find "$mntpt_prefix$drive" -maxdepth 0 -type d -empty 2>/dev/null) ]]; then 66 | echo "${info} Mounting Drive ${drive^} to $mntpt_prefix$drive..." 67 | if mount -t drvfs "${drive}:" "$mntpt_prefix$drive" -o "$mount_opt" 2>/dev/null; then 68 | echo "${info} Mounted Drive ${drive^} to $mntpt_prefix$drive." 69 | mount_s=$((mount_s + 1)) 70 | else 71 | echo "${error} Failed to mount Drive ${drive^}. Skipped." 72 | mount_f=$((mount_f + 1)) 73 | fi 74 | else 75 | echo "${warn} Already mounted Drive ${drive^} at $mntpt_prefix$drive. Skipped." 76 | mount_j=$((mount_j + 1)) 77 | fi 78 | done 79 | echo "${info} Auto mounting completed. $mount_s drive(s) succeed. $mount_f drive(s) failed. $mount_j drive(s) skipped." 80 | } 81 | 82 | function memory_reclaim { 83 | local help_short="wslact memory-reclaim [-h]" 84 | 85 | while [ "$1" != "" ]; do 86 | case "$1" in 87 | -h|--help) help "wslact" "$help_short"; exit;; 88 | *) shift;; 89 | esac 90 | done 91 | 92 | if [ "$EUID" -ne 0 ]; then 93 | error_echo "\`wslact memory-reclaim\` requires you to run as root. Aborted." 1 94 | fi 95 | 96 | sync 97 | echo 1 > /proc/sys/vm/drop_caches 98 | echo "${info} Memory Reclaimed." 99 | } 100 | 101 | while [ "$1" != "" ]; do 102 | case "$1" in 103 | ts|time-sync|tr|time-reset) time_reset "$@"; exit;; 104 | am|auto-mount|sm|smart-mount) auto_mount "$@"; exit;; 105 | mr|memory-reclaim|mem-reclaim) memory_reclaim "$@"; exit;; 106 | -h|--help) help "$0" "$help_short"; exit;; 107 | -v|--version) version; exit;; 108 | *) error_echo "Invalid Input. Aborted." 22;; 109 | esac 110 | done 111 | -------------------------------------------------------------------------------- /src/wslclip.sh: -------------------------------------------------------------------------------- 1 | # shellcheck shell=bash 2 | content="" 3 | 4 | help_short="$0 [-hvg]\n$0 CONTENT" 5 | 6 | function get_clipboard { 7 | winps_exec "get-clipboard" 8 | } 9 | 10 | for args; do 11 | case $args in 12 | -h|--help) help "$0" "$help_short"; exit;; 13 | -v|--version) version; exit;; 14 | -g|--get) get_clipboard; exit;; 15 | *) content="${*}";; 16 | esac 17 | done 18 | 19 | if [[ "$content" != "" ]]; then 20 | winps_exec "set-clipboard -value \"$content\"" 21 | else 22 | winps_exec "set-clipboard -value \"$PIPE\"" 23 | fi 24 | -------------------------------------------------------------------------------- /src/wslfetch.sh: -------------------------------------------------------------------------------- 1 | # shellcheck shell=bash 2 | is_color=0 3 | is_generic=0 4 | 5 | help_short="wslfetch [-hvcg] [-t THEME] [-o OPTIONS]" 6 | 7 | PARSED_ARGUMENTS=$(getopt -a -n "${wslu_util_name##*/}" -o hvtcgo: --long help,version,theme,colorbar,generic,options: -- "$@") 8 | #shellcheck disable=SC2181 9 | [ "$?" != "0" ] && help "$wslu_util_name" "$help_short" 10 | 11 | eval set -- "$PARSED_ARGUMENTS" 12 | while : 13 | do 14 | case "$1" in 15 | -h|--help) help "$_tmp_cmdname" "$help_short"; exit;; 16 | -v|--version) version; exit;; 17 | -t|--theme) shift; WSLFETCH_THEME_PATH="$1"; shift;; 18 | -c|--colorbar) is_color=1; shift;; 19 | -g|--generic) is_generic=1; shift;; 20 | -o|--options) shift; WSLFETCH_INFO_SECTION="$1"; shift;; 21 | --) shift; break ;; 22 | *) echo "Unexpected option: $1" 23 | help "$_tmp_cmdname" "$help_short" 24 | exit 1;; 25 | esac 26 | done 27 | 28 | debug_echo "is_color: $is_color" 29 | debug_echo "is_generic: $is_generic" 30 | debug_echo "WSLFETCH_INFO_SECTION: $WSLFETCH_INFO_SECTION" 31 | debug_echo "WSLFETCH_COLORBAR: $WSLFETCH_COLORBAR" 32 | debug_echo "WSLFETCH_ASCII_PATH: $WSLFETCH_ASCII_PATH" 33 | 34 | if [[ "$is_generic" == "1" ]] || [[ -n "$WSLFETCH_THEME_PATH" ]]; then 35 | distro="" 36 | fi 37 | case "$distro" in 38 | 'ubuntu') 39 | t="${red}${bold}" 40 | ascii_text=( 41 | "${bold}${red} .-/+oossssoo+/-. ${reset}" 42 | "${bold}${red} \`:+ssssssssssssssssss+:\` ${reset}" 43 | "${bold}${red} -+ssssssssssssssssssyyssss+- ${reset}" 44 | "${bold}${red} .ossssssssssssssssss${white}dMMMNy${red}sssso. ${reset}" 45 | "${bold}${red} /sssssssssss${white}hdmmNNmmyNMMMMh${red}ssssss/ ${reset}" 46 | "${bold}${red} +sssssssss${white}hm${red}yd${white}MMMMMMMNddddy${red}ssssssss+ ${reset}" 47 | "${bold}${red} /ssssssss${white}hNMMM${red}yh${white}hyyyyhmNMMMNh${red}ssssssss/ ${reset}" 48 | "${bold}${red} .ssssssss${white}dMMMNh${red}ssssssssss${white}hNMMMd${red}ssssssss. ${reset}" 49 | "${bold}${red} +ssss${white}hhhyNMMNy${red}ssssssssssss${white}yNMMMy${red}sssssss+ ${reset}" 50 | "${bold}${red} oss${white}yNMMMNyMMh${red}ssssssssssssss${white}hmmmh${red}ssssssso ${reset}" 51 | "${bold}${red} oss${white}yNMMMNyMMh${red}sssssssssssssshmmmh${red}ssssssso ${reset}" 52 | "${bold}${red} +ssss${white}hhhyNMMNy${red}ssssssssssss${white}yNMMMy${red}sssssss+ ${reset}" 53 | "${bold}${red} .ssssssss${white}dMMMNh${red}ssssssssss${white}hNMMMd${red}ssssssss. ${reset}" 54 | "${bold}${red} /ssssssss${white}hNMMM${red}yh${white}hyyyyhdNMMMNh${red}ssssssss/ ${reset}" 55 | "${bold}${red} +sssssssss${white}dm${red}yd${white}MMMMMMMMddddy${red}ssssssss+ ${reset}" 56 | "${bold}${red} /sssssssssss${white}hdmNNNNmyNMMMMh${red}ssssss/ ${reset}" 57 | "${bold}${red} .ossssssssssssssssss${white}dMMMNy${red}sssso. ${reset}" 58 | "${bold}${red} -+sssssssssssssssss${white}yyy${red}ssss+- ${reset}" 59 | "${bold}${red} \`:+ssssssssssssssssss+:\` ${reset}" 60 | "${bold}${red} .-/+oossssoo+/-. ${reset}");; 61 | 'debian') 62 | t="${light_red}${bold}" 63 | ascii_text=( 64 | "${white} _,met\$\$\$\$\$gg. ${reset}" 65 | "${white} ,g\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$P. ${reset}" 66 | "${white} ,g\$\$P\"\" \"\"\"Y\$\$.\". ${reset}" 67 | "${white} ,\$\$P' \`\$\$\$. ${reset}" 68 | "${white} ',\$\$P ,ggs. \`\$\$b: ${reset}" 69 | "${white} \`d\$\$' ,\$P\"\' ${light_red}.${white} \$\$\$ ${reset}" 70 | "${white} \$\$P d\$\' ${light_red},${white} \$\$P ${reset}" 71 | "${white} \$\$: \$\$. ${light_red}-${white} ,d\$\$' ${reset}" 72 | "${white} \$\$\; Y\$b._ _,d\$P' ${reset}" 73 | "${white} Y\$\$. ${light_red}\`.${white}\`\"Y\$\$\$\$P\"' ${reset}" 74 | "${white} \`\$\$b ${light_red}\"-.__ ${reset}" 75 | "${white} \`Y\$\$ ${reset}" 76 | "${white} \`Y\$\$. ${reset}" 77 | "${white} \`\$\$b. ${reset}" 78 | "${white} \`Y\$\$b. ${reset}" 79 | "${white} \`\"Y\$b._ ${reset}" 80 | "${white} \`\"\"\"\" ${reset}");; 81 | 'kali') 82 | t="${light_blue}${bold}" 83 | ascii_text=( 84 | "${light_blue}.............. " 85 | "${light_blue} ..,;:ccc,. ${reset}" 86 | "${light_blue} ......''';lxO. ${reset}" 87 | "${light_blue}.....''''..........,:ld; ${reset}" 88 | "${light_blue} .';;;:::;,,.x, ${reset}" 89 | "${light_blue} ..'''. 0Xxoc:,. ... ${reset}" 90 | "${light_blue} .... ,ONkc;,;cokOdc',. ${reset}" 91 | "${light_blue} . OMo ':${black}dd${light_blue}o. ${reset}" 92 | "${light_blue} dMc :OO; ${reset}" 93 | "${light_blue} 0M. .:o. ${reset}" 94 | "${light_blue} ;Wd ${reset}" 95 | "${light_blue} ;XO, ${reset}" 96 | "${light_blue} ,d0Odlc;,.. ${reset}" 97 | "${light_blue} ..',;:cdOOd::,. ${reset}" 98 | "${light_blue} .:d;.':;. ${reset}" 99 | "${light_blue} 'd, .' ${reset}" 100 | "${light_blue} ;l .. ${reset}" 101 | "${light_blue} .o ${reset}" 102 | "${light_blue} c ${reset}" 103 | "${light_blue} .' ${reset}" 104 | "${light_blue} . ${reset}");; 105 | 'opensuse') 106 | t="${light_green}${bold}" 107 | ascii_text=( 108 | "${light_gray} .;ldkO0000Okdl;. ${reset}" 109 | "${light_gray} .;d00xl:^''''''^:ok00d;. ${reset}" 110 | "${light_gray} .d00l' 'o00d. ${reset}" 111 | "${light_gray} .d0Kd'${light_green} Okxol:;,. ${light_gray}:O0d. ${reset}" 112 | "${light_gray} .OK${light_green}KKK0kOKKKKKKKKKKOxo:, ${light_gray}lKO. ${reset}" 113 | "${light_gray} ,0K${light_green}KKKKKKKKKKKKKKK0P^${light_gray},,,${light_green}^dx:${light_gray} ;00, ${reset}" 114 | "${light_gray} .OK${light_green}KKKKKKKKKKKKKKKk'${light_gray}.oOPPb.${light_green}'0k.${light_gray} cKO. ${reset}" 115 | "${light_gray} :KK${light_green}KKKKKKKKKKKKKKK: ${light_gray}kKx..dd ${light_green}lKd${light_gray} 'OK: ${reset}" 116 | "${light_gray} dKK${light_green}KKKKKKKKKOx0KKKd ${light_gray}^0KKKO' ${light_green}kKKc${light_gray} dKd ${reset}" 117 | "${light_gray} dKK${light_green}KKKKKKKKKK;.;oOKx,..${light_gray}^${light_green}..;kKKK0.${light_gray} dKd ${reset}" 118 | "${light_gray} :KK${light_green}KKKKKKKKKK0o;...^cdxxOK0O/^^' ${light_gray}.0K: ${reset}" 119 | "${light_gray} kKK${light_green}KKKKKKKKKKKKK0x;,,......,;od ${light_gray}lKk ${reset}" 120 | "${light_gray} '0K${light_green}KKKKKKKKKKKKKKKKKKKK00KKOo^ ${light_gray}c00' ${reset}" 121 | "${light_gray} 'kK${light_green}KKOxddxkOO00000Okxoc;'' ${light_gray}.dKk' ${reset}" 122 | "${light_gray} l0Ko. .c00l' ${reset}" 123 | "${light_gray} 'l0Kk:. .;xK0l' ${reset}" 124 | "${light_gray} 'lkK0xl:;,,,,;:ldO0kl' ${reset}" 125 | "${light_gray} '^:ldxkkkkxdl:^' ${reset}");; 126 | 'pengwin') 127 | t="${purple}${bold}" 128 | ascii_text=( 129 | "${light_purple} ...\` ${reset}" 130 | "${light_purple} \`-///:-\` ${reset}" 131 | "${light_purple} .+${purple}ssys${light_purple}/ ${reset}" 132 | "${light_purple} +${purple}yyyyy${light_purple}o ${reset}" 133 | "${purple} -yyyyyy: ${reset}" 134 | "${purple} \`.:/+ooo+/:\` -yyyyyy+ ${reset}" 135 | "${purple} \`:oyyyyyys+:-.\`syyyyyy: ${reset}" 136 | "${purple} .syyyyyyo-\` .oyyyyyyo ${reset}" 137 | "${purple} \`syyyyyy/ \`-+yyyyyyy/\` ${reset}" 138 | "${purple} /yyyyyy+ -/osyyyyyyo/. ${reset}" 139 | "${purple} +yyyyyy- \`.-:::-.\` ${reset}" 140 | "${purple} .yyyyyy- ${reset}" 141 | "${light_purple} :${purple}yyyyy${light_purple}o ${reset}" 142 | "${light_purple} .+${purple}ooo${light_purple}+: ${reset}" 143 | "${light_purple} \`.::/:. ${reset}");; 144 | 'wlinux') 145 | t="${light_orange}${bold}" 146 | ascii_text=( 147 | "${light_orange} _.._ ${reset}" 148 | "${light_orange} .-' \`-. ${reset}" 149 | "${light_orange} : ; ${reset}" 150 | "${light_orange} ; ,_ _, ; ${reset}" 151 | "${light_orange} : \\{\" \"}/ : ${reset}" 152 | "${light_orange} ,'.'\"=..=''.'. ${reset}" 153 | "${light_orange} ; / \ / \ ; ${reset}" 154 | "${light_orange} .' ; '.__.' ; '. ${reset}" 155 | "${light_orange} .-' .' '. '-. ${reset}" 156 | "${light_orange} .' ; ; '. ${reset}" 157 | "${light_orange} / / \ \ ${reset}" 158 | "${light_orange} ; ; ; ; ${reset}" 159 | "${light_orange} ; \`-._ _.-' ; ${reset}" 160 | "${light_orange} ; ""--. .--"" ; ${reset}" 161 | "${light_orange} '. _ ; ; _ .' ${reset}" 162 | "${light_orange} {""..' '._.-. .-._.' '..""} ${reset}" 163 | "${light_orange} \ ; ; / ${reset}" 164 | "${light_orange} : : : : ${reset}" 165 | "${light_orange} : :.__.: : ${reset}" 166 | "${light_orange} \ /\"-..-\"\ / ${reset}" 167 | "${light_orange} '-.__.' '.__.-' ${reset}");; 168 | 'sles') 169 | t="${green}${bold}" 170 | ascii_text=( 171 | "${green} .;ldkO0000Okdl;. ${reset}" 172 | "${green} .;d00xl:^''''''^:ok00d;. ${reset}" 173 | "${green} .d00l' 'o00d. ${reset}" 174 | "${green} .d0Kd' Okxol:;,. :O0d. ${reset}" 175 | "${green} .OKKKK0kOKKKKKKKKKKOxo:, lKO. ${reset}" 176 | "${green} ,0KKKKKKKKKKKKKKKK0P^,,,^dx: ;00, ${reset}" 177 | "${green} .OKKKKKKKKKKKKKKKKk'.oOPPb.'0k. cKO. ${reset}" 178 | "${green} :KKKKKKKKKKKKKKKKK: kKx..dd lKd 'OK: ${reset}" 179 | "${green} dKKKKKKKKKKKOx0KKKd ^0KKKO' kKKc dKd ${reset}" 180 | "${green} dKKKKKKKKKKKK;.;oOKx,..^..;kKKK0. dKd ${reset}" 181 | "${green} :KKKKKKKKKKKK0o;...^cdxxOK0O/^^' .0K: ${reset}" 182 | "${green} kKKKKKKKKKKKKKKK0x;,,......,;od lKk ${reset}" 183 | "${green} '0KKKKKKKKKKKKKKKKKKKKK00KKOo^ c00' ${reset}" 184 | "${green} 'kKKKOxddxkOO00000Okxoc;'' .dKk' ${reset}" 185 | "${green} l0Ko. .c00l' ${reset}" 186 | "${green} 'l0Kk:. .;xK0l' ${reset}" 187 | "${green} 'lkK0xl:;,,,,;:ldO0kl' ${reset}" 188 | "${green} '^:ldxkkkkxdl:^' ${reset}");; 189 | 'alpine') 190 | t="${blue}${bold}" 191 | ascii_text=( 192 | "${light_blue} ................ ${reset}" 193 | "${light_blue} ∴::::::::::::::::∴ ${reset}" 194 | "${light_blue} ∴::::::::::::::::::∴ ${reset}" 195 | "${light_blue} ∴::::::::::::::::::::∴ ${reset}" 196 | "${light_blue} ∴:::::::. :::::':::::::∴ ${reset}" 197 | "${light_blue} ∴:::::::. ;::; ::::::::∴ ${reset}" 198 | "${light_blue} ∴::::::; ∵ :::::::∴ ${reset}" 199 | "${light_blue} ∴:::::. . .::::::∴ ${reset}" 200 | "${light_blue} :::::: :::. . :::::: ${reset}" 201 | "${light_blue} ∵:::: ::::::. ::. ::::∵ ${reset}" 202 | "${light_blue} ∵:.. .:;::::::: :::. :::∵ ${reset}" 203 | "${light_blue} ∵::::::::::::::::::::::::∵ ${reset}" 204 | "${light_blue} ∵::::::::::::::::::::::∵ ${reset}" 205 | "${light_blue} ∵::::::::::::::::::::∵ ${reset}" 206 | "${light_blue} :::::::::::::::::::: ${reset}" 207 | "${light_blue} ∵::::::::::::::::∵ ${reset}");; 208 | 'archlinux') 209 | t="${light_cyan}${bold}" 210 | ascii_text=( 211 | "${light_cyan} -\` ${reset}" 212 | "${light_cyan} .o+\` ${reset}" 213 | "${light_cyan} \`ooo/ ${reset}" 214 | "${light_cyan} \`+oooo: ${reset}" 215 | "${light_cyan} \`+oooooo: ${reset}" 216 | "${light_cyan} -+oooooo+: ${reset}" 217 | "${light_cyan} \`/:-:++oooo+: ${reset}" 218 | "${light_cyan} \`/++++/+++++++: ${reset}" 219 | "${light_cyan} \`/++++++++++++++: ${reset}" 220 | "${light_cyan} \`/+++o${cyan}oooooooo${light_cyan}oooo/\` ${reset}" 221 | "${cyan} ${light_cyan}./${cyan}ooosssso++osssssso${light_cyan}+\` ${reset}" 222 | "${cyan} .oossssso-\`\`\`\`/ossssss+\` ${reset}" 223 | "${cyan} -osssssso. :ssssssso. ${reset}" 224 | "${cyan} :osssssss/ osssso+++. ${reset}" 225 | "${cyan} /ossssssss/ +ssssooo/- ${reset}" 226 | "${cyan} \`/ossssso+/:- -:/+osssso+- ${reset}" 227 | "${cyan} \`+sso+:-\` \`.-/+oso: ${reset}" 228 | "${cyan} \`++:. \`-/+/${reset}" 229 | "${cyan} .\` \`/${reset}");; 230 | 'scilinux') 231 | t="${light_blue}${bold}" 232 | ascii_text=( 233 | "${light_blue} =/;;/- ${reset}" 234 | "${light_blue} +: // ${reset}" 235 | "${light_blue} /; /; ${reset}" 236 | "${light_blue} -X H. ${reset}" 237 | "${light_blue} .//;;;:;;-, X= :+ .-;:=;:;#;. ${reset}" 238 | "${light_blue} M- ,=;;;#:, ,:#;;:=, ,@ ${reset}" 239 | "${light_blue} :# :#.=/++++/=.$= #= ${reset}" 240 | "${light_blue} ,#; #/:+/;,,/++:+/ ;+. ${reset}" 241 | "${light_blue} ,+/. ,;@+, ,#H;, ,/+, ${reset}" 242 | "${light_blue} ;+;;/= @. ${light_red}.H${white}#${light_red}#X ${light_blue}-X :///+; ${reset}" 243 | "${light_blue} ;+=;;;.@, ${white}.X${light_red}M${white}@$. ${light_blue}=X.//;=#/. ${reset}" 244 | "${light_blue} ,;: :@#= =\$H: .+#- ${reset}" 245 | "${light_blue} ,#= #;-///==///-// =#, ${reset}" 246 | "${light_blue} ;+ :#-;;;:;;;;-X- +: ${reset}" 247 | "${light_blue} @- .-;;;;M- =M/;;;-. -X ${reset}" 248 | "${light_blue} :;;::;;-. #- :+ ,-;;-;:== ${reset}" 249 | "${light_blue} ,X H. ${reset}" 250 | "${light_blue} ;/ #= ${reset}" 251 | "${light_blue} // +; ${reset}" 252 | "${light_blue} '////' ${reset}");; 253 | 'oracle') 254 | t="${red}${bold}" 255 | ascii_text=( 256 | "${red} \`-/+++++++++++++++++/-.\` ${reset}" 257 | "${red} \`/syyyyyyyyyyyyyyyyyyyyyyys/. ${reset}" 258 | "${red} :yyyyo/-...............-/oyyyy/ ${reset}" 259 | "${red} /yyys- .oyyy+ ${reset}" 260 | "${red} .yyyy\` \`syyy- ${reset}" 261 | "${red} :yyyo /yyy/ ${reset}" 262 | "${red} .yyyy\` \`syyy- ${reset}" 263 | "${red} /yyys. .oyyyo ${reset}" 264 | "${red} /yyyyo:-...............-:oyyyy/\` ${reset}" 265 | "${red} \`/syyyyyyyyyyyyyyyyyyyyyyys+. ${reset}" 266 | "${red} \`.:/+ooooooooooooooo+/:.\` ${reset}");; 267 | 'oldfedora'|'fedora') 268 | t="${light_blue}${bold}" 269 | ascii_text=( 270 | "${light_blue} /:-------------:\ ${reset}" 271 | "${light_blue} :-------------------:: ${reset}" 272 | "${light_blue} :-----------${white}/shhOHbmp${light_blue}---:\\ ${reset}" 273 | "${light_blue} /-----------${white}omMMMNNNMMD ${light_blue}---: ${reset}" 274 | "${light_blue} :-----------${white}sMMMMNMNMP${light_blue}. ---: ${reset}" 275 | "${light_blue} :-----------${white}:MMMdP${light_blue}------- ---\ ${reset}" 276 | "${light_blue} ,------------${white}:MMMd${light_blue}-------- ---: ${reset}" 277 | "${light_blue} :------------${white}:MMMd${light_blue}------- .---: ${reset}" 278 | "${light_blue} :---- ${white}oNMMMMMMMMMNho${light_blue} .----: ${reset}" 279 | "${light_blue} :-- .${white}+shhhMMMmhhy++${light_blue} .------/ ${reset}" 280 | "${light_blue} :- -------${white}:MMMd${light_blue}--------------: ${reset}" 281 | "${light_blue} :- --------${white}/MMMd${light_blue}-------------; ${reset}" 282 | "${light_blue} :- ------${white}/hMMMy${light_blue}------------: ${reset}" 283 | "${light_blue} :--${white} :dMNdhhdNMMNo${light_blue}------------; ${reset}" 284 | "${light_blue} :---${white}:sdNMMMMNds:${light_blue}------------: ${reset}" 285 | "${light_blue} :------${white}:://:${light_blue}-------------:: ${reset}" 286 | "${light_blue} :---------------------:// ${reset}");; 287 | 'fedoraremix') 288 | t="${white}${deep_purple}" 289 | ascii_text=( 290 | "${white} ${reset}" 291 | "${white} ${reset}" 292 | "${white} ${reset}" 293 | "${white} wgg ,g ${reset}" 294 | "${white} \$\$ ]$ ${reset}" 295 | "${white} 'A\$\$A g@PR&, x\$NR&@$ g\$PR&w \$N\$P* g&P&&y ${reset}" 296 | "${white} \$\$ \$\$gggg$ $~ 1$ \$\$ &K \$F \$E \"\$. ${reset}" 297 | "${white} \$\$ ]\$w ,gg &N,,w\$\$ \"\$w,,g$\" \$F J\$w,,\$\$U ${reset}" 298 | "${white} \" *T7' \`7T' 7 \"TT' 7 ?T7 7 ™ ${reset}" 299 | "${deep_purple} ,@@@@&8@@@@@M&@@@@@8R@@R@@@@@@@@@@@@@@@@@W ${reset}" 300 | "${deep_purple} .@@@@\`,@@@@F M ]@@@@ @ a@ @@@@ #@@@@,\`,@@@@@ ${reset}" 301 | "${deep_purple} @@@@~]@@@@W *\"]@@@@j@ \$@ @@@@ #@@@F @ \$@@@@ ${reset}" 302 | "${deep_purple} *R@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@RMF ${reset}" 303 | "${white} ${reset}" 304 | "${white} ${reset}" 305 | "${white} ${reset}");; 306 | 'gentoo') 307 | t="${white}${light_purple}" 308 | ascii_text=( 309 | "${light_purple} -/oyddmdhs+:. ${reset}" 310 | "${light_purple} -o${white}dNMMMMMMMMNNmhy+${light_purple}-\` ${reset}" 311 | "${light_purple} -y${white}NMMMMMMMMMMMNNNmmdhy${light_purple}+- ${reset}" 312 | "${light_purple} \`o${white}mMMMMMMMMMMMMNmdmmmmddhhy${light_purple}/\` ${reset}" 313 | "${light_purple} om${white}MMMMMMMMMMMN${light_purple}hhyyyo${white}hmdddhhhd${light_purple}o\` ${reset}" 314 | "${light_purple}.y${white}dMMMMMMMMMMd${light_purple}hs++so/s${white}mdddhhhhdm${light_purple}+\` ${reset}" 315 | "${light_purple} oy${white}hdmNMMMMMMMN${light_purple}dyooy${white}dmddddhhhhyhN${light_purple}d. ${reset}" 316 | "${light_purple} :o${white}yhhdNNMMMMMMMNNNmmdddhhhhhyym${light_purple}Mh ${reset}" 317 | "${light_purple} .:${white}+sydNMMMMMNNNmmmdddhhhhhhmM${light_purple}my ${reset}" 318 | "${light_purple} /m${white}MMMMMMNNNmmmdddhhhhhmMNh${light_purple}s: ${reset}" 319 | "${light_purple} \`o${white}NMMMMMMMNNNmmmddddhhdmMNhs${light_purple}+\` ${reset}" 320 | "${light_purple} \`s${white}NMMMMMMMMNNNmmmdddddmNMmhs${light_purple}/. ${reset}" 321 | "${light_purple} /N${white}MMMMMMMMNNNNmmmdddmNMNdso${light_purple}:\` ${reset}" 322 | "${light_purple}+M${white}MMMMMMNNNNNmmmmdmNMNdso${light_purple}/- ${reset}" 323 | "${light_purple}yM${white}MNNNNNNNmmmmmNNMmhs+/${light_purple}-\` ${reset}" 324 | "${light_purple}/h${white}MMNNNNNNNNMNdhs++/${light_purple}-\` ${reset}" 325 | "${light_purple}\`/${white}ohdmmddhys+++/:${light_purple}.\` ${reset}" 326 | "${light_purple} \`-//////:--. ${reset}");; 327 | "cblm") 328 | t="${blue}${bold}" 329 | ascii_text=( 330 | "${blue} ____ ____ _ _ ${reset}" 331 | "${blue} / ___| __ ) | | (_)_ __ _ ___ __ ${reset}" 332 | "${blue}| | | _ \ | | | | '_ \\| | | \\ \\/ / ${reset}" 333 | "${blue}| |___| |_) | | |___| | | | | |_| |> < ${reset}" 334 | "${blue} \\____|____/ |_____|_|_| |_|\\__,_/_/\\_\ ${reset}" 335 | "${blue} __ __ _ ${reset}" 336 | "${blue} | \\/ | __ _ _ __(_)_ __ ___ _ __ ${reset}" 337 | "${blue} | |\\/| |/ _\` | '__| | '_ \\ / _ \\ '__| ${reset}" 338 | "${blue} | | | | (_| | | | | | | | __/ | ${reset}" 339 | "${blue} |_| |_|\\__,_|_| |_|_| |_|\\___|_| ${reset}");; 340 | "clear") 341 | t="${blue}${bold}" 342 | ascii_text=( 343 | "${blue} BBB ${reset}" 344 | "${blue} BBBBBBBBB ${reset}" 345 | "${blue} BBBBBBBBBBBBBBB ${reset}" 346 | "${blue} BBBBBBBBBBBBBBBBBBBB ${reset}" 347 | "${blue} BBBBBBBBBBB BBB ${reset}" 348 | "${blue} BBBBBBBB${brown}YYYYY ${reset}" 349 | "${blue} BBBBBBBB${brown}YYYYYY ${reset}" 350 | "${blue} BBBBBBBB${brown}YYYYYYY ${reset}" 351 | "${blue} BBBBBBBBB${brown}YYYYY${white}W ${reset}" 352 | "${cyan} GG${blue}BBBBBBBY${brown}YYYY${white}WWW ${reset}" 353 | "${cyan} GGG${blue}BBBBBBB${brown}YY${white}WWWWWWWW ${reset}" 354 | "${cyan} GGGGGG${blue}BBBBBB${white}WWWWWWWW ${reset}" 355 | "${cyan} GGGGGGGG${blue}BBBB${white}WWWWWWWW ${reset}" 356 | "${cyan}GGGGGGGGGGG${blue}BBB${white}WWWWWWW ${reset}" 357 | "${cyan}GGGGGGGGGGGGG${blue}B${white}WWWWWW ${reset}" 358 | "${cyan}GGGGGGGG${white}WWWWWWWWWWW ${reset}" 359 | "${cyan}GG${white}WWWWWWWWWWWWWWWW ${reset}" 360 | "${white} WWWWWWWWWWWWWWWW ${reset}" 361 | "${white} WWWWWWWWWW ${reset}" 362 | "${white} WWW ${reset}");; 363 | "almalinux") 364 | t="${blue}${bold}" 365 | ascii_text=( 366 | "${red} 'c:. ${reset}" 367 | "${red} lkkkx, .. ${brown}.. ,cc, ${reset}" 368 | "${red} okkkk:ckkx' ${brown}.lxkkx.okkkkd ${reset}" 369 | "${red} .:llcokkx' ${brown}:kkkxkko:xkkd, ${reset}" 370 | "${red} .xkkkkdood: ${brown};kx, .lkxlll; ${reset}" 371 | "${red} xkkx. ${brown}xk' xkkkkk: ${reset}" 372 | "${red} 'xkx. ${brown}xd .....,. ${reset}" 373 | "${blue} .. ${red}:xkl' ${brown}:c ..''.. ${reset}" 374 | "${blue} .dkx' ${red}.:ldl:'. ${brown}' ${green}':lollldkkxo; ${reset}" 375 | "${blue} .''lkkko' ${green}ckkkx. ${reset}" 376 | "${blue}'xkkkd:kkd. .. ${cyan};' ${green}:kkxo. ${reset}" 377 | "${blue},xkkkd;kk' ,d; ${cyan}ld. ${green}':dkd::cc, ${reset}" 378 | "${blue} .,,.;xkko'.';lxo. ${cyan}dx, ${green}:kkk'xkkkkc ${reset}" 379 | "${blue} 'dkkkkkxo:. ${cyan};kx ${green}.kkk:;xkkd. ${reset}" 380 | "${blue} ..... ${cyan}.;dk:. ${cyan}lkk. ${green}:;, ${reset}" 381 | "${cyan} :kkkkkkkdoxkkx ${reset}" 382 | "${cyan} ,c,,;;;:xkkd. ${reset}" 383 | "${cyan} ;kkkkl... ${reset}" 384 | "${cyan} ;kkkkl ${reset}" 385 | "${cyan} ,od; ${reset}" 386 | );; 387 | *) 388 | t="${cyan}${bold}" 389 | ascii_text=( 390 | "${cyan} /\$\$ /\$\$ /\$\$\$\$\$\$ /\$\$ " 391 | "${cyan}| \$\$ /\$ | \$\$ /\$\$__ \$\$| \$\$ " 392 | "${cyan}| \$\$ /\$\$\$| \$\$| \$\$${reset} ${cyan}\\__/| \$\$${reset} " 393 | "${cyan}| \$\$${reset}${cyan}/\$\$${reset} ${cyan}\$\$${reset} ${cyan}\$\$${reset}${cyan}| \$\$\$\$\$\$${reset} ${cyan}| \$\$${reset} " 394 | "${cyan}| \$\$\$\$${reset}${cyan}_ \$\$\$\$${reset} ${cyan}\\____ \$\$${reset}${cyan}| \$\$${reset} " 395 | "${cyan}| \$\$\$${reset}${cyan}/ \\ \$\$\$${reset} ${cyan}/\$\$${reset} ${cyan}\\ \$\$${reset}${cyan}| \$\$${reset} " 396 | "${cyan}| \$\$${reset}${cyan}/ \\ \$\$${reset}${cyan}| \$\$\$\$\$\$${reset}${cyan}/| \$\$\$\$\$\$\$\$${reset} " 397 | "${cyan}|__/ \\__/ \\______/ |________/${reset} ");; 398 | esac 399 | 400 | if [[ -n "$WSLFETCH_THEME_PATH" ]]; then 401 | debug_echo "custom theme detected: $WSLFETCH_THEME_PATH" 402 | #shellcheck disable=SC1090 403 | source "$WSLFETCH_THEME_PATH" 404 | fi 405 | 406 | debug_echo "distro: $distro" 407 | debug_echo "t: ${t}color${reset}" 408 | debug_echo "ascii_text: ${ascii_text[*]}" 409 | 410 | SAVEIFS=$IFS 411 | info_collect=() 412 | while IFS=$'\n' read -r line; do 413 | info_collect+=("$line"); 414 | done < <(wslsys "$wslu_debug" --wslfetch "${WSLFETCH_INFO_SECTION}" "${t}") 415 | IFS=$SAVEIFS 416 | 417 | wslf_ver="${info_collect[0]}" 418 | debug_echo "collected wsl version: $wslf_ver" 419 | 420 | debug_echo "constructing text" 421 | info_text=("${t}Windows Subsystem for Linux (WSL${wslf_ver})${reset}" 422 | "${t}${USER}${reset}@${t}$(/dev/null << EOF 93 | Import-Module 'C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\Microsoft.PowerShell.Utility\\Microsoft.PowerShell.Utility.psd1'; 94 | \$action = New-ScheduledTaskAction -Execute 'C:\\Windows\\System32\\wscript.exe' -Argument '$script_location_win\\runHidden.vbs $wa_gs_commd'; 95 | \$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries; 96 | \$trigger = New-ScheduledTaskTrigger -AtLogOn -User \$env:userdomain\\\$env:username; \$trigger.Delay = 'PT2M'; 97 | \$task = New-ScheduledTask -Action \$action -Trigger \$trigger -Description \"$wa_gs_dscp\" -Settings \$settings; 98 | Register-ScheduledTask -InputObject \$task -TaskPath '\\' -TaskName 'WSLUtilities_Actions_Startup_${wa_gs_name}_${tmp_rand}' | out-null; 99 | EOF 100 | 101 | debug_echo "$(cat "$tpath_linux"/tmp.ps1)" 102 | echo "${warn} WSL Utilities is adding \"${wa_gs_name}\" to Task Scheduler; A UAC Prompt will show up later. Allow it if you know what you are doing." 103 | if winps_exec "$script_location_win"\\sudo.ps1 "$tpath"\\tmp.ps1; then 104 | debug_echo "Task Scheduler added" 105 | rm -rf "$tpath_linux/tmp.ps1" 106 | echo "${info} Task \"${wa_gs_name}\" added." 107 | else 108 | rm -rf "$tpath_linux/tmp.ps1" 109 | error_echo "Adding Task \"${wa_gs_name}\" failed." 1 110 | fi 111 | else 112 | error_echo "No input, aborting" 21 113 | fi 114 | 115 | unset isService 116 | unset wa_gs_commd 117 | unset wa_gs_name 118 | unset wa_gs_user 119 | -------------------------------------------------------------------------------- /src/wslsys.sh: -------------------------------------------------------------------------------- 1 | # shellcheck shell=bash 2 | help_short="wslsys [-VIbBFUWRKPSltTd] [-s]\nwslsys [-hv] [-n NAME]" 3 | 4 | ## Windows 10 information 5 | function get_branch() { 6 | debug_echo "get_branch: called" 7 | branch=$("$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/reg.exe query "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion" /v BuildBranch | tail -n 2 | head -n 1 | sed -e 's|\r||g') 8 | echo "${branch##* }" 9 | } 10 | 11 | function get_build() { 12 | debug_echo "get_build: called" 13 | wslu_get_build 14 | } 15 | 16 | function get_full_build() { 17 | debug_echo "get_full_build: called" 18 | full_build=$("$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/reg.exe query "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion" /v BuildLabEx | tail -n 2 | head -n 1 | sed -e 's|\r||g') 19 | echo "${full_build##* }" 20 | } 21 | 22 | function get_install_date() { 23 | debug_echo "get_install_date: called" 24 | installdate=$("$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/reg.exe query "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion" /v InstallDate | tail -n 2 | head -n 1 | sed -e 's|\r||g') 25 | echo "${installdate##* }" 26 | } 27 | 28 | function get_theme() { 29 | debug_echo "get_theme: called" 30 | win_theme=$("$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/reg.exe query "HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize" /v AppsUseLightTheme | tail -n 2 | head -n 1 | sed -e 's|\r||g') 31 | win_theme=${win_theme##* } 32 | if [ "$win_theme" != "0x1" ]; then 33 | echo "dark" 34 | else 35 | echo "light" 36 | fi 37 | } 38 | 39 | function get_display_scaling() { 40 | debug_echo "get_display_scaling: called" 41 | up_path="$(wslvar -s USERPROFILE)" 42 | wslu_file_check "$(wslpath "$up_path")/wslu" "get_dpi.ps1" "?!S" 43 | display_scaling="$(winps_exec "$(double_dash_p "$up_path" | sed -e 's| |\` |g')\\wslu\\get_dpi.ps1" | sed -e 's|\r||g')" 44 | bc -l <<< "$(printf "%d\n" "$display_scaling")/100" | sed -e "s/\.0//g" -e "s/0*$//g" 45 | } 46 | 47 | function get_windows_uptime() { 48 | debug_echo "get_windows_uptime: called" 49 | win_uptime=$(winps_exec "[int64]((get-date) - (gcim Win32_OperatingSystem).LastBootUpTime).TotalSeconds" | sed -e 's|\r||g') 50 | win_uptime=${win_uptime//.*} 51 | w_days=$((win_uptime/86400)) 52 | w_hours=$((win_uptime/3600%24)) 53 | w_minutes=$((win_uptime/60%60)) 54 | echo "${w_days}d ${w_hours}h ${w_minutes}m" 55 | } 56 | 57 | function get_windows_locale() { 58 | debug_echo "get_windows_locale: called" 59 | win_uptime=$(winps_exec "(Get-Culture).Name" | sed -e 's|\r||g' -e 's|-|_|g') 60 | echo "$win_uptime" 61 | } 62 | 63 | ## WSL information 64 | 65 | function get_wsl_version() { 66 | wslu_get_wsl_ver 67 | } 68 | 69 | function get_wsl_release() { 70 | debug_echo "get_wsl_release: called" 71 | release="$(grep "PRETTY_NAME=" /etc/os-release | sed -e 's/PRETTY_NAME=//g' -e 's/"//g')" 72 | ## old version of fedora remix specific information 73 | if [ "$distro" == "oldfedora" ]; then 74 | release="Fedora Remix $(grep -e "^VERSION=" /etc/os-release | sed -e 's/\"//g' | sed -e 's/VERSION=//g')" 75 | fi 76 | echo "$release" 77 | } 78 | 79 | function get_wsl_kernel() { 80 | debug_echo "get_wsl_kernel: called" 81 | echo "$(/dev/null; then 131 | echo "enabled" 132 | else 133 | echo "disabled" 134 | fi 135 | else 136 | echo "N/A" 137 | fi 138 | } 139 | 140 | ## Simple printer defined for fetching information 141 | function printer() { 142 | debug_echo "printer: called with \"$1\" \"$2\"" 143 | if [[ -n "$WSLSYS_WSLFETCH_COLOR" ]]; then 144 | debug_echo "printer: wslfetch printing" 145 | echo "$WSLSYS_WSLFETCH_COLOR$1${reset}: $2" 146 | elif [[ -z "$WSLSYS_WSLFETCH_SHORTFORM" ]]; then 147 | debug_echo "printer: long form printing" 148 | echo "$1: $2" 149 | elif [[ "$1" == "Release Install Date" ]]; then 150 | debug_echo "printer: special get_install_date called" 151 | get_install_date # special case for Release Install Date, only shortform use hex unix timestamp 152 | else 153 | debug_echo "printer(wslsys): short form printing" 154 | echo "$2" 155 | fi 156 | } 157 | 158 | # function to find the value using the param/number/option passed 159 | function dict_finder() { 160 | debug_echo "dict_finder: called with $1 $2" 161 | # this function should only have two input: the content ($1) and the shortform param ($2). 162 | # the dict looks like this: 163 | ## num|short_param|long_param|option) 164 | ## printer "readable name" "value" "$2" 165 | ## return;; 166 | # num is used for empty input for iteration only 167 | # param are for parameter passing 168 | # option are for --wslfetch and --name 169 | local WSLSYS_WSLFETCH_SHORTFORM="$2" 170 | case $1 in 171 | 1|-I|--sys-installdate|windows-install-date) 172 | printer "Release Install Date" "$(date -d @"$(printf "%d" "$(get_install_date)")")" 173 | return;; 174 | 2|-b|--branch|windows-rel-branch) 175 | printer "Branch" "$(get_branch)" 176 | return;; 177 | 3|-B|--build|windows-build) 178 | printer "Build" "$(get_build)" 179 | return;; 180 | 4|-F|--full-build|windows-full-build) 181 | printer "Full Build" "$(get_full_build)" 182 | return;; 183 | 5|-S|--display-scaling|display-scaling) 184 | printer "Display Scaling" "$(get_display_scaling)" 185 | return;; 186 | 6|-l|--locale|windows-locale) 187 | printer "Locale (Windows)" "$(get_windows_locale)" 188 | return;; 189 | 7|-t|--win-theme|windows-theme) 190 | printer "Theme (Windows)" "$(get_theme)" 191 | return;; 192 | 8|-W|--win-uptime|windows-uptime) 193 | printer "Uptime (Windows)" "$(get_windows_uptime)" 194 | return;; 195 | 9|-V|--wsl-version|wsl-version) 196 | printer "Version (WSL)" "$(get_wsl_version)" 197 | return;; 198 | 10|-U|--uptime|wsl-uptime) 199 | printer "Uptime (WSL)" "$(get_wsl_uptime)" 200 | return;; 201 | 11|-R|--release|wsl-release) 202 | printer "Release" "$(get_wsl_release)" 203 | return;; 204 | 12|-K|--kernel|wsl-kernel) 205 | printer "Kernel" "$(get_wsl_kernel)" 206 | return;; 207 | 13|-P|--package|wsl-package-count) 208 | printer "Packages" "$(get_wsl_packages)" 209 | return;; 210 | 14|-i|--ip|wsl-ip) 211 | printer "IPv4 Address" "$(get_wsl_ip)" 212 | return;; 213 | 15|-T|--win-system-type|win-system-type) 214 | printer "System Type (Windows)" "$(get_win_system_type)" 215 | return;; 216 | 16|-d|--systemd-status|wsl-systemd-status) 217 | printer "SystemD Status" "$(get_systemd)" 218 | return;; 219 | *) return 1;; 220 | esac 221 | } 222 | 223 | # main handler for wslsys 224 | function wslsys_main() { 225 | debug_echo "wslsys_main: called" 226 | # If input is empty, print everything available 227 | if [[ "$*" == "" ]]; then 228 | debug_echo "wslsys_main: printing everything" 229 | for i in {1..16}; do 230 | dict_finder "$i" 231 | done 232 | exit 233 | fi 234 | # If input start with --wslfetch, doing wslfetch specific print, not intend to use externally 235 | if [[ "$1" == "--wslfetch" ]]; then 236 | debug_echo "wslsys_main: wslfetch printing" 237 | dict_finder "wsl-version" "-s" 238 | IFS=',' read -r -a fetch_array <<< "$2" 239 | for i in "${fetch_array[@]}"; do 240 | [[ "$i" == "wsl-version" ]] || WSLSYS_WSLFETCH_COLOR="$3" dict_finder "$i" 241 | done 242 | exit 243 | fi 244 | # If input start with --name, shift and use input instead 245 | if [[ "$1" == "--name" ]] || [[ "$1" == "-n" ]]; then 246 | debug_echo "wslsys_main: --name/-n found" 247 | shift 248 | fi 249 | # pass the param(or value) to dict_finder(), check return, if return -1, print error 250 | if ! dict_finder "$1" "$2"; then 251 | echo "${error} Invalid input." 252 | exit 22 253 | fi 254 | } 255 | 256 | # pre-handler 257 | case $1 in 258 | -h|--help) help "$0" "$help_short"; exit;; 259 | -v|--version) version; exit;; 260 | *) 261 | #shellcheck disable=SC2068 262 | wslsys_main $@; exit;; 263 | esac 264 | -------------------------------------------------------------------------------- /src/wslu-header: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #shellcheck disable=SC1091 3 | # wslu - Windows 10 linux Subsystem Utility 4 | # Component of Windows 10 linux Subsystem Utility 5 | # 6 | # Copyright (C) 2019 Patrick Wu 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 3 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | # Current utility 22 | wslu_util_fullpath="$0" 23 | wslu_util_name="${wslu_util_fullpath##*/}" 24 | 25 | # Version 26 | wslu_version=VERSIONPLACEHOLDER 27 | wslu_prefix="PREFIXPLACEHOLDER" 28 | wslu_dest_dir="DESTDIRPLACEHOLDER" 29 | 30 | # Speed up script by using unicode. 31 | LC_ALL=C 32 | LANG=C 33 | 34 | # current state location 35 | wslu_state_dir=${XDG_STATE_HOME:-$HOME/.local/state}/wslu 36 | if [ ! -d "$wslu_state_dir" ]; then 37 | mkdir -p "$wslu_state_dir" 38 | fi 39 | 40 | # prevent bash -x 41 | set +x 42 | 43 | bash_version_full=$(bash --version | head -n 1) 44 | bash_version_major=$(echo "$bash_version_full" | cut -d ' ' -f 4 | cut -d '.' -f 1) 45 | bash_version_minor=$(echo "$bash_version_full" | cut -d ' ' -f 4 | cut -d '.' -f 2) 46 | 47 | # pipeline content to pipe... if it is wslclip 48 | if [[ "$wslu_util_name" == "wslclip" ]]; then 49 | if [[ -p /dev/stdin ]]; then 50 | PIPE=$(cat -) 51 | fi 52 | fi 53 | 54 | # conf handling module 55 | __wsl_conf_read() { 56 | if [ -f /etc/wsl.conf ]; then 57 | tmp="$(sed -nr "/^\[${1}\]/ { :l /^${2}[ ]*=/ { s/[^=]*=[ ]*//; p; q;}; n; b l;}" /etc/wsl.conf)" 58 | if [ -n "$tmp" ]; then 59 | if [ ${#tmp} -ge 2 ]; then 60 | if [ "${tmp:0:1}" == '"' ] && [ "${tmp: -1}" == '"' ]; then 61 | echo "${tmp:1:-1}" 62 | elif [ "${tmp:0:1}" == "'" ] && [ "${tmp: -1}" == "'" ]; then 63 | echo "${tmp:1:-1}" 64 | else 65 | echo "$tmp" 66 | fi 67 | else 68 | echo "$tmp" 69 | fi 70 | fi 71 | fi 72 | } 73 | 74 | # checking interopability 75 | if __wsl_conf_read interop enabled | grep false >/dev/null; then 76 | echo -e "WSL Interopability is disabled and WSL Utilities won't work. Please enable it by: 77 | 1. open /etc/wsl.conf using root or equivalent editing permission; 78 | 2. under [interop] section, set enabled to true; 79 | 3. restart your distribution." 80 | exit 1 81 | elif [ -f /proc/sys/fs/binfmt_misc/WSLInterop ] && grep -q '^disabled' /proc/sys/fs/binfmt_misc/WSLInterop; then 82 | echo "WSL Interopability is temporarily disabled and WSL Utilities won't work. Please enable it by: 83 | # echo 1 > /proc/sys/fs/binfmt_misc/WSLInterop" 84 | exit 1 85 | elif [ -f /proc/sys/fs/binfmt_misc/WSLInterop-late ] && grep -q '^disabled' /proc/sys/fs/binfmt_misc/WSLInterop-late; then 86 | echo "WSL Interopability is temporarily disabled and WSL Utilities won't work. Please enable it by: 87 | # echo 1 > /proc/sys/fs/binfmt_misc/WSLInterop-late" 88 | exit 1 89 | fi 90 | 91 | # when --verbose, verbose; when --debug, debug. 92 | # 93 | # They should not exist at the same time, otherwise 94 | # the output would be too messy. 95 | wslu_debug="" 96 | if [ "$1" == "--verbose" ]; then 97 | echo -e '\e[38;5;202m\033[1m[verbose] Showing verbose output. \033(B\033[m' 1>&2 98 | shift 99 | set -x 100 | elif [ "$1" == "--debug" ]; then 101 | wslu_debug="--debug" 102 | echo -e '\e[38;5;202m\033[1m[debug:'"${wslu_util_fullpath}"'] Showing debug output. \033(B\033[m' 1>&2 103 | shift 104 | fi 105 | 106 | # variables 107 | ## color 108 | black=$(echo -e '\e[30m') 109 | red=$(echo -e '\e[31m') 110 | green=$(echo -e '\e[32m') 111 | brown=$(echo -e '\e[33m') 112 | blue=$(echo -e '\e[34m') 113 | purple=$(echo -e '\e[35m') 114 | cyan=$(echo -e '\e[36m') 115 | yellow=$(echo -e '\e[33m') 116 | white=$(echo -e '\e[37m') 117 | dark_gray=$(echo -e '\e[1;30m') 118 | light_red=$(echo -e '\e[1;31m') 119 | light_green=$(echo -e '\e[1;32m') 120 | light_blue=$(echo -e '\e[1;34m') 121 | light_purple=$(echo -e '\e[1;35m') 122 | light_cyan=$(echo -e '\e[1;36m') 123 | light_gray=$(echo -e '\e[37m') 124 | orange=$(echo -e '\e[38;5;202m') 125 | light_orange=$(echo -e '\e[38;5;214m') 126 | deep_purple=$(echo -e '\e[38;5;140m') 127 | bold=$(echo -e '\033[1m') 128 | reset=$(echo -e '\033(B\033[m') 129 | 130 | ## indicator 131 | info="${green}[info]${reset}" 132 | input_info="${cyan}[input]${reset}" 133 | error="${red}[error]${reset}" 134 | warn="${orange}[warn]${reset}" 135 | 136 | ## Windows build number constant 137 | # Windows 10 138 | readonly BN_SPR_CREATORS=15063 #1703, Redstone 2, Creators Update 139 | readonly BN_FAL_CREATORS=16299 #1709, Redstone 3, Fall Creators Update 140 | readonly BN_APR_EIGHTEEN=17134 #1803, Redstone 4, April 2018 Update 141 | readonly BN_OCT_EIGHTEEN=17763 #1809, Redstone 5, October 2018 Update 142 | readonly BN_MAY_NINETEEN=18362 #1903, 19H1, May 2019 Update 143 | readonly BN_NOV_NINETEEN=18363 #1909, 19H2, November 2019 Update 144 | readonly BN_MAY_TWENTYTY=19041 #2004, 20H1, May 2020 Update 145 | readonly BN_OCT_NINETEEN=19042 #20H2, Windows 10 October 2020 Update 146 | readonly BN_MAY_TWNETONE=19043 #21H1, Windows 10 May 2021 Update 147 | readonly BN_NOV_TWENTONE=19044 #21H2, Windows 10 November 2021 Update 148 | # Windows 11 149 | readonly BN_ELEVEN_21H2=22000 #21H2, Windows 11 150 | 151 | # echo functions 152 | function debug_echo { 153 | [ "$wslu_debug" == "--debug" ] && echo "${orange}${bold}[debug:${wslu_util_fullpath}]${reset} $*" 1>&2; 154 | } 155 | 156 | function error_echo { 157 | echo "${error} $1" 158 | exit "$2" 159 | } 160 | 161 | # Check if the version number of bash is greater or equal to 4.4 162 | if [ "$bash_version_major" -lt 4 ] || { [ "$bash_version_major" -eq 4 ] && [ "$bash_version_minor" -lt 4 ]; }; then 163 | error_echo "Bash version is too old. Please upgrade to 4.4 or later." 1 164 | fi 165 | 166 | 167 | # source default config 168 | if [ -f "${wslu_dest_dir}${wslu_prefix}/share/wslu/conf" ]; then 169 | debug_echo "source default setting" 170 | source "${wslu_dest_dir}${wslu_prefix}/share/wslu/conf" 171 | fi 172 | 173 | # source user-defined config 174 | if [ -f "${wslu_dest_dir}${wslu_prefix}/share/wslu/custom.conf" ]; then 175 | debug_echo "${wslu_dest_dir}${wslu_prefix}/share/wslu/custom.conf found, sourcing" 176 | source "${wslu_dest_dir}${wslu_prefix}/share/wslu/custom.conf" 177 | fi 178 | 179 | if [ -f "${wslu_dest_dir}/etc/wslu/conf" ]; then 180 | debug_echo "${wslu_dest_dir}/etc/wslu/conf found, sourcing" 181 | source "${wslu_dest_dir}/etc/wslu/conf" 182 | fi 183 | 184 | if [ -f "/etc/wslu/custom.conf" ]; then 185 | debug_echo "/etc/wslu/custom.conf found, sourcing" 186 | source "/etc/wslu/custom.conf" 187 | fi 188 | 189 | if [ -f "$HOME/.config/wslu/conf" ]; then 190 | debug_echo "$HOME/.config/wslu/conf found, sourcing" 191 | source "$HOME/.config/wslu/conf" 192 | fi 193 | if [ -f "$HOME/.wslurc" ]; then 194 | debug_echo "$HOME/.wslurc found, sourcing" 195 | source "$HOME/.wslurc" 196 | fi 197 | 198 | # functions 199 | 200 | function help { 201 | app_name=$wslu_util_name 202 | echo -e "$app_name - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL) 203 | Usage: $2 204 | 205 | For more help for $app_name, please use the command \`man $app_name\` or visit the following site: https://wslutiliti.es/wslu/man/$app_name.html. 206 | For overall help, you can use the command \`man wslu\` or visite the following site: https://wslutiliti.es/wslu." 207 | } 208 | 209 | function version { 210 | echo "wslu v$wslu_version" 211 | } 212 | 213 | function double_dash_p { 214 | echo "${@//\\/\\\\}" 215 | } 216 | 217 | function interop_prefix { 218 | 219 | win_location="/mnt/" 220 | tmp="$(__wsl_conf_read automount root)" 221 | [ "$tmp" == "" ] || win_location="$tmp" 222 | [[ "$win_location" =~ ^.*/$ ]] || win_location="$win_location/" # make sure it always end with slash 223 | unset tmp 224 | echo "$win_location" 225 | 226 | unset win_location 227 | } 228 | 229 | function sysdrive_prefix { 230 | hard_reset=0 231 | for pt in "$(interop_prefix)"/*; do 232 | [[ -e "$pt" ]] || break 233 | if [ "$(echo "$pt" | wc -l)" -eq 1 ]; then 234 | if [ -d "$pt/Windows/System32" ]; then 235 | hard_reset=1 236 | pt=${pt%/} 237 | win_location="${pt##*/}" 238 | break 239 | fi 240 | fi 241 | done 242 | 243 | if [ $hard_reset -eq 0 ]; then 244 | win_location="c" 245 | fi 246 | 247 | echo "$win_location" 248 | 249 | unset win_location 250 | unset hard_reset 251 | } 252 | 253 | function wslu_get_build { 254 | build=$("$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/reg.exe query "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion" /v CurrentBuild | tail -n 2 | head -n 1 | sed -e 's|\r||g') 255 | echo "${build##* }" 256 | } 257 | 258 | function wslu_get_wsl_ver { 259 | wslutmpbuild="$(( $(wslu_get_build) + 0 ))" 260 | if [ $wslutmpbuild -ge $BN_MAY_NINETEEN ]; then 261 | # The environment variable only available in 19H1 or later. 262 | wslu_distro_regpath=$("$(interop_prefix)$(sysdrive_prefix)"/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 ) 263 | if "$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/reg.exe query "$wslu_distro_regpath" /v Flags &>/dev/null; then 264 | wslu_distro_version=$("$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/reg.exe query "$wslu_distro_regpath" /v Flags | tail -n 2 | head -n 1 | sed -e 's|\r||g') 265 | wslu_distro_version=${wslu_distro_version##* } 266 | wslu_distro_version_processed=$(( "$(printf "%d\n" "$wslu_distro_version")" / 8 )) 267 | if [ "$wslu_distro_version_processed" == "1" ]; then 268 | echo "2" 269 | elif [ "$wslu_distro_version_processed" == "0" ]; then 270 | echo "1" 271 | fi 272 | else 273 | echo "1" 274 | fi 275 | else 276 | echo "1" 277 | fi 278 | } 279 | 280 | function chcp_com { 281 | "$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/chcp.com "$@" >/dev/null 282 | } 283 | 284 | function winps_exec { 285 | debug_echo "winps_exec: called with command $*" 286 | if [[ "$WSLU_POWERSHELL_CHCP_WORKAROUND" == "true" ]]; then 287 | wslutmpbuild="$(wslu_get_build)" 288 | cp="$(cat "${wslu_state_dir}"/oemcp)" 289 | [ "$wslutmpbuild" -ge $BN_OCT_NINETEEN ] || chcp_com "$cp" 290 | "$(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); $*" 291 | EXIT_STATUS=$? 292 | [ "$wslutmpbuild" -ge $BN_OCT_NINETEEN ] || chcp_com 65001 293 | return $EXIT_STATUS 294 | else 295 | "$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "$*" 296 | EXIT_STATUS=$? 297 | return $EXIT_STATUS 298 | fi 299 | } 300 | 301 | function cmd_exec { 302 | debug_echo "cmd_exec: called with command $*" 303 | "$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/cmd.exe /c "$@" 304 | EXIT_STATUS=$? 305 | return $EXIT_STATUS 306 | } 307 | 308 | function baseexec_gen { 309 | debug_echo "baseexec_gen: called" 310 | wslutmpbuild="$(( $(wslu_get_build) + 0 ))" 311 | debug_echo "baseexec_gen: winbuild: $wslutmpbuild" 312 | if [ $wslutmpbuild -ge $BN_MAY_NINETEEN ]; then 313 | # The environment variable only available in 19H1 or later. 314 | debug_echo "baseexec_gen: 19H1 or higher" 315 | 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 ) 316 | if "$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/reg.exe query "$wslu_distro_regpath" /v PackageFamilyName &>/dev/null; then 317 | 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') 318 | # if it is a store distro 319 | debug_echo "baseexec_gen: store distro: $wslu_distro_packagename" 320 | wslu_distro_packagename=${wslu_distro_packagename##* } 321 | wslu_base_exec_folder_path="$(wslpath "$(winps_exec "[Environment]::GetFolderPath('LocalApplicationData')" | tr -d "\r")\\Microsoft\\WindowsApps\\$wslu_distro_packagename")" 322 | debug_echo "baseexec_gen: base_exe_folder_path: $wslu_base_exec_folder_path" 323 | if find "$wslu_base_exec_folder_path" -name "*.exe" -print -quit &>/dev/null; then 324 | debug_echo "baseexec_gen: found exe in wslu_base_exec_folder_path" 325 | wslpath -w "$(find "$wslu_base_exec_folder_path" -name "*.exe" -print -quit)" > "${wslu_state_dir}"/baseexec 326 | else 327 | debug_echo "baseexec_gen: do not have base exec in the folder; use fallback" 328 | echo "$(wslpath -w "$(interop_prefix)$(sysdrive_prefix)")\\Windows\\System32\\wsl.exe" > "${wslu_state_dir}"/baseexec 329 | fi 330 | else 331 | debug_echo "baseexec_gen: imported distro" 332 | # if it is imported distro 333 | echo "$(wslpath -w "$(interop_prefix)$(sysdrive_prefix)")Windows\\System32\\wsl.exe" > "${wslu_state_dir}"/baseexec 334 | fi 335 | else 336 | debug_echo "baseexec_gen: fallback mode" 337 | # older version fallback. 338 | echo "$(wslpath -w "$(interop_prefix)$(sysdrive_prefix)")\\Windows\\System32\\wsl.exe" > "${wslu_state_dir}"/baseexec 339 | fi 340 | } 341 | 342 | function var_gen { 343 | debug_echo "var_gen: called" 344 | date +"%s" > "${wslu_state_dir}"/triggered_time 345 | 346 | rm -f "${wslu_state_dir}"/baseexec 347 | rm -f "${wslu_state_dir}"/oemcp 348 | 349 | # generate oem codepage 350 | "$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/reg.exe query "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage" /v OEMCP 2>&1 | sed -n 3p | sed -e 's|\r||g' | grep -o '[[:digit:]]*' > "${wslu_state_dir}"/oemcp 351 | # generate base exe location 352 | baseexec_gen 353 | 354 | } 355 | 356 | function wslu_function_check { 357 | # from https://stackoverflow.com/questions/85880/determine-if-a-function-exists-in-bash 358 | debug_echo "wslu_function_check: called with $*" 359 | declare -f -F "$1" > /dev/null 360 | return $? 361 | } 362 | 363 | function wslu_file_check { 364 | debug_echo "wslu_file_check: called with $*" 365 | should_i_show="" 366 | [[ "$3" == "?!S" ]] && should_i_show="n" 367 | 368 | if [[ ! -f "$1/$2" ]]; then 369 | [[ -z "$should_i_show" ]] && echo "${warn} $2 not found in Windows directory. Copying right now..." 370 | [[ -d "$1" ]] || mkdir "$1" 371 | if [[ -f "/usr/share/wslu/$2" ]]; then 372 | cp "/usr/share/wslu/$2" "$1" 373 | [[ -z "$should_i_show" ]] && echo "${info} $2 copied. Located at \"$1\"." 374 | else 375 | [[ -z "$should_i_show" ]] && echo "${error} $2 not found. Failed to copy." 376 | exit 30 377 | fi 378 | fi 379 | } 380 | 381 | function wslpy_check { 382 | debug_echo "wslpy_check" 383 | if type python3 > /dev/null 2>&1; then 384 | debug_echo "wslpy_check: python3 installed." 385 | tmp_wslpy_ver="$(python3 -c "import wslpy; print(wslpy.__version__)" 2>/dev/null)" 386 | if [[ "$tmp_wslpy_ver" != "" ]]; then 387 | debug_echo "wslpy_check: wslpy installed." 388 | older_ver="$(echo -e "$tmp_wslpy_ver\n0.1.0" | sort -n -t. | head -n1)" 389 | if [[ "$older_ver" == "$tmp_wslpy_ver" ]]; then 390 | debug_echo "wslpy_check: wslpy installed but a version < 0.1.0 is installed." 391 | return 1 392 | else 393 | debug_echo "wslpy_check: wslpy >= 0.1.0 is installed." 394 | return 395 | fi 396 | else 397 | debug_echo "wslpy_check: wslpy not installed." 398 | return 1 399 | fi 400 | else 401 | debug_echo "wslpy_check: python3 not installed." 402 | return 1 403 | fi 404 | } 405 | 406 | 407 | # pre_check to make sure WSL_INTEROP is properly set in WSL2 408 | if [ "$(wslu_get_wsl_ver)" == "2" ] && [ -z "$WSL_INTEROP" ]; then 409 | for i in $(pstree -np -s $$ | grep -o -E '[0-9]+'); do 410 | if [[ -e "/run/WSL/${i}_interop" ]]; then 411 | export WSL_INTEROP=/run/WSL/${i}_interop 412 | fi 413 | done 414 | fi 415 | 416 | # first run, saving some information 417 | if [ ! -d ~/.config/wslu ]; then 418 | debug_echo "first run; creating ~/.config/wslu" 419 | mkdir -p ~/.config/wslu 420 | fi 421 | 422 | # This gets tirggered then: 423 | # 1. if it's the first time the script is triggered, i.e., 424 | # ${wslu_state_dir}/triggered time 425 | # 2. if update_time is also not present, i.e., 426 | # badly installed packages or installed via install script 427 | if [ ! -f "${wslu_state_dir}"/triggered_time ] || [ ! -f /usr/share/wslu/updated_time ]; then 428 | debug_echo "first run or update_time not present; calling var_gen" 429 | var_gen 430 | # This gets triggered when: 431 | # installed time is larger than the last triggered time 432 | elif [ "$(cat "${wslu_state_dir}"/triggered_time)" -lt "$(cat /usr/share/wslu/updated_time)" ]; then 433 | debug_echo "upgraded package; calling var_gen" 434 | var_gen 435 | fi 436 | 437 | # basic distro detection 438 | distro="$(sed -n -e '/^NAME=.*/p' /etc/os-release | sed -e 's/^NAME=\"//g')" 439 | case $distro in 440 | *Clear\ Linux*) distro="clear";; 441 | *Common\ Base\ Linux\ Mariner*) distro="cblm";; 442 | *Pengwin*) distro="pengwin";; 443 | *WLinux*) distro="wlinux";; 444 | Ubuntu*) distro="ubuntu";; 445 | *Debian*) distro="debian";; 446 | *Kali*) distro="kali";; 447 | openSUSE*) distro="opensuse";; 448 | SLES*) distro="sles";; 449 | Alpine*) distro="alpine";; 450 | Arch*) distro="archlinux";; 451 | *Oracle*) distro="oracle";; 452 | AlmaLinux*) distro="almalinux";; 453 | Scientific*) distro="scilinux";; 454 | *Fedora\ Remix\ for\ WSL*) distro="fedoraremix";; 455 | *Fedora*) distro="fedora";; 456 | *Gentoo*) distro="gentoo";; 457 | *Generic*) [ "fedora" == "$(grep -e "LIKE=" /etc/os-release | sed -e 's/ID_LIKE=//g')" ] && distro="oldfedora" || distro="unknown";; 458 | *) distro="unknown";; 459 | esac 460 | 461 | debug_echo "distro: $distro" 462 | -------------------------------------------------------------------------------- /src/wslupath.sh: -------------------------------------------------------------------------------- 1 | # shellcheck shell=bash 2 | ########## CAUTION ########### 3 | ## wslupath is a legacy cli for backward compatbility. 4 | ## Use it unless it is necessary. 5 | 6 | style=1 7 | reg_path=0 8 | set_path="" 9 | 10 | help_short="wslupath [-dOr] [-D|-A|-T|-S|-W|-s|-su|-H|-P|...NAME...]\nwslupath [-h|-v|-R]" 11 | 12 | function path_double_dash { 13 | new_path="${*//\\/\\\\}" 14 | echo "$new_path" 15 | } 16 | 17 | function general_converter { 18 | target="$*" 19 | 20 | if [[ $target =~ ^[A-Z]:(\\[^:\\]+)*(\\)?$ ]]; then 21 | p=$(wslpath -u "${target}") 22 | elif [[ $target =~ ^$(interop_prefix)[A-Za-z](/[^/]+)*(/)?$ ]]; then 23 | p=$(wslpath -w "${target}") 24 | else 25 | echo "${error} No proper path form detected: ""$*""." 26 | exit 20 27 | fi 28 | echo "$p" 29 | } 30 | 31 | function style_path { 32 | case $style in 33 | 1) p="$(general_converter "$@")";; 34 | 2) p="$*";; 35 | 3) p="$(path_double_dash "$@")";; 36 | esac 37 | echo "$p" 38 | } 39 | 40 | if [[ $# -eq 0 ]]; then 41 | echo -e "$help_short" 42 | exit 20 43 | else 44 | for args; do 45 | case $args in 46 | #styles 47 | -r|--reg-data) reg_path=1;; 48 | -O|--original) style=2;; 49 | -d|--doubledash-dir) style=3;; 50 | ## system location 51 | 52 | -D|--desktop) 53 | set_path="$(style_path "$(wslvar -l 'Desktop')")" 54 | break;; 55 | -A|--appdata) 56 | set_path="$(style_path "$(wslvar -s APPDATA)")" 57 | break;; 58 | -T|--temp) 59 | set_path="$(style_path "$(wslvar -s TMP)")" 60 | break;; 61 | -S|--sysdir) 62 | set_path="$(style_path "$(wslvar -s windir)"\\System32)" 63 | break;; 64 | -W|--windir) 65 | set_path="$(style_path "$(wslvar -s windir)")" 66 | break;; 67 | -s|--start-menu) 68 | set_path="$(style_path "$(wslvar -l 'Start Menu')")" 69 | break;; 70 | -su|--startup) 71 | set_path="$(style_path "$(wslvar -l 'Startup')")" 72 | break;; 73 | -H|--home) 74 | set_path="$(style_path "$(wslvar HOMEDRIVE)""$(wslvar HOMEPATH)")" 75 | break;; 76 | -P|--program-files) 77 | set_path="$(style_path "$(wslvar -s ProgramFiles)")" 78 | break;; 79 | -h|--help) help "$0" "$help_short"; exit;; 80 | -v|--version) version; exit;; 81 | -R|--avail-reg) echo "Available registery input:" 82 | wslvar -L 83 | exit;; 84 | *) 85 | if [[ "$reg_path" == "1" ]]; then 86 | set_path="$(style_path "$(wslvar -l "$args")")" 87 | else 88 | set_path="$(style_path "$args")" 89 | fi 90 | break;; 91 | esac 92 | done 93 | fi 94 | 95 | if [[ "$set_path" == "" ]]; then 96 | echo "${error}No path input. Aborted." 97 | exit 21 98 | else 99 | echo "$set_path" 100 | fi 101 | -------------------------------------------------------------------------------- /src/wslusc.sh: -------------------------------------------------------------------------------- 1 | # shellcheck shell=bash 2 | cname="" 3 | iconpath="" 4 | is_gui=0 5 | is_interactive=0 6 | customname="" 7 | customenv="" 8 | base_converter_engine=${WSLUSC_BASE_CONVERTER_ENGINE:-"imagemagick"} 9 | 10 | help_short="wslusc [-IsgN] [-d SHORTCUT_FILE] [-e PATH] [-n NAME] [-i FILE] COMMAND\nwslusc [-hv]" 11 | 12 | PARSED_ARGUMENTS=$(getopt -a -n "${wslu_util_name##*/}" -o hvd:Ie:n:i:gNs --long help,version,shortcut-debug:,interactive,path:,name:,icon:,gui,native,smart-icon -- "$@") 13 | #shellcheck disable=SC2181 14 | [ "$?" != "0" ] && help "$wslu_util_name" "$help_short" 15 | 16 | function sc_debug { 17 | debug_echo "sc_debug: called with $*" 18 | dp="$(double_dash_p "$(wslvar -l Desktop)")" 19 | 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('$dp\\$*');\$s;" 20 | } 21 | 22 | debug_echo "Parsed: $PARSED_ARGUMENTS" 23 | eval set -- "$PARSED_ARGUMENTS" 24 | while : 25 | do 26 | case "$1" in 27 | -d|--shortcut-debug) shift; sc_debug "$@"; exit;; 28 | -I|--interactive) is_interactive=1;shift;; 29 | -i|--icon) shift; iconpath=$1;shift;; 30 | -s|--smart-icon) shift; WSLUSC_SMART_ICON_DETECTION="true";shift;; 31 | -n|--name) shift;customname=$1;shift;; 32 | -e|--env) shift;customenv=$1;shift;; 33 | -g|--gui) is_gui=1;shift;; 34 | -N|--native) WSLUSC_GUITYPE="native";shift;; 35 | -h|--help) help "$0" "$help_short"; exit;; 36 | -v|--version) version; exit;; 37 | --) shift; cname_header="$1"; shift; cname="$*"; break;; 38 | esac 39 | done 40 | debug_echo "cname_header: $cname_header cname: $cname" 41 | # interactive mode 42 | if [[ $is_interactive -eq 1 ]]; then 43 | echo "${info} Welcome to wslu shortcut creator interactive mode." 44 | read -r -e -i "$cname_header" -p "${input_info} Command (Without Parameter): " input 45 | cname_header="${input:-$cname_header}" 46 | read -r -e -i "$cname" -p "${input_info} Command param: " input 47 | cname="${input:-$cname}" 48 | read -r -e -i "$customname" -p "${input_info} Shortcut name [optional, ENTER for default]: " input 49 | customname="${input:-$customname}" 50 | read -r -e -i "$is_gui" -p "${input_info} Is it a GUI application? [if yes, input 1; if no, input 0]: " input 51 | is_gui=$(( ${input:-$is_gui} + 0 )) 52 | read -r -e -i "$customenv" -p "${input_info} Pre-executed command [optional, ENTER for default]: " input 53 | customenv="${input:-$customenv}" 54 | read -r -e -i "$iconpath" -p "${input_info} Custom icon Linux path (support ico/png/xpm/svg) [optional, ENTER for default]: " input 55 | iconpath="${input:-$iconpath}" 56 | fi 57 | 58 | # supported gui check 59 | if [ "$(wslu_get_build)" -lt 21332 ] && [[ "$gui_type" == "NATIVE" ]]; then 60 | error_echo "Your Windows 10 version do not support Native GUI, You need at least build 21332. Aborted" 35 61 | fi 62 | 63 | if [[ "$cname_header" != "" ]]; then 64 | up_path="$(wslvar -s USERPROFILE)" 65 | tpath=$(double_dash_p "$(wslvar -s TMP)") # Windows Temp, Win Double Sty. 66 | tpath="${tpath:-$(double_dash_p "$(wslvar -s TEMP)")}" # sometimes TMP is not set for some reason 67 | dpath=$(wslpath "$(wslvar -l Desktop)") # Windows Desktop, WSL Sty. 68 | script_location="$(wslpath "$up_path")/wslu" # Windows wslu, Linux WSL Sty. 69 | script_location_win="$(double_dash_p "$up_path")\\wslu" # Windows wslu, Win Double Sty. 70 | distro_location_win="$(double_dash_p "$(cat "${wslu_state_dir}"/baseexec)")" # Distro Location, Win Double Sty. 71 | 72 | # change param according to the exec. 73 | distro_param="run" 74 | 75 | if [[ "$distro_location_win" == *wsl\.exe* ]]; then 76 | if [ "$(wslu_get_build)" -ge "$BN_MAY_NINETEEN" ]; then 77 | distro_param="-d $WSL_DISTRO_NAME -e" 78 | else 79 | distro_param="-e" 80 | fi 81 | fi 82 | 83 | # handling the execuable part, a.k.a., cname_header 84 | # always absolute path 85 | tmp_cname_header="$(readlink -f "$cname_header")" 86 | if [ ! -f "$tmp_cname_header" ]; then 87 | cname_header="$(command -v "$cname_header")" 88 | else 89 | cname_header="$tmp_cname_header" 90 | fi 91 | unset tmp_cname_header 92 | 93 | [ -z "$cname_header" ] && error_echo "Bad or invalid input; Aborting" 30 94 | 95 | # handling no name given case 96 | new_cname="${cname_header##*/}" 97 | # handling name given case 98 | if [[ "$customname" != "" ]]; then 99 | new_cname=$customname 100 | fi 101 | 102 | # construct full command 103 | #shellcheck disable=SC2001 104 | cname="\"$(echo "$cname_header" | sed "s| |\\\\ |g") $cname\"" 105 | 106 | # Check default icon and runHidden.vbs 107 | wslu_file_check "$script_location" "wsl.ico" 108 | wslu_file_check "$script_location" "wsl-term.ico" 109 | wslu_file_check "$script_location" "wsl-gui.ico" 110 | wslu_file_check "$script_location" "runHidden.vbs" 111 | 112 | # handling icon 113 | if [[ "$iconpath" != "" ]] || [[ "$WSLUSC_SMART_ICON_DETECTION" == "true" ]]; then 114 | #handling smart icon first; always first 115 | if [[ "$WSLUSC_SMART_ICON_DETECTION" == "true" ]]; then 116 | if wslpy_check; then 117 | tmp_fcname="${cname_header##*/}" 118 | iconpath="$(python3 -c "import wslpy.__internal__; print(wslpy.__internal__.find_icon(\"$tmp_fcname\"))")" 119 | echo "${info} Icon Detector found icon $tmp_fcname at: $iconpath" 120 | else 121 | echo "${warn} Icon Detector cannot find icon." 122 | fi 123 | fi 124 | 125 | # normal detection section 126 | icon_filename="${iconpath##*/}" 127 | ext="${iconpath##*.}" 128 | 129 | if [[ ! -f $iconpath ]]; then 130 | iconpath="$(double_dash_p "$up_path")\\wslu\\wsl.ico" 131 | echo "${warn} Icon not found. Reset to default icon..." 132 | else 133 | echo "${info} You choose to use custom icon: $iconpath. Processing..." 134 | cp "$iconpath" "$script_location" 135 | 136 | if [[ "$ext" != "ico" ]]; then 137 | if [[ "${base_converter_engine}" = "ffmpeg" ]] && ! type ffmpeg > /dev/null; then 138 | echo "The 'ffmpeg' command is needed for converting the icon with 'ffmpeg' Engine." 139 | if [ -x /usr/lib/command-not-found ]; then 140 | echo " It can be installed with:" >&2 141 | echo "" >&2 142 | /usr/lib/command-not-found ffmpeg 2>&1 | grep -E -v '(not found|^$)' >&2 143 | else 144 | echo "It can usally be installed in your package manager as 'ffmpeg'." 145 | fi 146 | exit 22 147 | elif ! type convert > /dev/null; then 148 | echo "The 'convert' command is needed for converting the icon with 'imagemagick' Engine." 149 | if [ -x /usr/lib/command-not-found ]; then 150 | echo " It can be installed with:" >&2 151 | echo "" >&2 152 | /usr/lib/command-not-found convert 2>&1 | grep -E -v '(not found|^$)' >&2 153 | else 154 | echo "It can usally be found in the imagemagick package, please install it." 155 | fi 156 | exit 22 157 | fi 158 | if [[ "${base_converter_engine}" = "ffmpeg" ]]; then 159 | if [[ "$ext" == "svg" ]]; then 160 | echo "${info} Converting $ext icon to ico..." 161 | echo "${warn} ffmpeg is not designed for converting svg to ico, the result may not be satisfactory." 162 | if ffmpeg -encoders | grep svg > /dev/null; then 163 | ffmpeg -hide_banner -loglevel panic -i "$script_location/$icon_filename" -width 256 -height 256 -keep_ar false -vf scale=256:256 "$script_location/${icon_filename%."$ext"}.ico" 164 | else 165 | error_echo "${warn} ffmpeg is not compiled with svg support, please compile it with svg support. Aborted." 22 166 | fi 167 | rm "$script_location/$icon_filename" 168 | icon_filename="${icon_filename%."$ext"}.ico" 169 | elif [[ "$ext" == "png" ]] || [[ "$ext" == "xpm" ]]; then 170 | echo "${info} Converting $ext icon to ico..." 171 | ffmpeg -hide_banner -loglevel panic -i "$script_location/$icon_filename" -vf scale=256:256 "$script_location/${icon_filename%."$ext"}.ico" 172 | rm "$script_location/$icon_filename" 173 | icon_filename="${icon_filename%."$ext"}.ico" 174 | else 175 | error_echo "wslusc only support creating shortcut using .png/.svg/.ico icon with ffmpeg engine. Aborted." 22 176 | fi 177 | else 178 | if [[ "$ext" == "svg" ]]; then 179 | echo "${info} Converting $ext icon to ico..." 180 | convert "$script_location/$icon_filename" -trim -background none -resize 256X256 -define 'icon:auto-resize=16,24,32,64,128,256' "$script_location/${icon_filename%."$ext"}.ico" 181 | rm "$script_location/$icon_filename" 182 | icon_filename="${icon_filename%."$ext"}.ico" 183 | elif [[ "$ext" == "png" ]] || [[ "$ext" == "xpm" ]]; then 184 | echo "${info} Converting $ext icon to ico..." 185 | convert "$script_location/$icon_filename" -resize 256X256 "$script_location/${icon_filename%."$ext"}.ico" 186 | rm "$script_location/$icon_filename" 187 | icon_filename="${icon_filename%."$ext"}.ico" 188 | else 189 | error_echo "wslusc only support creating shortcut using .png/.svg/.xpm/.ico icon with imagemagick engine. Aborted." 22 190 | fi 191 | fi 192 | fi 193 | iconpath="$script_location_win\\$icon_filename" 194 | fi 195 | else 196 | if [[ "$is_gui" == "1" ]]; then 197 | iconpath="$(double_dash_p "$up_path")\\wslu\\wsl-gui.ico" 198 | else 199 | iconpath="$(double_dash_p "$up_path")\\wslu\\wsl-term.ico" 200 | fi 201 | fi 202 | 203 | # handling custom vairable command 204 | if [[ "$customenv" != "" ]]; then 205 | echo "${info} the following custom variable/command will be applied: $customenv" 206 | fi 207 | 208 | if [[ "$is_gui" == "1" ]]; then 209 | if [[ "$WSLUSC_GUITYPE" == "legacy" ]]; then 210 | 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();" 211 | elif [[ "$WSLUSC_GUITYPE" == "native" ]]; then 212 | 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\\wslg.exe';\$s.Arguments='~ -d $WSL_DISTRO_NAME $customenv $cname';\$s.IconLocation='$iconpath';\$s.Save();" 213 | else 214 | error_echo "bad GUI type, aborting" 22 215 | fi 216 | else 217 | 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();" 218 | fi 219 | tpath="$(wslpath "$tpath")/$new_cname.lnk" 220 | mv "$tpath" "$dpath" 221 | echo "${info} Create shortcut ${new_cname}.lnk successful" 222 | else 223 | error_echo "No input, aborting" 21 224 | fi 225 | -------------------------------------------------------------------------------- /src/wslvar.sh: -------------------------------------------------------------------------------- 1 | # shellcheck shell=bash 2 | var_type=${WSLVAR_DEFAULT_VARTYPE:-1} 3 | 4 | help_short="wslvar [-sl] NAME\nwslvar [-hvSL]" 5 | 6 | function call_shell { 7 | winps_exec "(Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders').'$*'" | cat 8 | } 9 | 10 | function view_shell { 11 | winps_exec "Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders'"| tail -n +3 | head -n -10 12 | } 13 | 14 | function call_sys { 15 | winps_exec "Write-Output \${Env:$*}" | cat 16 | } 17 | 18 | function view_sys { 19 | winps_exec "Get-ChildItem env:" | tail -n +2 | head -n -2 20 | } 21 | 22 | function cl_destoryer { 23 | echo "$@" | tr -d "\r" 24 | } 25 | 26 | function caller { 27 | if [ "$*" != "" ]; then 28 | case $var_type in 29 | 1) p="$(cl_destoryer "$(call_sys "$@")")";; 30 | 2) p="$(cl_destoryer "$(call_shell "$@")")";; 31 | *) error_echo "Invalid variable type. Aborted." 22;; 32 | esac 33 | echo "$p" 34 | else 35 | error_echo "No Input. Aborted." 21 36 | fi 37 | } 38 | 39 | while [ "$1" != "" ]; do 40 | case "$1" in 41 | -s|--sys) var_type=1; shift;; 42 | -l|--shell) var_type=2; shift;; 43 | -S|--getsys) view_sys; exit;; 44 | -L|--getshell) view_shell; exit;; 45 | -h|--help) help "$0" "$help_short"; exit;; 46 | -v|--version) version; exit;; 47 | *) caller "$@"; exit;; 48 | esac 49 | done 50 | 51 | error_echo "No Input. Aborted." 21 52 | 53 | -------------------------------------------------------------------------------- /src/wslview.sh: -------------------------------------------------------------------------------- 1 | # shellcheck shell=bash 2 | lname="" 3 | skip_validation_check=${WSLVIEW_SKIP_VALIDATION_CHECK:-1} 4 | 5 | help_short="$0 [-ehsvurE]\n$0 [-E ENGINE] LINK/FILE" 6 | 7 | function fileprotocoldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } 8 | 9 | function del_reg_alt { 10 | if [ "$distro" == "archlinux" ] || [ "$distro" == "alpine" ]; then 11 | error_echo "Unsupported action for this distro. Aborted." 34 12 | exit 34 13 | else 14 | sudo update-alternatives --remove x-www-browser "$(readlink -f "$0")" 15 | sudo update-alternatives --remove www-browser "$(readlink -f "$0")" 16 | exit 17 | fi 18 | } 19 | 20 | function add_reg_alt { 21 | if [ "$distro" == "archlinux" ] || [ "$distro" == "alpine" ]; then 22 | error_echo "Unsupported action for this distro. Aborted." 34 23 | else 24 | sudo update-alternatives --install "$wslu_prefix"/bin/x-www-browser x-www-browser "$(readlink -f "$0")" 1 25 | sudo update-alternatives --install "$wslu_prefix"/bin/www-browser www-browser "$(readlink -f "$0")" 1 26 | exit 27 | fi 28 | } 29 | 30 | function add_browser_export { 31 | # find all possible shell rc file and append export BROWSER="/usr/bin/wslview" at the end; if found existing export, comment it out 32 | # Define the shell rc files to search 33 | rc_files=(".bashrc" ".zshrc" ".kshrc" ".cshrc" ".tcshrc") 34 | 35 | # Loop over each file 36 | for rc_file in "${rc_files[@]}"; do 37 | # Check if the file exists 38 | if [ -f "$HOME/$rc_file" ]; then 39 | echo "Processing $rc_file..." 40 | 41 | # Comment out existing BROWSER export 42 | if grep -q "export BROWSER=" "$HOME/$rc_file"; then 43 | echo "Commenting out existing BROWSER export in $rc_file..." 44 | $SED -i 's/^export BROWSER=/#export BROWSER=/' "$HOME/$rc_file" 45 | fi 46 | 47 | # Append new BROWSER export 48 | echo "Appending new BROWSER export to $rc_file..." 49 | echo 'export BROWSER="/usr/bin/wslview"' >> "$HOME/$rc_file" 50 | fi 51 | done 52 | } 53 | 54 | function url_validator { 55 | content=$(curl --head --silent -g "$*" | head -n 1) 56 | if [ -n "$content" ]; then 57 | return 0 58 | else 59 | return 1 60 | fi 61 | } 62 | 63 | 64 | while [ "$1" != "" ]; do 65 | case "$1" in 66 | -s|--skip-validation-check) skip_validation_check=0; shift;; 67 | -r|--reg-as-browser) add_reg_alt;; 68 | -u|--unreg-as-browser) del_reg_alt;; 69 | -e|--export-as-browser) add_browser_export;; 70 | -h|--help) help "$0" "$help_short"; exit;; 71 | -v|--version) version; exit;; 72 | -E|--engine) shift; WSLVIEW_DEFAULT_ENGINE="$1"; shift;; 73 | *) lname="$*";break;; 74 | esac 75 | done 76 | 77 | debug_echo "lname: $lname" 78 | debug_echo "WSLVIEW_DEFAULT_ENGINE: $WSLVIEW_DEFAULT_ENGINE" 79 | 80 | if [[ "$lname" != "" ]]; then 81 | wslutmpbuild=$(wslu_get_build) 82 | # file:/// protocol used in linux 83 | if [[ "$lname" =~ ^file:\/\/.*$ ]] && [[ ! "$lname" =~ ^file:\/\/(\/)+[A-Za-z]\:.*$ ]]; then 84 | debug_echo "Received file:/// protocol used in linux" 85 | # convert before set 86 | lname="$(fileprotocoldecode "$lname")" 87 | [ "$wslutmpbuild" -ge "$BN_MAY_NINETEEN" ] || error_echo "This protocol is not supported before version 1903." 34 88 | properfile_full_path="$(readlink -f "${lname//file:\/\//}")" 89 | # Linux absolute path 90 | elif [[ "$lname" =~ ^(/[^/]+)*(/)?$ ]]; then 91 | debug_echo "Received linux absolute path" 92 | [ "$wslutmpbuild" -ge "$BN_MAY_NINETEEN" ] || error_echo "This protocol is not supported before version 1903." 34 93 | properfile_full_path="$(readlink -f "${lname}")" 94 | # Linux relative path 95 | elif [[ -d "$(readlink -f "$lname")" ]] || [[ -f "$(readlink -f "$lname")" ]]; then 96 | debug_echo "Received linux relative path" 97 | [ "$wslutmpbuild" -ge "$BN_MAY_NINETEEN" ] || error_echo "This protocol is not supported before version 1903." 34 98 | properfile_full_path="$(readlink -f "${lname}")" 99 | fi 100 | debug_echo "properfile_full_path: $properfile_full_path" 101 | if [ "$skip_validation_check" -eq 0 ]; then 102 | debug_echo "Skipping validation check" 103 | is_valid_url=0 104 | else 105 | debug_echo "Validating whether if it is a link" 106 | is_valid_url=$(url_validator "$lname") 107 | fi 108 | if [[ "$is_valid_url" -eq 0 ]] && [ -z "$properfile_full_path" ]; then 109 | debug_echo "It is a link" 110 | cmd="\"$lname\"" 111 | elif [[ "$lname" =~ ^file:\/\/(\/)+[A-Za-z]\:.*$ ]] || [[ "$lname" =~ ^[A-Za-z]\:.*$ ]]; then 112 | debug_echo "It is not a link; received windows absolute path/file protocol windows absolute path" 113 | cmd="\"$lname\"" 114 | else 115 | debug_echo "It is not a link" 116 | cmd="\"$(wslpath -w "${properfile_full_path:-$lname}" 2>/dev/null || echo "$lname")\"" 117 | fi 118 | debug_echo "cmd: $cmd" 119 | if [[ "$WSLVIEW_DEFAULT_ENGINE" == "powershell" ]]; then 120 | winps_exec Start "${cmd}" 121 | elif [[ "$WSLVIEW_DEFAULT_ENGINE" == "cmd" ]]; then 122 | cmd_exec start "${cmd}" 123 | elif [[ "$WSLVIEW_DEFAULT_ENGINE" == "cmd_explorer" ]]; then 124 | cmd_exec explorer.exe "${cmd}" 125 | fi 126 | else 127 | error_echo "No input, aborting" 21 128 | fi 129 | -------------------------------------------------------------------------------- /tests/header.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | #header testing 4 | @test "Header - Colortesting 1" { 5 | color="$(. src/wslu-header;echo -e $black | cat -A)" 6 | [ "$color" = "^[[30m$" ] 7 | } 8 | 9 | @test "Header - Colortesting 2" { 10 | color="$(. src/wslu-header;echo -e $light_red | cat -A)" 11 | [ "$color" = "^[[1;31m$" ] 12 | } 13 | 14 | @test "Header - colortesting 3" { 15 | color="$(. src/wslu-header;echo -e $orange | cat -A)" 16 | [ "$color" = "^[[38;5;202m$" ] 17 | } 18 | 19 | @test "Header - Format 1" { 20 | format="$(. src/wslu-header;echo -e $bold | cat -A)" 21 | [ "$format" = "^[[1m$" ] 22 | } 23 | 24 | @test "Header - Format 2" { 25 | format="$(. src/wslu-header;echo -e $reset | cat -A)" 26 | [ "$format" = "^[(B^[[m$" ] 27 | } 28 | 29 | @test "Header - Windows Build" { 30 | format="$(. src/wslu-header;echo -e $BN_OCT_EIGHTEEN)" 31 | [ "$format" = "17763" ] 32 | } 33 | 34 | @test "Header - Indicator" { 35 | format="$(. src/wslu-header;echo -e $info | cat -A)" 36 | [ "$format" = "^[[32m[info]^[(B^[[m$" ] 37 | } 38 | 39 | @test "Header - Double Dash Parsing" { 40 | format="$(. src/wslu-header; echo "$(double_dash_p "\\")")" 41 | [ "$format" = "\\\\" ] 42 | } 43 | 44 | @test "Header - Interop Prefix" { 45 | format="$(. src/wslu-header; echo "$(interop_prefix)")" 46 | [ "$format" = "/mnt/" ] 47 | } 48 | 49 | @test "Header - System Drive Prefix" { 50 | format="$(. src/wslu-header; echo "$(sysdrive_prefix)")" 51 | [ "$format" = "c" ] 52 | } -------------------------------------------------------------------------------- /tests/wslact.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | #wslact testing 4 | @test "wslact - Help" { 5 | run out/wslact --help 6 | [ "${lines[0]}" = "wslact - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 7 | [ "${lines[1]}" = "Usage: wslact COMMAND ..." ] 8 | } 9 | 10 | @test "wslact - Help - Alt." { 11 | run out/wslact -h 12 | [ "${lines[0]}" = "wslact - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 13 | [ "${lines[1]}" = "Usage: wslact COMMAND ..." ] 14 | } 15 | 16 | @test "wslact - Time Sync - Help" { 17 | run out/wslact time-sync --help 18 | [ "${lines[0]}" = "wslact - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 19 | [ "${lines[1]}" = "Usage: wslact time-reset [-h]" ] 20 | } 21 | 22 | @test "wslact - Time Sync - Help - Alt." { 23 | run out/wslact time-sync -h 24 | [ "${lines[0]}" = "wslact - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 25 | [ "${lines[1]}" = "Usage: wslact time-reset [-h]" ] 26 | } 27 | 28 | @test "wslact - Time Sync - short form - Help" { 29 | run out/wslact ts --help 30 | [ "${lines[0]}" = "wslact - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 31 | [ "${lines[1]}" = "Usage: wslact time-reset [-h]" ] 32 | } 33 | 34 | @test "wslact - Time Sync - short form - Help - Alt." { 35 | run out/wslact ts -h 36 | [ "${lines[0]}" = "wslact - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 37 | [ "${lines[1]}" = "Usage: wslact time-reset [-h]" ] 38 | } 39 | 40 | @test "wslact - Smart Mounting - Help" { 41 | run out/wslact auto-mount --help 42 | [ "${lines[0]}" = "wslact - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 43 | [ "${lines[1]}" = "Usage: wslact auto-mount [-mh]" ] 44 | } 45 | 46 | @test "wslact - Smart Mounting - Help - Alt." { 47 | run out/wslact auto-mount -h 48 | [ "${lines[0]}" = "wslact - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 49 | [ "${lines[1]}" = "Usage: wslact auto-mount [-mh]" ] 50 | } 51 | 52 | @test "wslact - Smart Mounting - short form - Help" { 53 | run out/wslact am --help 54 | [ "${lines[0]}" = "wslact - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 55 | [ "${lines[1]}" = "Usage: wslact auto-mount [-mh]" ] 56 | } 57 | 58 | @test "wslact - Smart Mounting - short form - Help - Alt." { 59 | run out/wslact am -h 60 | [ "${lines[0]}" = "wslact - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 61 | [ "${lines[1]}" = "Usage: wslact auto-mount [-mh]" ] 62 | } 63 | 64 | @test "wslact - Memory Reclamation - Help" { 65 | run out/wslact memory-reclaim --help 66 | [ "${lines[0]}" = "wslact - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 67 | [ "${lines[1]}" = "Usage: wslact memory-reclaim [-h]" ] 68 | } 69 | 70 | @test "wslact - Memory Reclamation - Help - Alt." { 71 | run out/wslact memory-reclaim -h 72 | [ "${lines[0]}" = "wslact - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 73 | [ "${lines[1]}" = "Usage: wslact memory-reclaim [-h]" ] 74 | } 75 | 76 | @test "wslact - Memory Reclamation - short form - Help" { 77 | run out/wslact mr --help 78 | [ "${lines[0]}" = "wslact - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 79 | [ "${lines[1]}" = "Usage: wslact memory-reclaim [-h]" ] 80 | } 81 | 82 | @test "wslact - Memory Reclamation - short form - Help - Alt." { 83 | run out/wslact mr -h 84 | [ "${lines[0]}" = "wslact - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 85 | [ "${lines[1]}" = "Usage: wslact memory-reclaim [-h]" ] 86 | } 87 | -------------------------------------------------------------------------------- /tests/wslfetch.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | #wslsys testing 4 | @test "wslfetch - No parameter" { 5 | run out/wslfetch 6 | [ "$status" -eq 0 ] 7 | } 8 | 9 | @test "wslfetch - Help" { 10 | run out/wslfetch --help 11 | [ "${lines[0]}" = "wslfetch - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 12 | [ "${lines[1]}" = "Usage: wslfetch [-hvcg] [-t THEME] [-o OPTIONS]" ] 13 | } 14 | 15 | @test "wslfetch - Help - Alt." { 16 | run out/wslfetch -h 17 | [ "${lines[0]}" = "wslfetch - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 18 | [ "${lines[1]}" = "Usage: wslfetch [-hvcg] [-t THEME] [-o OPTIONS]" ] 19 | } 20 | -------------------------------------------------------------------------------- /tests/wslgsu.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | #wslgsu testing 4 | @test "wslgsu - Help" { 5 | run out/wslgsu --help 6 | [ "${lines[0]}" = "wslgsu - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 7 | [ "${lines[1]}" = "Usage: wslgsu [-u USERNAME] [-n NAME] [-S] SERVICE/COMMAND" ] 8 | [ "${lines[2]}" = "wslgsu [-hvw]" ] 9 | } 10 | 11 | @test "wslgsu - Help - Alt." { 12 | run out/wslgsu -h 13 | [ "${lines[0]}" = "wslgsu - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 14 | [ "${lines[1]}" = "Usage: wslgsu [-u USERNAME] [-n NAME] [-S] SERVICE/COMMAND" ] 15 | [ "${lines[2]}" = "wslgsu [-hvw]" ] 16 | } -------------------------------------------------------------------------------- /tests/wslsys.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | #wslsys testing 4 | @test "wslsys - No parameter" { 5 | run out/wslsys 6 | [[ "${lines[2]}" =~ ^Build\:\ [0-9]{5}$ ]] 7 | [ "$status" -eq 0 ] 8 | } 9 | 10 | @test "wslsys - Help" { 11 | run out/wslsys --help 12 | [ "${lines[0]}" = "wslsys - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 13 | [[ "${lines[1]}" =~ ^Usage\:\ .*wslsys\ \[\-VIbBFUWRKPSltTd\]\ \[\-s\]$ ]] 14 | [[ "${lines[2]}" =~ ^.*wslsys\ \[\-hv\]\ \[\-n\ NAME\]$ ]] 15 | } 16 | 17 | @test "wslsys - Help - Alt." { 18 | run out/wslsys -h 19 | [ "${lines[0]}" = "wslsys - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 20 | [[ "${lines[1]}" =~ ^Usage\:\ .*wslsys\ \[\-VIbBFUWRKPSltTd\]\ \[\-s\]$ ]] 21 | [[ "${lines[2]}" =~ ^.*wslsys\ \[\-hv\]\ \[\-n\ NAME\]$ ]] 22 | } 23 | 24 | @test "wslsys - /w parameter" { 25 | run out/wslsys -B 26 | [[ "${lines[0]}" =~ ^Build\:\ [0-9]{5}$ ]] 27 | [ "$status" -eq 0 ] 28 | } 29 | 30 | @test "wslsys - /w parameter - shortform" { 31 | run out/wslsys -B -s 32 | [[ "${lines[0]}" =~ ^[0-9]{5}$ ]] 33 | [ "$status" -eq 0 ] 34 | } 35 | -------------------------------------------------------------------------------- /tests/wslupath.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | #wslupath testing 4 | @test "wslupath - No parameter" { 5 | run out/wslupath 6 | [ "${lines[0]}" = "wslupath [-dOr] [-D|-A|-T|-S|-W|-s|-su|-H|-P|...NAME...]" ] 7 | [ "${lines[1]}" = "wslupath [-h|-v|-R]" ] 8 | [ "$status" -eq 20 ] 9 | } 10 | 11 | @test "wslupath - Help" { 12 | run out/wslupath --help 13 | [ "${lines[0]}" = "wslupath - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 14 | [ "${lines[1]}" = "Usage: wslupath [-dOr] [-D|-A|-T|-S|-W|-s|-su|-H|-P|...NAME...]" ] 15 | [ "${lines[2]}" = "wslupath [-h|-v|-R]" ] 16 | } 17 | 18 | @test "wslupath - Help - Alt." { 19 | run out/wslupath -h 20 | [ "${lines[0]}" = "wslupath - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 21 | [ "${lines[1]}" = "Usage: wslupath [-dOr] [-D|-A|-T|-S|-W|-s|-su|-H|-P|...NAME...]" ] 22 | [ "${lines[2]}" = "wslupath [-h|-v|-R]" ] 23 | } 24 | @test "wslupath - Available Registery" { 25 | run out/wslupath --avail-reg 26 | [ "${lines[0]}" = "Available registery input:" ] 27 | } 28 | 29 | @test "wslupath - Available Registery - Alt." { 30 | run out/wslupath -R 31 | [ "${lines[0]}" = "Available registery input:" ] 32 | } 33 | 34 | @test "wslupath - No parameter - Windows Double DirPath" { 35 | run out/wslupath "C:\\Windows" 36 | [ "${lines[0]}" = "/mnt/c/Windows" ] 37 | } 38 | 39 | @test "wslupath - No parameter - Windows DirPath" { 40 | run out/wslupath "C:\Windows" 41 | [ "${lines[0]}" = "/mnt/c/Windows" ] 42 | } 43 | 44 | @test "wslupath - No parameter - Linux DirPath" { 45 | run out/wslupath "/mnt/c/Windows" 46 | [ "${lines[0]}" = "C:\\Windows" ] 47 | } 48 | 49 | @test "wslupath - /w DoubleDash - Windows Double DirPath" { 50 | run out/wslupath -d "C:\\Windows" 51 | [ "${lines[0]}" = "C:\\\\Windows" ] 52 | } 53 | 54 | @test "wslupath - /w DoubleDash - Windows DirPath" { 55 | run out/wslupath -d "C:\Windows" 56 | [ "${lines[0]}" = "C:\\\\Windows" ] 57 | } 58 | 59 | @test "wslupath - /w DoubleDash - Linux DirPath" { 60 | run out/wslupath -d "/mnt/c/Windows" 61 | [ "${lines[0]}" = "/mnt/c/Windows" ] 62 | } 63 | @test "wslupath - /w parameter - No Input" { 64 | run out/wslupath -d 65 | [ "${status}" -eq 21 ] 66 | } 67 | -------------------------------------------------------------------------------- /tests/wslusc.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | #wslusc testing 4 | 5 | teardown() { 6 | echo "removal for temporary shortcuts" 7 | rm -rf "$(wslupath -D)/top.lnk" 8 | rm -rf "$(wslupath -D)/xeyes.lnk" 9 | rm -rf "$(wslupath -D)/lolwhat.lnk" 10 | } 11 | 12 | @test "wslusc - No parameter" { 13 | run out/wslusc 14 | [ "$status" -eq 21 ] 15 | } 16 | 17 | @test "wslusc - Help" { 18 | run out/wslusc --help 19 | [ "${lines[0]}" = "wslusc - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 20 | [ "${lines[1]}" = "Usage: wslusc [-IsgN] [-d SHORTCUT_FILE] [-e PATH] [-n NAME] [-i FILE] COMMAND" ] 21 | [ "${lines[2]}" = "wslusc [-hv]" ] 22 | } 23 | 24 | @test "wslusc - Help - Alt." { 25 | run out/wslusc -h 26 | [ "${lines[0]}" = "wslusc - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 27 | [ "${lines[1]}" = "Usage: wslusc [-IsgN] [-d SHORTCUT_FILE] [-e PATH] [-n NAME] [-i FILE] COMMAND" ] 28 | [ "${lines[2]}" = "wslusc [-hv]" ] 29 | } 30 | 31 | @test "wslusc - non-exist file" { 32 | run out/wslusc wryyyyy 33 | [ "$status" -eq 30 ] 34 | } 35 | 36 | @test "wslusc - without GUI" { 37 | run out/wslusc top 38 | [ -f "$(wslupath -D)/top.lnk" ] 39 | } 40 | 41 | @test "wslusc - with GUI" { 42 | run out/wslusc -g xeyes 43 | [ -f "$(wslupath -D)/xeyes.lnk" ] 44 | } 45 | 46 | @test "wslusc - with Custom Name" { 47 | run out/wslusc -n "lolwhat" top 48 | [ -f "$(wslupath -D)/lolwhat.lnk" ] 49 | } 50 | 51 | # TODO: Add more tests to cover all possible cases -------------------------------------------------------------------------------- /tests/wslvar.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | #wslvar testing 4 | @test "wslvar - No parameter" { 5 | run out/wslvar 6 | [ "$status" -eq 21 ] 7 | } 8 | 9 | @test "wslvar - Help" { 10 | run out/wslvar --help 11 | [ "${lines[0]}" = "wslvar - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 12 | [ "${lines[1]}" = "Usage: wslvar [-sl] NAME" ] 13 | [ "${lines[2]}" = "wslvar [-hvSL]" ] 14 | } 15 | 16 | @test "wslvar - Help - Alt." { 17 | run out/wslvar -h 18 | [ "${lines[0]}" = "wslvar - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 19 | [ "${lines[1]}" = "Usage: wslvar [-sl] NAME" ] 20 | [ "${lines[2]}" = "wslvar [-hvSL]" ] 21 | } 22 | @test "wslvar - System Variables" { 23 | run out/wslvar -s ProgramFiles 24 | [ "${lines[0]}" = "C:\Program Files" ] 25 | } 26 | 27 | @test "wslvar - /w -s parameter - No Input" { 28 | run out/wslvar -s 29 | [ "${status}" -eq 21 ] 30 | } 31 | 32 | @test "wslvar - Register Variables" { 33 | run out/wslvar -l AppData 34 | [[ "${lines[0]}" =~ ^C\:\\Users\\.*\\AppData\\Roaming$ ]] 35 | } 36 | 37 | @test "wslvar - /w -l parameter - No Input" { 38 | run out/wslvar -l 39 | [ "${status}" -eq 21 ] 40 | } 41 | -------------------------------------------------------------------------------- /tests/wslview.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | setup() { 4 | if [[ "$(wslsys -T -s)" != "Desktop" ]]; then 5 | skip "unsupported platform" 6 | fi 7 | } 8 | 9 | #wslview testing 10 | @test "wslview - No parameter" { 11 | run out/wslview 12 | [ "$status" -eq 21 ] 13 | } 14 | 15 | @test "wslview - Help" { 16 | run out/wslview --help 17 | [ "${lines[0]}" = "wslview - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 18 | [[ "${lines[1]}" =~ ^Usage\:\ .*wslview\ \[\-ehsvurE\]$ ]] 19 | [[ "${lines[2]}" =~ ^.*wslview\ \[\-E\ ENGINE\]\ LINK/FILE$ ]] 20 | } 21 | 22 | @test "wslview - Help - Alt." { 23 | run out/wslview -h 24 | [ "${lines[0]}" = "wslview - Part of wslu, a collection of utilities for Windows Subsystem for Linux (WSL)" ] 25 | [[ "${lines[1]}" =~ ^Usage\:\ .*wslview\ \[\-ehsvurE\]$ ]] 26 | [[ "${lines[2]}" =~ ^.*wslview\ \[\-E\ ENGINE\]\ LINK/FILE$ ]] 27 | } 28 | 29 | @test "wslview - Linux - relative" { 30 | run out/wslview . 31 | if [ $(wslsys -B -s) -ge 18362 ]; then 32 | [ "$status" -eq 0 ] 33 | else 34 | [ "$status" -eq 34 ] 35 | fi 36 | } 37 | 38 | @test "wslview - Linux - absolute" { 39 | run out/wslview /home 40 | if [ $(wslsys -B -s) -ge 18362 ]; then 41 | [ "$status" -eq 0 ] 42 | else 43 | [ "$status" -eq 34 ] 44 | fi 45 | } 46 | 47 | @test "wslview - Linux - file protocol" { 48 | run out/wslview file:///etc 49 | if [ $(wslsys -B -s) -ge 18362 ]; then 50 | [ "$status" -eq 0 ] 51 | else 52 | [ "$status" -eq 34 ] 53 | fi 54 | } 55 | 56 | @test "wslview - Windows folder in Linux - absolute" { 57 | run out/wslview /mnt/c/Windows 58 | if [ $(wslsys -B -s) -ge 18362 ]; then 59 | [ "$status" -eq 0 ] 60 | else 61 | [ "$status" -eq 34 ] 62 | fi 63 | } 64 | 65 | @test "wslview - Windows folder in Linux - file protocol" { 66 | run out/wslview file:///mnt/c/Users 67 | if [ $(wslsys -B -s) -ge 18362 ]; then 68 | [ "$status" -eq 0 ] 69 | else 70 | [ "$status" -eq 34 ] 71 | fi 72 | } 73 | 74 | @test "wslview - Windows - absolute" { 75 | run out/wslview "C:/Users/Public" 76 | [ "$status" -eq 0 ] 77 | } 78 | 79 | @test "wslview - Windows - file protocol" { 80 | run out/wslview "file:///C:/Windows/System32" 81 | [ "$status" -eq 0 ] 82 | } 83 | 84 | @test "wslview - Internet - no protocol" { 85 | run out/wslview "www.duckduckgo.com" 86 | [ "$status" -eq 0 ] 87 | } 88 | 89 | @test "wslview - Internet - http" { 90 | run out/wslview "http://info.cern.ch" 91 | [ "$status" -eq 0 ] 92 | } 93 | 94 | @test "wslview - Internet - https" { 95 | run out/wslview "https://wslutiliti.es/" 96 | [ "$status" -eq 0 ] 97 | } 98 | 99 | @test "wslview - Internet - with brackets" { 100 | run out/wslview "https://www.duckduckgo.com/?q=[wslu]" 101 | [ "$status" -eq 0 ] 102 | } 103 | --------------------------------------------------------------------------------