every file

This commit is contained in:
David Alasow 2019-04-30 10:22:10 +02:00
commit 54d0046c88
2 changed files with 38 additions and 0 deletions

BIN
main Executable file

Binary file not shown.

38
main.go Normal file
View File

@ -0,0 +1,38 @@
package main
import (
"fmt"
"github.com/0xAX/notificator"
"github.com/distatus/battery"
"time"
)
var notify *notificator.Notificator
func main() {
warning := false
for {
battery, er := battery.Get(0)
if er != nil {
fmt.Println(er)
continue
}
percentage := battery.Current / battery.Full * 100
if !warning && percentage <= 15 && string(battery.State) != "Charging" {
warning = true
notify = notificator.New(notificator.Options{
DefaultIcon: "/home/trac/Go/src/github.com/0xAX/notificatior/icon/golang.png",
AppName: "Low Battery",
})
err := notify.Push("Battery LOW", "Plug in a charger", "/home/trac/Go/src/github.com/0xAX/notificator/icon/golang.png", notificator.UR_CRITICAL)
if err != nil {
panic(err)
}
} else if percentage > 15 || string(battery.State) == "Charging" {
warning = true
}
time.Sleep(1000 * time.Millisecond)
}
}