This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/getlantern/systray" | |
) | |
func main() { | |
systray.Run(onReady, onExit) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
func getData()(string){ | |
cpuData:="Cpu: "+strconv.Itoa(getCpuUsage())+"% " | |
memoryData:="Mem: "+strconv.Itoa(getMemoryUsage())+"% " | |
return cpuData+memoryData | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func onReady() { | |
go func() { | |
var result string | |
for { | |
result = getData() | |
systray.SetTitle(result) | |
} | |
}() | |
systray.AddSeparator() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"github.com/shirou/gopsutil/mem" | |
"math" | |
) | |
func getMemoryUsage()int{ | |
memory,err:=mem.VirtualMemory() | |
if err!=nil{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"time" | |
"github.com/shirou/gopsutil/cpu" | |
) | |
func getCpuUsage()int{ | |
percent,err:=cpu.Percent(time.Second,false) | |
if err!=nil{ | |
log.Fatal(err) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "`date` : Build starting . . . " | |
mkdir -p ~/Applications/PingService.app/Contents/MacOS | |
go mod download | |
GOMAXPROCS=1 go build -o PingService 2>err.log | |
if [ -s "err.log" ];then | |
echo -e "`date` : Build failed, check err.log " | |
exit 2 | |
fi | |
cp PingService ~/Applications/PingService.app/Contents/MacOS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func pingGoogle() (string,error) { | |
pinger,err := ping.NewPinger("www.google.com") | |
if err != nil { | |
return "", errors.New("Network Error") | |
} | |
pinger.Count = 1 | |
pinger.Timeout=2 * time.Second | |
pinger.Debug=true | |
pinger.Run() | |
if pinger.Statistics().Rtts==nil{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func onReady(){ | |
go func() { | |
var result string | |
var err error | |
for { | |
result,err=pingGoogle() | |
if err!=nil{ | |
systray.SetTitle(err.Error()) | |
}else{ | |
systray.SetTitle(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"github.com/getlantern/systray" | |
"github.com/sparrc/go-ping" | |
"strconv" | |
"time" | |
) | |
func main(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Base settings install | |
# Zero everything out... | |
zerombr | |
clearpart --all --initlabel | |
# Generic boot settings... | |
cdrom | |
lang en_US.UTF-8 | |
keyboard 'us' |