diff --git a/bamboohr/widget.go b/bamboohr/widget.go index a8997013..0b75bbf8 100644 --- a/bamboohr/widget.go +++ b/bamboohr/widget.go @@ -16,7 +16,7 @@ type Widget struct { func NewWidget() *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(" πŸ‘½ BambooHR ", "bamboohr", false), + TextWidget: wtf.NewTextWidget(" BambooHR ", "bamboohr", false), } return &widget @@ -37,7 +37,7 @@ func (widget *Widget) Refresh() { ) widget.UpdateRefreshedAt() - widget.View.SetTitle(fmt.Sprintf(" πŸ‘½ Away (%d) ", len(todayItems))) + widget.View.SetTitle(fmt.Sprintf(" Away (%d) ", len(todayItems))) widget.View.Clear() fmt.Fprintf(widget.View, "%s", widget.contentFrom(todayItems)) diff --git a/clocks/widget.go b/clocks/widget.go index e5214fb6..6003d1be 100644 --- a/clocks/widget.go +++ b/clocks/widget.go @@ -18,7 +18,7 @@ type Widget struct { func NewWidget() *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(" πŸ•— World Clocks ", "clocks", false), + TextWidget: wtf.NewTextWidget(" World Clocks ", "clocks", false), } widget.clockColl = widget.buildClockCollection(Config.UMap("wtf.mods.clocks.locations")) diff --git a/security/dns.go b/security/dns_darwin.go similarity index 100% rename from security/dns.go rename to security/dns_darwin.go diff --git a/security/dns_windows.go b/security/dns_windows.go new file mode 100644 index 00000000..53f9e748 --- /dev/null +++ b/security/dns_windows.go @@ -0,0 +1,13 @@ +package security + +import ( + "os/exec" + + "github.com/senorprogrammer/wtf/wtf" +) + + +func DnsServers() string { + cmd := exec.Command("powershell.exe", "Get-DnsClientServerAddress | Select-Object –ExpandProperty ServerAddresses") + return wtf.ExecuteCommand(cmd) +} diff --git a/security/users.go b/security/users_darwin.go similarity index 100% rename from security/users.go rename to security/users_darwin.go diff --git a/security/users_windows.go b/security/users_windows.go new file mode 100644 index 00000000..587ad88f --- /dev/null +++ b/security/users_windows.go @@ -0,0 +1,23 @@ +package security + +import ( + "os/exec" + "strings" + + "github.com/senorprogrammer/wtf/wtf" +) + +func LoggedInUsers() []string { + cmd := exec.Command("powershell.exe", "(query user) -replace '\\s{2,}', ','") + users := wtf.ExecuteCommand(cmd) + return cleanUsers(strings.Split(users, "\n")[1:]) +} + +func cleanUsers(users []string) []string { + cleaned := make([]string, 0) + for _, user := range users { + usr := strings.Split(user, ",") + cleaned = append(cleaned, usr[0]) + } + return cleaned +} diff --git a/security/widget.go b/security/widget_darwin.go similarity index 94% rename from security/widget.go rename to security/widget_darwin.go index 37653640..330afbaa 100644 --- a/security/widget.go +++ b/security/widget_darwin.go @@ -17,7 +17,7 @@ type Widget struct { func NewWidget() *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(" 🀺 Security ", "security", false), + TextWidget: wtf.NewTextWidget(" Security ", "security", false), } return &widget diff --git a/security/widget_windows.go b/security/widget_windows.go new file mode 100644 index 00000000..c2bccdd1 --- /dev/null +++ b/security/widget_windows.go @@ -0,0 +1,57 @@ +package security + +import ( + "fmt" + "strings" + + "github.com/olebedev/config" + "github.com/senorprogrammer/wtf/wtf" +) + +// Config is a pointer to the global config object +var Config *config.Config + +type Widget struct { + wtf.TextWidget +} + +func NewWidget() *Widget { + widget := Widget{ + TextWidget: wtf.NewTextWidget(" Security ", "security", false), + } + + return &widget +} + +/* -------------------- Exported Functions -------------------- */ + +func (widget *Widget) Refresh() { + if widget.Disabled() { + return + } + + data := NewSecurityData() + data.Fetch() + + widget.UpdateRefreshedAt() + widget.View.Clear() + + fmt.Fprintf(widget.View, "%s", widget.contentFrom(data)) +} + +/* -------------------- Unexported Functions -------------------- */ + +func (widget *Widget) contentFrom(data *SecurityData) string { + str := " [red]WiFi[white]\n" + str = str + fmt.Sprintf(" %8s: %s\n", "Network", data.WifiName) + str = str + fmt.Sprintf(" %8s: %s\n", "Crypto", data.WifiEncryption) + str = str + "\n" + str = str + " [red]Firewall[white] [red]DNS[white]\n" + str = str + fmt.Sprintf(" %8s: %4s %12s\n", "Enabled", data.FirewallEnabled, data.DnsAt(0)) + str = str + fmt.Sprintf(" %8s: %4s %12s\n", "Stealth", data.FirewallStealth, data.DnsAt(1)) + str = str + "\n" + str = str + " [red]Users[white]\n" + str = str + fmt.Sprintf(" %s", strings.Join(data.LoggedInUsers, ",")) + + return str +} diff --git a/status/widget.go b/status/widget.go index a4f2b4d0..449562ca 100644 --- a/status/widget.go +++ b/status/widget.go @@ -18,7 +18,7 @@ type Widget struct { func NewWidget() *Widget { widget := Widget{ - TextWidget: wtf.NewTextWidget(" πŸŽ‰ Status ", "status", false), + TextWidget: wtf.NewTextWidget(" Status ", "status", false), CurrentIcon: 0, } @@ -45,7 +45,7 @@ func (widget *Widget) Refresh() { /* -------------------- Unexported Functions -------------------- */ func (widget *Widget) animation() string { - icons := []string{"πŸ‘", "🀜", "πŸ€™", "🀜", "🀘", "🀜", "✊", "🀜", "πŸ‘Œ", "🀜"} + icons := []string{"|", "/", "-", "\\", "|"} next := icons[widget.CurrentIcon] widget.CurrentIcon = widget.CurrentIcon + 1