pfetch icon indicating copy to clipboard operation
pfetch copied to clipboard

Call for Windows testers (CYGWIN, MSYS, MINGW, WSL)

Open dylanaraps opened this issue 6 years ago • 8 comments

Edit: Those using CYGWIN, MSYS or MINGW, test out https://github.com/dylanaraps/pfetch/pull/22

Send me the full outputs of the following commands:

  • wmic os get Caption (needed for OS name).
    • Does wmic have an option to exclude Caption from the output?
  • wmic computersystem get manufacturer,model (needed for host information).

Notes:

  • WSL detection is possible through checking /proc/version and uname -r.
  • Uptime (in seconds) is accessible through /proc/uptime.
  • Memory is accessible through /proc/meminfo.

dylanaraps avatar Sep 26 '19 18:09 dylanaraps

This is on stock Windows.

wmic os get Caption:

Caption
Microsoft Windows 10 Home

note: I have no clue how to use wmic.

wmic computersystem get manufacturer,model:

Manufacturer  Model
MSI           MS-7982

Using Ubuntu 18.04 LTS WSL:

cat /proc/version:

Linux version 4.4.0-18362-Microsoft ([email protected]) (gcc version 5.4.0 (GCC) ) #1-Microsoft Mon Mar 18 12:02:00 PST 2019

uname -r:

4.4.0-18362-Microsoft

cat /proc/uptime:

89.00 261.02

cat /proc/meminfo:

MemTotal:        8351944 kB
MemFree:         3528932 kB
Buffers:           34032 kB
Cached:           188576 kB
SwapCached:            0 kB
Active:           167556 kB
Inactive:         157876 kB
Active(anon):     103104 kB
Inactive(anon):    17440 kB
Active(file):      64452 kB
Inactive(file):   140436 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:      25165824 kB
SwapFree:       24797680 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:        102824 kB
Mapped:            71404 kB
Shmem:             17720 kB
Slab:              13868 kB
SReclaimable:       6744 kB
SUnreclaim:         7124 kB
KernelStack:        2848 kB
PageTables:         2524 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      515524 kB
Committed_AS:    3450064 kB
VmallocTotal:     122880 kB
VmallocUsed:       21296 kB
VmallocChunk:      66044 kB
HardwareCorrupted:     0 kB
AnonHugePages:      2048 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       12280 kB
DirectMap4M:      897024 kB

kayew avatar Sep 28 '19 03:09 kayew

WSL support has been added.

dylanaraps avatar Sep 28 '19 07:09 dylanaraps

Does wmic have an option to exclude Caption from the output?

Do know that wmic is just an inflexible legacy executable to interface with WMI from the ol' DOS shell. You would typically query WMI/CIM from PowerShell, this also gives you the ability to easily drop the "Caption" header - for example like this:

# Probably most common:
(Get-CimInstance -ClassName CIM_OperatingSystem).Caption

# Faster
[System.Management.ManagementObjectSearcher]::new("SELECT Caption FROM Win32_OperatingSystem").Get().Caption

Also, with WSL2 there is no guarantee that the kernel has -Microsoft in its name as the user can use any linux kernel they want, so basing detection off of that is a little wonky. Even by default, my /proc/version on WSL2 Ubuntu 18.04 now reads:

Linux version 4.19.67-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Sun Aug 18 13:37:54 UTC 2019

and uname -r :

4.19.67-microsoft-standard

The "microsoft" is lowercase now, so the current detection method does not work anymore already even with the (for now) default kernel.

jantari avatar Sep 30 '19 21:09 jantari

Do know that wmic is just an inflexible legacy executable to interface with WMI from the ol' DOS shell.

I'm aware though Cygwin, MSYS and MINGW can access it through bash/`sh so we're limited to how it works in that sort of environment.

The "microsoft" is lowercase now, so the current detection method does not work anymore already even with the (for now) default kernel.

Does /proc/version always contain Microsoft?

dylanaraps avatar Sep 30 '19 21:09 dylanaraps

I'm aware though Cygwin, MSYS and MINGW can access it through bash/sh so we're limited to how it works in that sort of environment.

You can call powershell.exe (or any other Windows executable) from WSL:

jantari@AMDESKTOP:~$ powershell.exe -Command "(Get-CimInstance -ClassName CIM_OperatingSystem).Caption"

that returns just Microsoft Windows 10 Pro in a single line, nothing more.

/proc/version will likely always contain [mM]icrosoft for the kernels Microsoft compiles and ships, but not for any kernel the user installs in WSL2.

I do see three promising environment variables in my WSL2 though:

$WSLENV (empty for me)
$WSL_DISTRO_NAME (contains 'Ubuntu-18.04' for me)
$WSL_INTEROP (contains '/run/WSL/8_interop' for me)

I'm not great at *nix-sh, but if there's an IFDEF-like statement that could work. $WSLENV is probably always declared, even if it's empty.

jantari avatar Sep 30 '19 21:09 jantari

Fixed the WSL2 detection: https://github.com/dylanaraps/pfetch/commit/46b68022a3964cfb5a77d91cc2b129612547aaf2

dylanaraps avatar Sep 30 '19 21:09 dylanaraps

Initial Windows support is done here: https://github.com/dylanaraps/pfetch/pull/22

Please test it out!

dylanaraps avatar Oct 01 '19 07:10 dylanaraps

Suggestion: Running on Windows 11 WSL2 - make the text more generic - confusing when it shows "on Windows 10 [WSL2]" when I'm actually running Windows 11 - there is no difference to the detection code so just drop the 10?

jbaribeault avatar Dec 15 '21 17:12 jbaribeault