@@ -9,12 +9,6 @@ import (
99 "os"
1010 "encoding/json"
1111 "io/ioutil"
12-
13- ps "github.com/shirou/gopsutil/process"
14- hst "github.com/shirou/gopsutil/host"
15- // cp "github.com/shirou/gopsutil/cpu"
16- "github.com/jaypipes/ghw"
17- "golang.org/x/sys/windows/registry"
1812 "github.com/gilliek/go-xterm256/xterm256"
1913)
2014
@@ -99,7 +93,7 @@ llllllllllllll lllllllllllllllllll
9993 ' \\*:: :ccllllllllllllllll
10094 ''''''''''*::cll
10195 ''''`
102- var winArtSmall string = ` .
96+ var winArtSmall string = ` .
10397 ....,,:;+ccll
10498 ..,+:; cllllllllllllllll
10599,cclllllllll lllllllllllllllll
@@ -112,11 +106,7 @@ llllllllllll lllllllllllllllll
112106llllllllllll lllllllllllllllll
113107 'ccllllllll lllllllllllllllll
114108 ' \\*:: :ccllllllllllllll
115- ''''''''''*::;`
116- memory , err := ghw .Memory ()
117- if err != nil {
118- fmt .Printf ("Error getting memory info: %v" , err )
119- }
109+ ''''''''''*::;`
120110 user , err := user .Current ()
121111 if _ , err := os .Stat (user .HomeDir + "\\ .winfetch.json" ); os .IsNotExist (err ) {
122112 config := newConfig ()
@@ -146,6 +136,7 @@ llllllllllll lllllllllllllllll
146136 }
147137 winArtResult = strings .Split (string (content ), "\n " )
148138 }
139+
149140 title := xterm256 .Green
150141 ascii := xterm256 .Blue
151142 sep := xterm256 .Red
@@ -159,97 +150,7 @@ llllllllllll lllllllllllllllll
159150 userc = getCustomColor (config .UserColor )
160151 info = getCustomColor (config .InfoColor )
161152 }
162-
163- s = append (s , xterm256 .Sprint (userc , strings .ReplaceAll (user .Username , "\\ " , "@" )))
164- s = append (s , xterm256 .Sprint (sep , "--------------------------------" ))
165-
166- if (config .ShowUptime ){
167- uptime , err := hst .Uptime ()
168- if (err != nil ) {
169- log .Fatal ("Failed to Get Uptime!" )
170- }
171- uptimes := secondsToHuman (int (uptime ))
172- s = append (s , xterm256 .Sprint (title , config .Titles .Uptime + ": " ) + xterm256 .Sprint (info , uptimes ))
173- }
174-
175- memorySplit := strings .Split (memory .String (), "(" )
176- mem := strings .Split (memorySplit [1 ], "," )
177- usableMem := strings .Split (mem [1 ], "usable" )
178- physMem := strings .Split (mem [0 ], "physical" )
179- if (config .ShowMem ) {
180- s = append (s , xterm256 .Sprint (title , config .Titles .Memory + ": " ) + xterm256 .Sprint (info , strings .ReplaceAll (usableMem [0 ], "MB " , "GB" ) + "/" + strings .ReplaceAll (physMem [0 ], "MB" , "GB" )))
181- }
182- if (config .ShowTotalCPUCores || config .ShowTotalCPUThreads || config .ShowCPU ){
183- cpu , err := ghw .CPU ()
184- if err != nil {
185- fmt .Printf ("Error getting CPU info: %v" , err )
186- }
187- if (config .ShowCPU ){
188- in := 0
189- for x := range cpu .Processors {
190- s = append (s , xterm256 .Sprint (title , "CPU #" + fmt .Sprint (in ) + ": " ) + xterm256 .Sprint (info , cpu .Processors [x ].Model ))
191- }
192- }
193- if (config .ShowTotalCPUCores ){
194- s = append (s , xterm256 .Sprint (title , config .Titles .CPUCores + ": " ) + xterm256 .Sprint (info , fmt .Sprint (cpu .TotalCores )))
195- }
196- if (config .ShowTotalCPUThreads ){
197- s = append (s , xterm256 .Sprint (title , config .Titles .CPUThreads + ": " ) + xterm256 .Sprint (info , fmt .Sprint (cpu .TotalThreads )))
198- }
199- }
200- if (config .ShowProcessCount ){
201- pids , err := ps .Pids ()
202-
203- if err != nil {
204- log .Fatal ("Couldn't get Processes!" )
205- }
206-
207- s = append (s , xterm256 .Sprint (title , "Proccesses Running: " ) + xterm256 .Sprint (info , int64 (len (pids ))))
208- }
209- if (config .ShowWindowsVersion ){
210- k , err := registry .OpenKey (registry .LOCAL_MACHINE , `SOFTWARE\Microsoft\Windows NT\CurrentVersion` , registry .QUERY_VALUE )
211-
212- pn , _ , err := k .GetStringValue ("ProductName" )
213- if err != nil {
214- log .Fatal (err )
215- }
216- s = append (s , xterm256 .Sprint (title , config .Titles .WindowsVersion + ": " ) + xterm256 .Sprint (info , pn ))
217- }
218- if (config .ShowTotalDiskSize ){
219- bi , err := ghw .Block ()
220- if err != nil {
221- fmt .Printf ("Error getting disk info: %v" , err )
222- }
223- s = append (s , xterm256 .Sprint (title , config .Titles .DiskSize + ": " ) + xterm256 .Sprint (info , ByteFormat (float64 (bi .TotalPhysicalBytes ), 1 )))
224- }
225- if (config .ShowGPUS ){
226- gpu , err := ghw .GPU ()
227- if err != nil {
228- fmt .Printf ("Error getting GPU info: %v" , err )
229- }
230- gpuin := 0
231- for _ , c := range gpu .GraphicsCards {
232- s = append (s , xterm256 .Sprint (title , config .Titles .GPUs + fmt .Sprint (gpuin ) + ": " ) + xterm256 .Sprint (info , c .DeviceInfo .Product .Name ))
233- gpuin ++
234- }
235- }
236- if (config .ShowBios ){
237- bios , err := ghw .BIOS ()
238- if err != nil {
239- fmt .Printf ("Error getting BIOS info: %v" , err )
240- }
241- s = append (s , xterm256 .Sprint (title , config .Titles .Bios + ": " ) + xterm256 .Sprint (info , bios .Vendor ))
242- }
243- if (config .ShowBaseboard ){
244- bb , err := ghw .Baseboard ()
245- if err != nil {
246- fmt .Printf ("Error getting BB info: %v" , err )
247- }
248- s = append (s , xterm256 .Sprint (title , config .Titles .Baseboard + ": " ) + xterm256 .Sprint (info , bb .Vendor ))
249- }
250- s = append (s , "" )
251- s = append (s , " " + xterm256 .Sprint (xterm256 .LightGray , "███" ) + xterm256 .Sprint (xterm256 .Red , "███" ) + xterm256 .Sprint (xterm256 .Green , "███" ) + xterm256 .Sprint (xterm256 .Yellow , "███" ) + xterm256 .Sprint (xterm256 .Blue , "███" ) + xterm256 .Sprint (xterm256 .Magenta , "███" ) + xterm256 .Sprint (xterm256 .Cyan , "███" ))
252- s = append (s , " " + xterm256 .Sprint (xterm256 .DarkGray , "███" ) + xterm256 .Sprint (xterm256 .DarkRed , "███" ) + xterm256 .Sprint (xterm256 .DarkGreen , "███" ) + xterm256 .Sprint (xterm256 .DarkYellow , "███" ) + xterm256 .Sprint (xterm256 .DarkBlue , "███" ) + xterm256 .Sprint (xterm256 .DarkMagenta , "███" ) + xterm256 .Sprint (xterm256 .DarkCyan , "███" ))
153+ s = generateInfo (config , title , info , userc , sep )
253154 scanner := bufio .NewScanner (strings .NewReader ("" ))
254155 if (config .UseSmallAscii ){
255156 scanner = bufio .NewScanner (strings .NewReader (winArtSmall ))
0 commit comments