Skip to content

Commit

Permalink
Update 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
frenchie0x4ff committed Aug 27, 2020
1 parent e4b1534 commit b8f075d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
11 changes: 9 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,27 @@ type TitleValues struct {
Baseboard string `json:"baseboard"`
ProcessCount string `json:"processCount"`
Uptime string `json:"uptime"`
Network string `json:"network"`
}

func updateConfig(config Config) {
user, _ := user.Current()
if config.Version == 0 {
config.AutoUpdate = true
config.Version = 1
}
if config.Version == 1 {
config.Titles.Network = "Local IP"
config.Format = append(config.Format, "network")
config.Version = 2
}
config.Version = 1
file, _ := json.MarshalIndent(config, "", " ")
_ = ioutil.WriteFile(user.HomeDir+"\\.winfetch.json", file, 0644)
}

func newConfig() Config {
config := Config{}
config.Format = []string{"user", "sep", "uptime", "mem", "cpu", "procs", "cpuCores", "cpuThreads", "disk", "wversion", "gpus", "bios", "baseboard"}
config.Format = []string{"user", "sep", "uptime", "mem", "cpu", "procs", "cpuCores", "cpuThreads", "disk", "wversion", "gpus", "bios", "baseboard", "network"}
config.ShowASCII = true
config.UseSmallASCII = false
config.UseCustomASCII = false
Expand All @@ -73,6 +79,7 @@ func newConfig() Config {
config.Titles.Uptime = "Uptime"
config.Titles.ProcessCount = "Processes"
config.Titles.CPU = "CPU #"
config.Titles.Network = "Local IP"
config.AutoUpdate = true
config.Version = 1
return config
Expand Down
16 changes: 16 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"math"
"net"
"os/user"
"strconv"
"strings"
Expand Down Expand Up @@ -138,6 +139,9 @@ func generateInfo(config Config, title xterm256.Color, info xterm256.Color, user
}
for x := range config.Format {
switch config.Format[x] {
case "network":
outboundIP := getOutboundIP()
s = append(s, xterm256.Sprint(title, config.Titles.Network+": ")+xterm256.Sprint(info, outboundIP.String()))
case "user":
user, _ := user.Current()
s = append(s, xterm256.Sprint(userc, strings.ReplaceAll(user.Username, "\\", "@")))
Expand Down Expand Up @@ -230,3 +234,15 @@ func generateInfo(config Config, title xterm256.Color, info xterm256.Color, user
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, "███"))
return s
}

func getOutboundIP() net.IP {
conn, err := net.Dial("udp", "8.8.8.8:80")
if err != nil {
log.Fatal(err)
}
defer conn.Close()

localAddr := conn.LocalAddr().(*net.UDPAddr)

return localAddr.IP
}
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1
1.5.0

0 comments on commit b8f075d

Please sign in to comment.