1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

fixed platform-specific stuff.

Mostly fixed character encoding and stuff.

Signed-off-by: Mike Lloyd <mike@reboot3times.org>
This commit is contained in:
Mike Lloyd 2018-06-03 23:16:40 -06:00
parent 7c03d607cb
commit db43c947b0
9 changed files with 99 additions and 6 deletions

View File

@ -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))

View File

@ -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"))

13
security/dns_windows.go Normal file
View File

@ -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)
}

23
security/users_windows.go Normal file
View File

@ -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
}

View File

@ -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

View File

@ -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
}

View File

@ -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