Files
artif/windows/winfetch.ps1
mnerv 687ac88c85 winfetch: improve GPU detection and add logo variants
- Prioritize discrete GPU (NVIDIA/AMD) over integrated graphics
- Add classic Windows 7/Vista logo
- Add Windows 8/10 logo
- Add Windows 95 retro logo
- Add Windows 2025 logo with rounded corners
- Fix classic logo alignment with padding
2026-02-04 00:03:20 +01:00

259 lines
13 KiB
PowerShell

# winfetch.ps1
# Windows system information display with ASCII art (inspired by fastfetch/neofetch)
param(
[ValidateSet("11", "small", "classic", "8", "95", "2025")]
[string]$Logo = "11"
)
# Color definitions using ANSI escape codes
$colors = @{
Reset = "`e[0m"
Cyan = "`e[96m"
Blue = "`e[94m"
Green = "`e[92m"
Yellow = "`e[93m"
Red = "`e[91m"
Magenta = "`e[95m"
White = "`e[97m"
Gray = "`e[90m"
BrightBlue = "`e[1;94m"
BrightCyan = "`e[1;96m"
BrightGreen = "`e[1;92m"
BrightYellow = "`e[1;93m"
}
# Windows 11 logo colors (Blue, Cyan, Green, Yellow)
$logo11 = @(
"$($colors.Blue)///////////////// $($colors.BrightCyan)/////////////////",
"$($colors.Blue)///////////////// $($colors.BrightCyan)/////////////////",
"$($colors.Blue)///////////////// $($colors.BrightCyan)/////////////////",
"$($colors.Blue)///////////////// $($colors.BrightCyan)/////////////////",
"$($colors.Blue)///////////////// $($colors.BrightCyan)/////////////////",
"$($colors.Blue)///////////////// $($colors.BrightCyan)/////////////////",
"$($colors.Blue)///////////////// $($colors.BrightCyan)/////////////////",
"$($colors.Blue)///////////////// $($colors.BrightCyan)/////////////////",
"",
"$($colors.BrightGreen)///////////////// $($colors.BrightYellow)/////////////////",
"$($colors.BrightGreen)///////////////// $($colors.BrightYellow)/////////////////",
"$($colors.BrightGreen)///////////////// $($colors.BrightYellow)/////////////////",
"$($colors.BrightGreen)///////////////// $($colors.BrightYellow)/////////////////",
"$($colors.BrightGreen)///////////////// $($colors.BrightYellow)/////////////////",
"$($colors.BrightGreen)///////////////// $($colors.BrightYellow)/////////////////",
"$($colors.BrightGreen)///////////////// $($colors.BrightYellow)/////////////////",
"$($colors.BrightGreen)///////////////// $($colors.BrightYellow)/////////////////"
)
$logoSmall = @(
"$($colors.Blue)lllllll $($colors.BrightCyan)lllllll",
"$($colors.Blue)lllllll $($colors.BrightCyan)lllllll",
"$($colors.Blue)lllllll $($colors.BrightCyan)lllllll",
" ", # Empty line with proper width (16 chars)
"$($colors.BrightGreen)lllllll $($colors.BrightYellow)lllllll",
"$($colors.BrightGreen)lllllll $($colors.BrightYellow)lllllll",
"$($colors.BrightGreen)lllllll $($colors.BrightYellow)lllllll",
" " # Empty line with proper width (16 chars)
)
# Classic Windows logo (Windows 7/Vista style)
$logoClassic = @(
"$($colors.Red) ,.=:!!t3Z3z., ",
"$($colors.Red) :tt:::tt333EE3 ",
"$($colors.Red) Et:::ztt33EEEL$($colors.Green) @Ee., ..,",
"$($colors.Red) ;tt:::tt333EE7$($colors.Green) ;EEEEEEttttt33#",
"$($colors.Red) :Et:::zt333EEQ.$($colors.Green) `$EEEEEttttt33QL",
"$($colors.Red) it::::tt333EEF$($colors.Green) @EEEEEEttttt33F ",
"$($colors.Red) ;3=*^``````""*4EEV$($colors.Green) :EEEEEEttttt33@.",
"$($colors.Blue) ,.=::::!t=., $($colors.Red)``$($colors.Green) @EEEEEEtttz33QF ",
"$($colors.Blue) ;::::::::zt33)$($colors.Green) ""4EEEtttji3P* ",
"$($colors.Blue) :t::::::::tt33.$($colors.Yellow):Z3z..$($colors.Green) ````$($colors.Yellow) ,..g. ",
"$($colors.Blue) i::::::::zt33F$($colors.Yellow) AEEEtttt::::ztF ",
"$($colors.Blue) ;:::::::::t33V$($colors.Yellow) ;EEEttttt::::t3 ",
"$($colors.Blue) E::::::::zt33L$($colors.Yellow) @EEEtttt::::z3F ",
"$($colors.Blue){3=*^``````""*4E3)$($colors.Yellow) ;EEEtttt:::::tZ`` ",
"$($colors.Blue) ``$($colors.Yellow) :EEEEtttt::::z7 ",
"$($colors.Yellow) ""VEzjt:;;z>*`` "
)
# Windows 8/10 logo
$logo8 = @(
"$($colors.Cyan) ..,",
"$($colors.Cyan) ....,,:;+ccllll",
"$($colors.Blue) ...,,+:; $($colors.Cyan)cllllllllllllllllll",
"$($colors.Blue),cclllllllllll $($colors.Cyan)lllllllllllllllllll",
"$($colors.Blue)llllllllllllll $($colors.Cyan)lllllllllllllllllll",
"$($colors.Blue)llllllllllllll $($colors.Cyan)lllllllllllllllllll",
"$($colors.Blue)llllllllllllll $($colors.Cyan)lllllllllllllllllll",
"$($colors.Blue)llllllllllllll $($colors.Cyan)lllllllllllllllllll",
"$($colors.Blue)llllllllllllll $($colors.Cyan)lllllllllllllllllll",
"",
"$($colors.BrightGreen)llllllllllllll $($colors.BrightYellow)lllllllllllllllllll",
"$($colors.BrightGreen)llllllllllllll $($colors.BrightYellow)lllllllllllllllllll",
"$($colors.BrightGreen)llllllllllllll $($colors.BrightYellow)lllllllllllllllllll",
"$($colors.BrightGreen)llllllllllllll $($colors.BrightYellow)lllllllllllllllllll",
"$($colors.BrightGreen)llllllllllllll $($colors.BrightYellow)lllllllllllllllllll",
"$($colors.BrightGreen)``'ccllllllllll $($colors.BrightYellow)lllllllllllllllllll",
"$($colors.BrightGreen) ``' \*:: $($colors.BrightYellow):ccllllllllllllllll",
"$($colors.BrightYellow) ````''*::cll",
"$($colors.BrightYellow) ``"
)
# Windows 95 logo
$logo95 = @(
"$($colors.Gray) ___",
"$($colors.Gray) .--=+++++=-:.",
"$($colors.Gray). _ *%@@@@@@@@@@@@@@*",
"$($colors.Gray) *:+:.__ :+* @@@ @""$($colors.Cyan)_*&%$($colors.Gray)@@$($colors.Yellow)%&&&*$($colors.Gray)""@@@",
"$($colors.Gray) ""+.-#+ +%* "" _ $($colors.Cyan)++&&&%$($colors.Gray)@@$($colors.Yellow)%&&&&&#$($colors.Gray)@@",
"$($colors.Cyan)"" , $($colors.Gray)%@@ $($colors.Cyan)&&&&&%$($colors.Gray)@@$($colors.Yellow)%&&&&&#$($colors.Gray)@@",
"$($colors.Cyan) * oo *# $($colors.Gray)"" _ $($colors.Cyan)&&&&&%$($colors.Gray)@@$($colors.Yellow)%&&&&&#$($colors.Gray)@@",
"$($colors.Cyan)"" , $($colors.Gray)%@@ $($colors.Cyan)&&&&""$($colors.Gray)@@@@#*$($colors.Yellow)""&&&$($colors.Gray)@@",
"$($colors.Cyan). * oo *# $($colors.Gray)"" _ %@@@@@@@@@@@@@@@@",
"$($colors.Gray) *:+:.__ :=* %@@ @""$($colors.Red)**&%$($colors.Gray)@@$($colors.Green)%&&&*$($colors.Gray)""@@@",
"$($colors.Gray) ""+.-#+ +%* "" _ $($colors.Red)&&&&&%$($colors.Gray)@@$($colors.Green)%&&&&&#$($colors.Gray)@@",
"$($colors.Red)"" , $($colors.Gray)%@@ $($colors.Red)&&&&&%$($colors.Gray)@@$($colors.Green)%&&&&&#$($colors.Gray)@@",
"$($colors.Red) * oo *# $($colors.Gray)"" _ $($colors.Red)&&&&&%$($colors.Gray)@@$($colors.Green)%&&&&&#$($colors.Gray)@@",
"$($colors.Red)"" , $($colors.Gray)%@@ $($colors.Red)&&*""%$($colors.Gray)@@@@@@$($colors.Green)""*%&$($colors.Gray)@@",
"$($colors.Red). * oo *# $($colors.Gray)"" _ @@@@@@@@@@@@@@@@@",
"$($colors.Gray) *:+:.__ :+# @@@ @%#=+""""""""""+==%#@",
"$($colors.Gray) ""+.-#+ +%* %+"" "" "":@",
"$($colors.Gray) "" """
)
# Windows 2025 logo (rounded corners)
$logo2025 = @(
"$($colors.Blue) ##%%%%%%%%% $($colors.BrightCyan)%%%%%%%%%##",
"$($colors.Blue) ###%%%%%%%%%% $($colors.BrightCyan)%%%%%%%%%%###",
"$($colors.Blue) ####%%%%%%%%%%% $($colors.BrightCyan)%%%%%%%%%%%####",
"$($colors.Blue) ##%%%%%%%%%%%%%% $($colors.BrightCyan)%%%%%%%%%%%%%%##",
"$($colors.Blue)#%%%%%%%%%%%%%%%% $($colors.BrightCyan)%%%%%%%%%%%%%%%%#",
"$($colors.Blue)%%%%%%%%%%%%%%%%% $($colors.BrightCyan)%%%%%%%%%%%%%%%%%",
"$($colors.Blue)%%%%%%%%%%%%%%%%% $($colors.BrightCyan)%%%%%%%%%%%%%%%%%",
"$($colors.Blue)%%%%%%%%%%%%%%%%% $($colors.BrightCyan)#%%%%%%%%%%%%%%%%",
"",
"$($colors.BrightGreen)%%%%%%%%%%%%%%%%% $($colors.BrightYellow)#%%%%%%%%%%%%%%%%",
"$($colors.BrightGreen)%%%%%%%%%%%%%%%%% $($colors.BrightYellow)%%%%%%%%%%%%%%%%%",
"$($colors.BrightGreen)%%%%%%%%%%%%%%%%% $($colors.BrightYellow)%%%%%%%%%%%%%%%%%",
"$($colors.BrightGreen)%%%%%%%%%%%%%%%%% $($colors.BrightYellow)%%%%%%%%%%%%%%%%#",
"$($colors.BrightGreen) ###%%%%%%%%%%%%% $($colors.BrightYellow)%%%%%%%%%%%%%%%##",
"$($colors.BrightGreen) ####%%%%%%%%%%% $($colors.BrightYellow)%%%%%%%%%%%#%####",
"$($colors.BrightGreen) ##%#%%%%%%%%% $($colors.BrightYellow)%%%%%%%%%%%######",
"$($colors.BrightGreen) ##%%%%%%%%% $($colors.BrightYellow)%%%%%%%%%########"
)
# Select logo
$asciiLogo = switch ($Logo) {
"small" { $logoSmall }
"classic" { $logoClassic }
"8" { $logo8 }
"95" { $logo95 }
"2025" { $logo2025 }
default { $logo11 }
}
# Collect system information
$computerSystem = Get-CimInstance Win32_ComputerSystem
$os = Get-CimInstance Win32_OperatingSystem
$cpu = Get-CimInstance Win32_Processor | Select-Object -First 1
# Get GPU - prefer discrete GPU over integrated
$gpuList = Get-CimInstance Win32_VideoController | Where-Object { $_.Status -eq 'OK' -or $_.Availability -eq 3 }
$gpu = $gpuList | Where-Object {
$_.Name -match 'NVIDIA|AMD|Radeon|GeForce|RTX|GTX|RX\s*\d'
} | Select-Object -First 1
if (-not $gpu) {
$gpu = $gpuList | Select-Object -First 1
}
$disk = Get-PSDrive -PSProvider FileSystem | Where-Object { $_.Name -eq 'C' }
# Calculate uptime
$uptime = (Get-Date) - $os.LastBootUpTime
$uptimeStr = if ($uptime.Days -gt 0) {
"$($uptime.Days)d $($uptime.Hours)h $($uptime.Minutes)m"
} else {
"$($uptime.Hours)h $($uptime.Minutes)m"
}
# Calculate memory usage
$totalMemGB = [math]::Round($computerSystem.TotalPhysicalMemory / 1GB, 2)
$usedMemGB = [math]::Round(($computerSystem.TotalPhysicalMemory - $os.FreePhysicalMemory * 1KB) / 1GB, 2)
# Calculate disk usage
$totalDiskGB = [math]::Round(($disk.Used + $disk.Free) / 1GB, 2)
$usedDiskGB = [math]::Round($disk.Used / 1GB, 2)
# Get display resolution
$resolution = "N/A"
try {
Add-Type -AssemblyName System.Windows.Forms
$screen = [System.Windows.Forms.Screen]::PrimaryScreen
$resolution = "$($screen.Bounds.Width)x$($screen.Bounds.Height)"
} catch {
# Fallback if GUI not available
if ($gpu.CurrentHorizontalResolution -and $gpu.CurrentVerticalResolution) {
$resolution = "$($gpu.CurrentHorizontalResolution)x$($gpu.CurrentVerticalResolution)"
}
}
# Build info array
if ($Logo -eq "small") {
$info = @(
"$($colors.Cyan)$env:USERNAME$($colors.White)@$($colors.Cyan)$env:COMPUTERNAME",
"$($colors.Gray)$("-" * ($env:USERNAME.Length + $env:COMPUTERNAME.Length + 1))",
"$($colors.BrightBlue)OS$($colors.Reset): $($os.Caption)",
"$($colors.BrightBlue)Uptime$($colors.Reset): $uptimeStr",
"$($colors.BrightBlue)CPU$($colors.Reset): $($cpu.Name.Trim())",
"$($colors.BrightBlue)Memory$($colors.Reset): ${usedMemGB}GB / ${totalMemGB}GB",
"",
(($colors.Keys | Where-Object { $_ -ne 'Reset' -and $_ -ne 'Gray' -and $_ -ne 'White' } | Sort-Object | ForEach-Object { "$($colors[$_])███" }) -join '') + $colors.Reset
)
} else {
$info = @(
"$($colors.Cyan)$env:USERNAME$($colors.White)@$($colors.Cyan)$env:COMPUTERNAME",
"$($colors.Gray)$("-" * ($env:USERNAME.Length + $env:COMPUTERNAME.Length + 1))",
"$($colors.BrightBlue)OS$($colors.Reset): $($os.Caption) [$($os.OSArchitecture)]",
"$($colors.BrightBlue)Host$($colors.Reset): $($computerSystem.Manufacturer) $($computerSystem.Model)",
"$($colors.BrightBlue)Kernel$($colors.Reset): $($os.Version)",
"$($colors.BrightBlue)Uptime$($colors.Reset): $uptimeStr",
"$($colors.BrightBlue)Shell$($colors.Reset): PowerShell $($PSVersionTable.PSVersion)",
"$($colors.BrightBlue)Resolution$($colors.Reset): $resolution",
"$($colors.BrightBlue)Terminal$($colors.Reset): $env:TERM_PROGRAM $(if ($env:WT_SESSION) { "Windows Terminal" } else { "Console" })",
"$($colors.BrightBlue)CPU$($colors.Reset): $($cpu.Name.Trim())",
"$($colors.BrightBlue)GPU$($colors.Reset): $($gpu.Name)",
"$($colors.BrightBlue)Memory$($colors.Reset): ${usedMemGB}GB / ${totalMemGB}GB",
"$($colors.BrightBlue)Disk (C:)$($colors.Reset): ${usedDiskGB}GB / ${totalDiskGB}GB",
"",
(($colors.Keys | Where-Object { $_ -ne 'Reset' -and $_ -ne 'Gray' -and $_ -ne 'White' } | Sort-Object | ForEach-Object { "$($colors[$_])███" }) -join '') + $colors.Reset
)
}
# Display
$maxLines = [Math]::Max($asciiLogo.Count, $info.Count)
# Calculate logo width dynamically
$logoWidth = switch ($Logo) {
"small" { 16 }
"classic" { 40 }
"8" { 36 }
"95" { 40 }
"2025" { 38 }
default { 38 }
}
for ($i = 0; $i -lt $maxLines; $i++) {
$logoLine = if ($i -lt $asciiLogo.Count) { $asciiLogo[$i] } else { "" }
$infoLine = if ($i -lt $info.Count) { $info[$i] } else { "" }
# Pad logo to align info
if ($logoLine) {
$logoStripped = $logoLine -replace '\e\[[0-9;]*m', '' # Remove ANSI codes for length calc
$paddingNeeded = $logoWidth - $logoStripped.Length
if ($paddingNeeded -lt 2) { $paddingNeeded = 2 } # Minimum spacing
Write-Host "$logoLine$(' ' * $paddingNeeded)$infoLine"
} else {
# Empty logo line, just use full logo width for spacing
Write-Host "$(' ' * $logoWidth)$infoLine"
}
}
Write-Host $colors.Reset