From 146c6b6baee1371afa32c772aa60862e84df9ebb Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 1 Oct 2019 00:44:22 +0300 Subject: [PATCH] pfetch: Fix WSL2 detection. --- pfetch | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/pfetch b/pfetch index 2bafa79..825855b 100755 --- a/pfetch +++ b/pfetch @@ -177,17 +177,23 @@ get_os() { command -v guix && distro='Guix System' # Check to see if Linux is running in Windows 10 under - # WSL (Windows subsystem for Linux) and append a string - # accordingly. + # WSL1 (Windows subsystem for Linux [version 1]) and + # append a string accordingly. # # If the kernel version string ends in "-Microsoft", - # we're very likely running under Windows 10 in WSL. - # - # This also acts as a means of allowing the user to - # fake this by changing their kernel version to end in - # "Microsoft". + # we're very likely running under Windows 10 in WSL1. [ "${kernel%%*-Microsoft}" ] || - distro="$distro on Windows 10" + distro="$distro on Windows 10 [WSL1]" + + # Check to see if Linux is running in Windows 10 under + # WSL2 (Windows subsystem for Linux [version 2]) and + # append a string accordingly. + # + # If either of these environment variables are defined + # and non-empty, we are very likely running under + # Windows 10 in WSL2. + [ "$WSL_INTEROP" ] || [ "$WSLENV" ] || [ "$WSL_DISTRO_NAME" ] && + distro="$distro on Windows 10 [WSL1]" ;; Darwin*)