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:
parent
7c03d607cb
commit
db43c947b0
@ -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))
|
||||
|
@ -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
13
security/dns_windows.go
Normal 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
23
security/users_windows.go
Normal 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
|
||||
}
|
@ -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
|
57
security/widget_windows.go
Normal file
57
security/widget_windows.go
Normal 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
|
||||
}
|
@ -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
|
||||
|
Loadingβ¦
x
Reference in New Issue
Block a user