-
Notifications
You must be signed in to change notification settings - Fork 81
/
winfetch.ps1
1514 lines (1364 loc) · 147 KB
/
winfetch.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env -S pwsh -nop
#requires -version 5
# (!) This file must to be saved in UTF-8 with BOM encoding in order to work with legacy Powershell 5.x
<#PSScriptInfo
.VERSION 2.5.1
.GUID 27c6f0dd-dbf2-4a3e-90df-a23c3c6c630d
.AUTHOR Winfetch contributers
.PROJECTURI https://github.com/lptstr/winfetch
.COMPANYNAME
.COPYRIGHT
.TAGS neofetch screenfetch system-info commandline
.LICENSEURI https://github.com/lptstr/winfetch/blob/master/LICENSE
.ICONURI https://lptstr.github.io/lptstr-images/proj/winfetch/logo.png
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
#>
<#
.SYNOPSIS
Winfetch - Neofetch for Windows in PowerShell 5+
.DESCRIPTION
Winfetch is a command-line system information utility for Windows written in PowerShell.
.PARAMETER image
Display a pixelated image instead of the usual logo.
.PARAMETER ascii
Display the image using ASCII characters instead of blocks.
.PARAMETER genconf
Reset your configuration file to the default.
.PARAMETER configpath
Specify a path to a custom config file.
.PARAMETER noimage
Do not display any image or logo; display information only.
.PARAMETER logo
Sets the version of Windows to derive the logo from.
.PARAMETER imgwidth
Specify width for image/logo. Default is 35.
.PARAMETER alphathreshold
Specify minimum alpha value for image pixels to be visible. Default is 50.
.PARAMETER blink
Make the logo blink.
.PARAMETER stripansi
Output without any text effects or colors.
.PARAMETER all
Display all built-in info segments.
.PARAMETER help
Display this help message.
.PARAMETER cpustyle
Specify how to show information level for CPU usage
.PARAMETER memorystyle
Specify how to show information level for RAM usage
.PARAMETER diskstyle
Specify how to show information level for disks' usage
.PARAMETER batterystyle
Specify how to show information level for battery
.PARAMETER showdisks
Configure which disks are shown, use '-showdisks *' to show all.
.PARAMETER showpkgs
Configure which package managers are shown, e.g. '-showpkgs winget,scoop,choco'.
.INPUTS
System.String
.OUTPUTS
System.String[]
.NOTES
Run Winfetch without arguments to view core functionality.
#>
[CmdletBinding()]
param(
[string][alias('i')]$image,
[switch][alias('k')]$ascii,
[switch][alias('g')]$genconf,
[string][alias('c')]$configpath,
[switch][alias('n')]$noimage,
[string][alias('l')]$logo,
[switch][alias('b')]$blink,
[switch][alias('s')]$stripansi,
[switch][alias('a')]$all,
[switch][alias('h')]$help,
[ValidateSet("text", "bar", "textbar", "bartext")][string]$cpustyle = "text",
[ValidateSet("text", "bar", "textbar", "bartext")][string]$memorystyle = "text",
[ValidateSet("text", "bar", "textbar", "bartext")][string]$diskstyle = "text",
[ValidateSet("text", "bar", "textbar", "bartext")][string]$batterystyle = "text",
[ValidateScript({$_ -gt 1 -and $_ -lt $Host.UI.RawUI.WindowSize.Width-1})][alias('w')][int]$imgwidth = 35,
[ValidateScript({$_ -ge 0 -and $_ -le 255})][alias('t')][int]$alphathreshold = 50,
[array]$showdisks = @($env:SystemDrive),
[array]$showpkgs = @("scoop", "choco")
)
if (-not ($IsWindows -or $PSVersionTable.PSVersion.Major -eq 5)) {
Write-Error "Only supported on Windows."
exit 1
}
# ===== DISPLAY HELP =====
if ($help) {
if (Get-Command -Name less -ErrorAction Ignore) {
Get-Help ($MyInvocation.MyCommand.Definition) -Full | less
} else {
Get-Help ($MyInvocation.MyCommand.Definition) -Full
}
exit 0
}
# ===== CONFIG MANAGEMENT =====
$defaultConfig = @'
# ===== WINFETCH CONFIGURATION =====
# $image = "~/winfetch.png"
# $noimage = $true
# Display image using ASCII characters
# $ascii = $true
# Set the version of Windows to derive the logo from.
# $logo = "Windows 10"
# Specify width for image/logo
# $imgwidth = 24
# Specify minimum alpha value for image pixels to be visible
# $alphathreshold = 50
# Custom ASCII Art
# This should be an array of strings, with positive
# height and width equal to $imgwidth defined above.
# $CustomAscii = @(
# "⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣾⣿⣦⠀ ⠀"
# "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣶⣶⣾⣷⣶⣆⠸⣿⣿⡟⠀ ⠀"
# "⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣷⡈⠻⠿⠟⠻⠿⢿⣷⣤⣤⣄⠀⠀ ⠀"
# "⠀⠀⠀⠀⠀⠀⠀⣴⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣦⠀ ⠀"
# "⠀⠀⠀⢀⣤⣤⡘⢿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⣿⡇ ⠀"
# "⠀⠀⠀⣿⣿⣿⡇⢸⣿⡁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢈⣉⣉⡁ ⠀"
# "⠀⠀⠀⠈⠛⠛⢡⣾⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⡇ ⠀"
# "⠀⠀⠀⠀⠀⠀⠀⠻⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⠟⠀ ⠀"
# "⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⡿⢁⣴⣶⣦⣴⣶⣾⡿⠛⠛⠋⠀⠀ ⠀"
# "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠿⠿⢿⡿⠿⠏⢰⣿⣿⣧⠀⠀ ⠀"
# "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢿⣿⠟⠀⠀ ⠀"
# )
# Make the logo blink
# $blink = $true
# Display all built-in info segments.
# $all = $true
# Add a custom info line
# function info_custom_time {
# return @{
# title = "Time"
# content = (Get-Date)
# }
# }
# Configure which disks are shown
# $ShowDisks = @("C:", "D:")
# Show all available disks
# $ShowDisks = @("*")
# Configure which package managers are shown
# disabling unused ones will improve speed
# $ShowPkgs = @("winget", "scoop", "choco")
# Use the following option to specify custom package managers.
# Create a function with that name as suffix, and which returns
# the number of packages. Two examples are shown here:
# $CustomPkgs = @("cargo", "just-install")
# function info_pkg_cargo {
# return (cargo install --list | Where-Object {$_ -like "*:" }).Length
# }
# function info_pkg_just-install {
# return (just-install list).Length
# }
# Configure how to show info for levels
# Default is for text only.
# 'bar' is for bar only.
# 'textbar' is for text + bar.
# 'bartext' is for bar + text.
# $cpustyle = 'bar'
# $memorystyle = 'textbar'
# $diskstyle = 'bartext'
# $batterystyle = 'bartext'
# Remove the '#' from any of the lines in
# the following to **enable** their output.
@(
"title"
"dashes"
"os"
"computer"
"kernel"
"motherboard"
# "custom_time" # use custom info line
"uptime"
# "ps_pkgs" # takes some time
"pkgs"
"pwsh"
"resolution"
"terminal"
# "theme"
"cpu"
"gpu"
# "cpu_usage"
"memory"
"disk"
# "battery"
# "locale"
# "weather"
# "local_ip"
# "public_ip"
"blank"
"colorbar"
)
'@
if (-not $configPath) {
if ($env:WINFETCH_CONFIG_PATH) {
$configPath = $env:WINFETCH_CONFIG_PATH
} else {
$configPath = "${env:USERPROFILE}\.config\winfetch\config.ps1"
}
}
# generate default config
if ($genconf -and (Test-Path $configPath)) {
$choiceYes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", `
"overwrite your configuration with the default"
$choiceNo = New-Object System.Management.Automation.Host.ChoiceDescription "&No", `
"do nothing and exit"
$result = $Host.UI.PromptForChoice("Resetting your config to default will overwrite it.",
"Do you want to continue?", ($choiceYes, $choiceNo), 1)
if ($result -eq 0) { Remove-Item -Path $configPath } else { exit 1 }
}
if (-not (Test-Path $configPath) -or [String]::IsNullOrWhiteSpace((Get-Content $configPath))) {
New-Item -Type File -Path $configPath -Value $defaultConfig -Force | Out-Null
if ($genconf) {
Write-Host "Saved default config to '$configPath'."
exit 0
} else {
Write-Host "Missing config: Saved default config to '$configPath'."
}
}
# load config file
$config = . $configPath
if (-not $config -or $all) {
$config = @(
"title"
"dashes"
"os"
"computer"
"kernel"
"motherboard"
"uptime"
"resolution"
"ps_pkgs"
"pkgs"
"pwsh"
"terminal"
"theme"
"cpu"
"gpu"
"cpu_usage"
"memory"
"disk"
"battery"
"locale"
"weather"
"local_ip"
"public_ip"
"blank"
"colorbar"
)
}
# prevent config from overriding specified parameters
foreach ($param in $PSBoundParameters.Keys) {
Set-Variable $param $PSBoundParameters[$param]
}
# ===== VARIABLES =====
$e = [char]0x1B
$ansiRegex = '([\u001B\u009B][[\]()#;?]*(?:(?:(?:[a-zA-Z\d]*(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-ntqry=><~])))'
$cimSession = New-CimSession
$os = Get-CimInstance -ClassName Win32_OperatingSystem -Property Caption,OSArchitecture,LastBootUpTime,TotalVisibleMemorySize,FreePhysicalMemory -CimSession $cimSession
$t = if ($blink) { "5" } else { "1" }
$COLUMNS = $imgwidth
# ===== UTILITY FUNCTIONS =====
function get_percent_bar {
param ([Parameter(Mandatory)][int]$percent)
if ($percent -gt 100) { $percent = 100 }
elseif ($percent -lt 0) { $percent = 0 }
$x = [char]9632
$bar = $null
$bar += "$e[97m[ $e[0m"
for ($i = 1; $i -le ($barValue = ([math]::round($percent / 10))); $i++) {
if ($i -le 6) { $bar += "$e[32m$x$e[0m" }
elseif ($i -le 8) { $bar += "$e[93m$x$e[0m" }
else { $bar += "$e[91m$x$e[0m" }
}
for ($i = 1; $i -le (10 - $barValue); $i++) { $bar += "$e[97m-$e[0m" }
$bar += "$e[97m ]$e[0m"
return $bar
}
function get_level_info {
param (
[string]$barprefix,
[string]$style,
[int]$percentage,
[string]$text,
[switch]$altstyle
)
switch ($style) {
'bar' { return "$barprefix$(get_percent_bar $percentage)" }
'textbar' { return "$text $(get_percent_bar $percentage)" }
'bartext' { return "$barprefix$(get_percent_bar $percentage) $text" }
default { if ($altstyle) { return "$percentage% ($text)" } else { return "$text ($percentage%)" }}
}
}
function truncate_line {
param (
[string]$text,
[int]$maxLength
)
$length = ($text -replace $ansiRegex, "").Length
if ($length -le $maxLength) {
return $text
}
$truncateAmt = $length - $maxLength
$trucatedOutput = ""
$parts = $text -split $ansiRegex
for ($i = $parts.Length - 1; $i -ge 0; $i--) {
$part = $parts[$i]
if (-not $part.StartsWith([char]27) -and $truncateAmt -gt 0) {
$num = if ($truncateAmt -gt $part.Length) {
$part.Length
} else {
$truncateAmt
}
$truncateAmt -= $num
$part = $part.Substring(0, $part.Length - $num)
}
$trucatedOutput = "$part$trucatedOutput"
}
return $trucatedOutput
}
# ===== IMAGE =====
$img = if (-not $noimage) {
if ($image) {
if ($image -eq 'wallpaper') {
$image = (Get-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name Wallpaper).Wallpaper
}
Add-Type -AssemblyName 'System.Drawing'
$OldImage = if (Test-Path $image -PathType Leaf) {
[Drawing.Bitmap]::FromFile((Resolve-Path $image))
} else {
[Drawing.Bitmap]::FromStream((Invoke-WebRequest $image -UseBasicParsing).RawContentStream)
}
# Divide scaled height by 2.2 to compensate for ASCII characters being taller than they are wide
[int]$ROWS = $OldImage.Height / $OldImage.Width * $COLUMNS / $(if ($ascii) { 2.2 } else { 1 })
$Bitmap = New-Object System.Drawing.Bitmap @($OldImage, [Drawing.Size]"$COLUMNS,$ROWS")
if ($ascii) {
$chars = ' .,:;+iIH$@'
for ($i = 0; $i -lt $Bitmap.Height; $i++) {
$currline = ""
for ($j = 0; $j -lt $Bitmap.Width; $j++) {
$p = $Bitmap.GetPixel($j, $i)
$currline += "$e[38;2;$($p.R);$($p.G);$($p.B)m$($chars[[math]::Floor($p.GetBrightness() * $chars.Length)])$e[0m"
}
$currline
}
} else {
for ($i = 0; $i -lt $Bitmap.Height; $i += 2) {
$currline = ""
for ($j = 0; $j -lt $Bitmap.Width; $j++) {
$pixel1 = $Bitmap.GetPixel($j, $i)
$char = [char]0x2580
if ($i -ge $Bitmap.Height - 1) {
if ($pixel1.A -lt $alphathreshold) {
$char = [char]0x2800
$ansi = "$e[49m"
} else {
$ansi = "$e[38;2;$($pixel1.R);$($pixel1.G);$($pixel1.B)m"
}
} else {
$pixel2 = $Bitmap.GetPixel($j, $i + 1)
if ($pixel1.A -lt $alphathreshold -or $pixel2.A -lt $alphathreshold) {
if ($pixel1.A -lt $alphathreshold -and $pixel2.A -lt $alphathreshold) {
$char = [char]0x2800
$ansi = "$e[49m"
} elseif ($pixel1.A -lt $alphathreshold) {
$char = [char]0x2584
$ansi = "$e[49;38;2;$($pixel2.R);$($pixel2.G);$($pixel2.B)m"
} else {
$ansi = "$e[49;38;2;$($pixel1.R);$($pixel1.G);$($pixel1.B)m"
}
} else {
$ansi = "$e[38;2;$($pixel1.R);$($pixel1.G);$($pixel1.B);48;2;$($pixel2.R);$($pixel2.G);$($pixel2.B)m"
}
}
$currline += "$ansi$char$e[0m"
}
$currline
}
}
$Bitmap.Dispose()
$OldImage.Dispose()
} elseif (($CustomAscii -is [Array]) -and ($CustomAscii.Length -gt 0)) {
$CustomAscii
} else {
if (-not $logo) {
if ($os -Like "*Windows 11 *") {
$logo = "Windows 11"
} elseif ($os -Like "*Windows 10 *" -Or $os -Like "*Windows 8.1 *" -Or $os -Like "*Windows 8 *") {
$logo = "Windows 10"
} else {
$logo = "Windows 7"
}
}
if ($logo -eq "Windows 11") {
$COLUMNS = 32
@(
"${e}[${t};34mlllllllllllllll lllllllllllllll"
"${e}[${t};34mlllllllllllllll lllllllllllllll"
"${e}[${t};34mlllllllllllllll lllllllllllllll"
"${e}[${t};34mlllllllllllllll lllllllllllllll"
"${e}[${t};34mlllllllllllllll lllllllllllllll"
"${e}[${t};34mlllllllllllllll lllllllllllllll"
"${e}[${t};34mlllllllllllllll lllllllllllllll"
"${e}[${t};34m "
"${e}[${t};34mlllllllllllllll lllllllllllllll"
"${e}[${t};34mlllllllllllllll lllllllllllllll"
"${e}[${t};34mlllllllllllllll lllllllllllllll"
"${e}[${t};34mlllllllllllllll lllllllllllllll"
"${e}[${t};34mlllllllllllllll lllllllllllllll"
"${e}[${t};34mlllllllllllllll lllllllllllllll"
"${e}[${t};34mlllllllllllllll lllllllllllllll"
)
} elseif ($logo -eq "Windows 10" -Or $logo -eq "Windows 8.1" -Or $logo -eq "Windows 8") {
$COLUMNS = 34
@(
"${e}[${t};34m ....,,:;+ccllll"
"${e}[${t};34m ...,,+:; cllllllllllllllllll"
"${e}[${t};34m,cclllllllllll lllllllllllllllllll"
"${e}[${t};34mllllllllllllll lllllllllllllllllll"
"${e}[${t};34mllllllllllllll lllllllllllllllllll"
"${e}[${t};34mllllllllllllll lllllllllllllllllll"
"${e}[${t};34mllllllllllllll lllllllllllllllllll"
"${e}[${t};34mllllllllllllll lllllllllllllllllll"
"${e}[${t};34m "
"${e}[${t};34mllllllllllllll lllllllllllllllllll"
"${e}[${t};34mllllllllllllll lllllllllllllllllll"
"${e}[${t};34mllllllllllllll lllllllllllllllllll"
"${e}[${t};34mllllllllllllll lllllllllllllllllll"
"${e}[${t};34mllllllllllllll lllllllllllllllllll"
"${e}[${t};34m``'ccllllllllll lllllllllllllllllll"
"${e}[${t};34m ``' \\*:: :ccllllllllllllllll"
"${e}[${t};34m ````````''*::cll"
"${e}[${t};34m ````"
)
} elseif ($logo -eq "Windows 7" -Or $logo -eq "Windows Vista" -Or $logo -eq "Windows XP") {
$COLUMNS = 35
@(
"${e}[${t};31m ,.=:!!t3Z3z., "
"${e}[${t};31m :tt:::tt333EE3 "
"${e}[${t};31m Et:::ztt33EEE ${e}[32m@Ee., ..,"
"${e}[${t};31m ;tt:::tt333EE7 ${e}[32m;EEEEEEttttt33#"
"${e}[${t};31m :Et:::zt333EEQ. ${e}[32mSEEEEEttttt33QL"
"${e}[${t};31m it::::tt333EEF ${e}[32m@EEEEEEttttt33F "
"${e}[${t};31m ;3=*^``````'*4EEV ${e}[32m:EEEEEEttttt33@. "
"${e}[${t};34m ,.=::::it=., ${e}[31m`` ${e}[32m@EEEEEEtttz33QF "
"${e}[${t};34m ;::::::::zt33) ${e}[32m'4EEEtttji3P* "
"${e}[${t};34m :t::::::::tt33 ${e}[33m:Z3z.. ${e}[32m```` ${e}[33m,..g. "
"${e}[${t};34m i::::::::zt33F ${e}[33mAEEEtttt::::ztF "
"${e}[${t};34m ;:::::::::t33V ${e}[33m;EEEttttt::::t3 "
"${e}[${t};34m E::::::::zt33L ${e}[33m@EEEtttt::::z3F "
"${e}[${t};34m{3=*^``````'*4E3) ${e}[33m;EEEtttt:::::tZ`` "
"${e}[${t};34m `` ${e}[33m:EEEEtttt::::z7 "
"${e}[${t};33m 'VEzjt:;;z>*`` "
)
} elseif ($logo -eq "Microsoft") {
$COLUMNS = 13
@(
"${e}[${t};31m┌─────┐${e}[32m┌─────┐"
"${e}[${t};31m│ │${e}[32m│ │"
"${e}[${t};31m│ │${e}[32m│ │"
"${e}[${t};31m└─────┘${e}[32m└─────┘"
"${e}[${t};34m┌─────┐${e}[33m┌─────┐"
"${e}[${t};34m│ │${e}[33m│ │"
"${e}[${t};34m│ │${e}[33m│ │"
"${e}[${t};34m└─────┘${e}[33m└─────┘"
)
} elseif ($logo -eq "Windows 2000" -Or $logo -eq "Windows 98" -Or $logo -eq "Windows 95") {
$COLUMNS = 45
@(
" ${e}[${t};30mdBBBBBBBb"
" ${e}[${t};30mdBBBBBBBBBBBBBBBb"
" ${e}[${t};30m 000 BBBBBBBBBBBBBBBBBBBB"
"${e}[${t};30m::::: 000000 BBBBB${e}[${t};31mdBB${e}[${t};30mBBBB${e}[${t};32mBBBb${e}[${t};30mBBBBBBB"
"${e}[${t};31m::::: ${e}[${t};30m====== 000${e}[${t};31m000 BBBBBBBB${e}[${t};30mBBBB${e}[${t};32mBBBBBBBBB${e}[${t};30mBBBB"
"${e}[${t};31m::::: ====== ${e}[${t};31m000000 BBBBBBBB${e}[${t};30mBBBB${e}[${t};32mBBBBBBBBB${e}[${t};30mBBBB"
"${e}[${t};31m::::: ====== ${e}[${t};31m000000 BBBBBBBB${e}[${t};30mBBBB${e}[${t};32mBBBBBBBBB${e}[${t};30mBBBB"
"${e}[${t};31m::::: ====== ${e}[${t};31m000000 BBBBBBBB${e}[${t};30mBBBB${e}[${t};32mBBBBBBBBB${e}[${t};30mBBBB"
"${e}[${t};31m::::: ====== 000000 BBBBf${e}[${t};30mBBBBBBBBBBB${e}[${t};32m`BBBB${e}[${t};30mBBBB"
"${e}[${t};30m::::: ${e}[${t};31m====== 000${e}[${t};30m000 BBBBBBBBBBBBBBBBBBBBBBBBB"
"${e}[${t};30m::::: ====== 000000 BBBBB${e}[${t};34mdBB${e}[${t};30mBBBB${e}[${t};33mBBBb${e}[${t};30mBBBBB${e}[${t};30mBBBB"
"${e}[${t};34m::::: ${e}[${t};30m====== 000${e}[${t};34m000 BBBBBBBB${e}[${t};30mBBBB${e}[${t};33mBBBBBBBBB${e}[${t};30mBBBB"
"${e}[${t};34m::::: ====== 000000 BBBBBBBB${e}[${t};30mBBBB${e}[${t};33mBBBBBBBBB${e}[${t};30mBBBB"
"${e}[${t};34m::::: ====== 000000 BBBBBBBB${e}[${t};30mBBBB${e}[${t};33mBBBBBBBBB${e}[${t};30mBBBB"
"${e}[${t};34m::::: ====== 000000 BBBBBBBB${e}[${t};30mBBBB${e}[${t};33mBBBBBBBBB${e}[${t};30mBBBB"
"${e}[${t};34m::::: ====== 000000 BBBBf${e}[${t};30mBBBBBBBBBBB${e}[${t};33m`BBBB${e}[${t};30mBBBB"
"${e}[${t};30m::::: ${e}[${t};34m====== 000${e}[${t};30m000 BBBBBf `BBBBBBBBB"
"${e}[${t};30m :: ====== 000000 BBf `BBBBB"
" ${c1} == 000000 B BBB"
)
} else {
Write-Error 'The only version logos supported are Windows 11, Windows 10/8.1/8, Windows 7/Vista/XP, Windows 2000/98/95 and Microsoft.'
exit 1
}
}
}
# ===== BLANK =====
function info_blank {
return @{}
}
# ===== COLORBAR =====
function info_colorbar {
return @(
@{
title = ""
content = ('{0}[0;40m{1}{0}[0;41m{1}{0}[0;42m{1}{0}[0;43m{1}{0}[0;44m{1}{0}[0;45m{1}{0}[0;46m{1}{0}[0;47m{1}{0}[0m') -f $e, ' '
},
@{
title = ""
content = ('{0}[0;100m{1}{0}[0;101m{1}{0}[0;102m{1}{0}[0;103m{1}{0}[0;104m{1}{0}[0;105m{1}{0}[0;106m{1}{0}[0;107m{1}{0}[0m') -f $e, ' '
}
)
}
# ===== OS =====
function info_os {
return @{
title = "OS"
content = "$($os.Caption.TrimStart('Microsoft ')) [$($os.OSArchitecture)]"
}
}
# ===== MOTHERBOARD =====
function info_motherboard {
$motherboard = Get-CimInstance Win32_BaseBoard -CimSession $cimSession -Property Manufacturer,Product
return @{
title = "Motherboard"
content = "{0} {1}" -f $motherboard.Manufacturer, $motherboard.Product
}
}
# ===== TITLE =====
function info_title {
return @{
title = ""
content = "${e}[1;33m{0}${e}[0m@${e}[1;33m{1}${e}[0m" -f [System.Environment]::UserName,$env:COMPUTERNAME
}
}
# ===== DASHES =====
function info_dashes {
$length = [System.Environment]::UserName.Length + $env:COMPUTERNAME.Length + 1
return @{
title = ""
content = "-" * $length
}
}
# ===== COMPUTER =====
function info_computer {
$compsys = Get-CimInstance -ClassName Win32_ComputerSystem -Property Manufacturer,Model -CimSession $cimSession
return @{
title = "Host"
content = '{0} {1}' -f $compsys.Manufacturer, $compsys.Model
}
}
# ===== KERNEL =====
function info_kernel {
return @{
title = "Kernel"
content = "$([System.Environment]::OSVersion.Version)"
}
}
# ===== UPTIME =====
function info_uptime {
@{
title = "Uptime"
content = $(switch ([System.DateTime]::Now - $os.LastBootUpTime) {
({ $PSItem.Days -eq 1 }) { '1 day' }
({ $PSItem.Days -gt 1 }) { "$($PSItem.Days) days" }
({ $PSItem.Hours -eq 1 }) { '1 hour' }
({ $PSItem.Hours -gt 1 }) { "$($PSItem.Hours) hours" }
({ $PSItem.Minutes -eq 1 }) { '1 minute' }
({ $PSItem.Minutes -gt 1 }) { "$($PSItem.Minutes) minutes" }
}) -join ' '
}
}
# ===== RESOLUTION =====
function info_resolution {
Add-Type -AssemblyName System.Windows.Forms
$displays = foreach ($monitor in [System.Windows.Forms.Screen]::AllScreens) {
"$($monitor.Bounds.Size.Width)x$($monitor.Bounds.Size.Height)"
}
return @{
title = "Resolution"
content = $displays -join ', '
}
}
# ===== TERMINAL =====
# this section works by getting the parent processes of the current powershell instance.
function info_terminal {
$programs = 'powershell', 'pwsh', 'winpty-agent', 'cmd', 'zsh', 'sh', 'bash', 'fish', 'env', 'nu', 'elvish', 'csh', 'tcsh', 'python', 'xonsh'
if ($PSVersionTable.PSEdition.ToString() -ne 'Core') {
$parent = Get-Process -Id (Get-CimInstance -ClassName Win32_Process -Filter "ProcessId = $PID" -Property ParentProcessId -CimSession $cimSession).ParentProcessId -ErrorAction Ignore
for () {
if ($parent.ProcessName -in $programs) {
$parent = Get-Process -Id (Get-CimInstance -ClassName Win32_Process -Filter "ProcessId = $($parent.ID)" -Property ParentProcessId -CimSession $cimSession).ParentProcessId -ErrorAction Ignore
continue
}
break
}
} else {
$parent = (Get-Process -Id $PID).Parent
for () {
if ($parent.ProcessName -in $programs) {
$parent = (Get-Process -Id $parent.ID).Parent
continue
}
break
}
}
$terminal = switch ($parent.ProcessName) {
{ $PSItem -in 'explorer', 'conhost' } { 'Windows Console' }
'Console' { 'Console2/Z' }
'ConEmuC64' { 'ConEmu' }
'WindowsTerminal' { 'Windows Terminal' }
'FluentTerminal.SystemTray' { 'Fluent Terminal' }
'Code' { 'Visual Studio Code' }
default { $PSItem }
}
if (-not $terminal) {
$terminal = "$e[91m(Unknown)"
}
return @{
title = "Terminal"
content = $terminal
}
}
# ===== THEME =====
function info_theme {
$themeinfo = Get-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize' -Name SystemUsesLightTheme, AppsUseLightTheme
$themename = (Get-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes' -Name CurrentTheme).CurrentTheme.Split('\')[-1].Replace('.theme', '')
$systheme = if ($themeinfo.SystemUsesLightTheme) { "Light" } else { "Dark" }
$apptheme = if ($themeinfo.AppsUseLightTheme) { "Light" } else { "Dark" }
return @{
title = "Theme"
content = "$themename (System: $systheme, Apps: $apptheme)"
}
}
# ===== CPU/GPU =====
function info_cpu {
$cpu = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Env:COMPUTERNAME).OpenSubKey("HARDWARE\DESCRIPTION\System\CentralProcessor\0")
$cpuname = $cpu.GetValue("ProcessorNameString")
$cpuname = if ($cpuname.Contains('@')) {
($cpuname -Split '@')[0].Trim()
} else {
$cpuname.Trim()
}
return @{
title = "CPU"
content = "$cpuname @ $($cpu.GetValue("~MHz") / 1000)GHz" # [math]::Round($cpu.GetValue("~MHz") / 1000, 1) is 2-5ms slower
}
}
function info_gpu {
[System.Collections.ArrayList]$lines = @()
#loop through Win32_VideoController
foreach ($gpu in Get-CimInstance -ClassName Win32_VideoController -Property Name -CimSession $cimSession) {
[void]$lines.Add(@{
title = "GPU"
content = $gpu.Name
})
}
return $lines
}
# ===== CPU USAGE =====
function info_cpu_usage {
# Get all running processes and assign to a variable to allow reuse
$processes = [System.Diagnostics.Process]::GetProcesses()
$loadpercent = 0
$proccount = $processes.Count
# Get the number of logical processors in the system
$CPUs = [System.Environment]::ProcessorCount
$timenow = [System.Datetime]::Now
$processes.ForEach{
if ($_.StartTime -gt 0) {
# Replicate the functionality of New-Timespan
$timespan = ($timenow.Subtract($_.StartTime)).TotalSeconds
# Calculate the CPU usage of the process and add to the total
$loadpercent += $_.CPU * 100 / $timespan / $CPUs
}
}
return @{
title = "CPU Usage"
content = get_level_info "" $cpustyle $loadpercent "$proccount processes" -altstyle
}
}
# ===== MEMORY =====
function info_memory {
$total = $os.TotalVisibleMemorySize / 1mb
$used = ($os.TotalVisibleMemorySize - $os.FreePhysicalMemory) / 1mb
$usage = [math]::floor(($used / $total * 100))
return @{
title = "Memory"
content = get_level_info " " $memorystyle $usage "$($used.ToString("#.##")) GiB / $($total.ToString("#.##")) GiB"
}
}
# ===== DISK USAGE =====
function info_disk {
[System.Collections.ArrayList]$lines = @()
function to_units($value) {
if ($value -gt 1tb) {
return "$([math]::round($value / 1tb, 1)) TiB"
} else {
return "$([math]::floor($value / 1gb)) GiB"
}
}
[System.IO.DriveInfo]::GetDrives().ForEach{
$diskLetter = $_.Name.SubString(0,2)
if ($showDisks.Contains($diskLetter) -or $showDisks.Contains("*")) {
try {
if ($_.TotalSize -gt 0) {
$used = $_.TotalSize - $_.AvailableFreeSpace
$usage = [math]::Floor(($used / $_.TotalSize * 100))
[void]$lines.Add(@{
title = "Disk ($diskLetter)"
content = get_level_info "" $diskstyle $usage "$(to_units $used) / $(to_units $_.TotalSize)"
})
}
} catch {
[void]$lines.Add(@{
title = "Disk ($diskLetter)"
content = "(failed to get disk usage)"
})
}
}
}
return $lines
}
# ===== POWERSHELL VERSION =====
function info_pwsh {
return @{
title = "Shell"
content = "PowerShell v$($PSVersionTable.PSVersion)"
}
}
# ===== POWERSHELL PACKAGES =====
function info_ps_pkgs {
$ps_pkgs = @()
# Get all installed packages
$pgp = Get-Package -ProviderName PowerShellGet
# Get the number of packages where the tags contains PSModule or PSScript
$modulecount = $pgp.Where({$_.Metadata["tags"] -like "*PSModule*"}).count
$scriptcount = $pgp.Where({$_.Metadata["tags"] -like "*PSScript*"}).count
if ($modulecount) {
if ($modulecount -eq 1) { $modulestring = "1 Module" }
else { $modulestring = "$modulecount Modules" }
$ps_pkgs += "$modulestring"
}
if ($scriptcount) {
if ($scriptcount -eq 1) { $scriptstring = "1 Script" }
else { $scriptstring = "$scriptcount Scripts" }
$ps_pkgs += "$scriptstring"
}
if (-not $ps_pkgs) {
$ps_pkgs = "(none)"
}
return @{
title = "PS Packages"
content = $ps_pkgs -join ', '
}
}
# ===== PACKAGES =====
function info_pkgs {
$pkgs = @()
if ("winget" -in $ShowPkgs -and (Get-Command -Name winget -ErrorAction Ignore)) {
$wingetpkg = (winget list | Where-Object {$_.Trim("`n`r`t`b-\|/ ").Length -ne 0} | Measure-Object).Count - 1
if ($wingetpkg) {
$pkgs += "$wingetpkg (system)"
}
}
if ("choco" -in $ShowPkgs -and (Get-Command -Name choco -ErrorAction Ignore)) {
$chocopkg = Invoke-Expression $(
"(& choco list" + $(if([version](& choco --version).Split('-')[0]`
-lt [version]'2.0.0'){" --local-only"}) + ")[-1].Split(' ')[0] - 1")
if ($chocopkg) {
$pkgs += "$chocopkg (choco)"
}
}
if ("scoop" -in $ShowPkgs) {
$scoopdir = if ($Env:SCOOP) { "$Env:SCOOP\apps" } else { "$Env:UserProfile\scoop\apps" }
if (Test-Path $scoopdir) {
$scooppkg = (Get-ChildItem -Path $scoopdir -Directory).Count - 1
}
if ($scooppkg) {
$pkgs += "$scooppkg (scoop)"
}
}
foreach ($pkgitem in $CustomPkgs) {
if (Test-Path Function:"info_pkg_$pkgitem") {
$count = & "info_pkg_$pkgitem"
$pkgs += "$count ($pkgitem)"
}
}
if (-not $pkgs) {
$pkgs = "(none)"
}
return @{
title = "Packages"
content = $pkgs -join ', '
}
}
# ===== BATTERY =====
function info_battery {
Add-Type -AssemblyName System.Windows.Forms
$battery = [System.Windows.Forms.SystemInformation]::PowerStatus
if ($battery.BatteryChargeStatus -eq 'NoSystemBattery') {
return @{
title = "Battery"
content = "(none)"
}
}
$status = if ($battery.BatteryChargeStatus -like '*Charging*') {
"Charging"
} elseif ($battery.PowerLineStatus -like '*Online*') {
"Plugged in"
} else {
"Discharging"
}
$timeRemaining = $battery.BatteryLifeRemaining / 60
# Don't show time remaining if Windows hasn't properly reported it yet
$timeFormatted = if ($timeRemaining -ge 0) {
$hours = [math]::floor($timeRemaining / 60)
$minutes = [math]::floor($timeRemaining % 60)
", ${hours}h ${minutes}m"
}
return @{
title = "Battery"
content = get_level_info " " $batterystyle "$([math]::round($battery.BatteryLifePercent * 100))" "$status$timeFormatted" -altstyle
}
}
# ===== LOCALE =====
function info_locale {
# Hashtables for language and region codes
$localeLookup = @{
"10" = "American Samoa"; "100" = "Guinea"; "10026358" = "Americas";
"10028789" = "Åland Islands"; "10039880" = "Caribbean"; "10039882" = "Northern Europe";
"10039883" = "Southern Africa"; "101" = "Guyana"; "10210824" = "Western Europe";
"10210825" = "Australia and New Zealand"; "103" = "Haiti"; "104" = "Hong Kong SAR";
"10541" = "Europe"; "106" = "Honduras"; "108" = "Croatia";
"109" = "Hungary"; "11" = "Argentina"; "110" = "Iceland";
"111" = "Indonesia"; "113" = "India"; "114" = "British Indian Ocean Territory";
"116" = "Iran"; "117" = "Israel"; "118" = "Italy";
"119" = "Côte d'Ivoire"; "12" = "Australia"; "121" = "Iraq";
"122" = "Japan"; "124" = "Jamaica"; "125" = "Jan Mayen";
"126" = "Jordan"; "127" = "Johnston Atoll"; "129" = "Kenya";
"130" = "Kyrgyzstan"; "131" = "North Korea"; "133" = "Kiribati";
"134" = "Korea"; "136" = "Kuwait"; "137" = "Kazakhstan";
"138" = "Laos"; "139" = "Lebanon"; "14" = "Austria";
"140" = "Latvia"; "141" = "Lithuania"; "142" = "Liberia";
"143" = "Slovakia"; "145" = "Liechtenstein"; "146" = "Lesotho";
"147" = "Luxembourg"; "148" = "Libya"; "149" = "Madagascar";
"151" = "Macao SAR"; "15126" = "Isle of Man"; "152" = "Moldova";
"154" = "Mongolia"; "156" = "Malawi"; "157" = "Mali";
"158" = "Monaco"; "159" = "Morocco"; "160" = "Mauritius";
"161832015" = "Saint Barthélemy"; "161832256" = "U.S. Minor Outlying Islands"; "161832257" = "Latin America and the Caribbean";
"161832258" = "Bonaire, Sint Eustatius and Saba"; "162" = "Mauritania"; "163" = "Malta";
"164" = "Oman"; "165" = "Maldives"; "166" = "Mexico";
"167" = "Malaysia"; "168" = "Mozambique"; "17" = "Bahrain";
"173" = "Niger"; "174" = "Vanuatu"; "175" = "Nigeria";
"176" = "Netherlands"; "177" = "Norway"; "178" = "Nepal";
"18" = "Barbados"; "180" = "Nauru"; "181" = "Suriname";
"182" = "Nicaragua"; "183" = "New Zealand"; "184" = "Palestinian Authority";
"185" = "Paraguay"; "187" = "Peru"; "19" = "Botswana";
"190" = "Pakistan"; "191" = "Poland"; "192" = "Panama";
"193" = "Portugal"; "194" = "Papua New Guinea"; "195" = "Palau";
"196" = "Guinea-Bissau"; "19618" = "North Macedonia"; "197" = "Qatar";
"198" = "Réunion"; "199" = "Marshall Islands"; "2" = "Antigua and Barbuda";
"20" = "Bermuda"; "200" = "Romania"; "201" = "Philippines";
"202" = "Puerto Rico"; "203" = "Russia"; "204" = "Rwanda";
"205" = "Saudi Arabia"; "206" = "Saint Pierre and Miquelon"; "207" = "Saint Kitts and Nevis";
"208" = "Seychelles"; "209" = "South Africa"; "20900" = "Melanesia";
"21" = "Belgium"; "210" = "Senegal"; "212" = "Slovenia";
"21206" = "Micronesia"; "21242" = "Midway Islands"; "2129" = "Asia";
"213" = "Sierra Leone"; "214" = "San Marino"; "215" = "Singapore";
"216" = "Somalia"; "217" = "Spain"; "218" = "Saint Lucia";
"219" = "Sudan"; "22" = "Bahamas"; "220" = "Svalbard";
"221" = "Sweden"; "222" = "Syria"; "223" = "Switzerland";
"224" = "United Arab Emirates"; "225" = "Trinidad and Tobago"; "227" = "Thailand";
"228" = "Tajikistan"; "23" = "Bangladesh"; "231" = "Tonga";