mirror of
https://github.com/nboughton/dotfiles
synced 2024-11-26 13:33:54 +01:00
removed scratch folder
This commit is contained in:
parent
30c44f676e
commit
64a078986a
@ -1,85 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/nboughton/dotfiles/waybar/modules/gobar"
|
|
||||||
regex "github.com/nboughton/go-utils/regex/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
type config struct {
|
|
||||||
Versions []string `json:"versions,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
var outfile = fmt.Sprintf("%s/tmp/aur-vcheck.json", os.Getenv(("HOME")))
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
confPath := "config.json"
|
|
||||||
// Check for config path
|
|
||||||
if len(os.Args) > 1 {
|
|
||||||
confPath = os.Args[1]
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read config
|
|
||||||
log.Println("Reading config")
|
|
||||||
f, err := os.Open(confPath)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("cannot open config: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
c := config{}
|
|
||||||
if err := json.NewDecoder(f).Decode(&c); err != nil {
|
|
||||||
log.Fatalf("failed to decode config: %s", err)
|
|
||||||
}
|
|
||||||
f.Close()
|
|
||||||
|
|
||||||
// Check Versions
|
|
||||||
log.Println("Checking versions")
|
|
||||||
out := []string{}
|
|
||||||
for _, appVer := range c.Versions {
|
|
||||||
app := fmt.Sprintf("@%s", strings.Split(appVer, "@")[1])
|
|
||||||
o, err := exec.Command("npm", "info", app).CombinedOutput()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("npm exec failed: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
v := regex.ANSI.ReplaceAllString(strings.Fields(strings.Split(string(o), "\n")[1])[0], "")
|
|
||||||
if appVer != v {
|
|
||||||
out = append(out, fmt.Sprintf("%s -> %s", appVer, v))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
n := len(out)
|
|
||||||
m := gobar.Module{
|
|
||||||
Name: "AUR VERSION CHECK",
|
|
||||||
Summary: "AUR NPM Packages Out Of Date",
|
|
||||||
JSON: gobar.JSONOutput{
|
|
||||||
Text: fmt.Sprintf("%d", n),
|
|
||||||
Alt: fmt.Sprintf("%d", n),
|
|
||||||
Tooltip: strings.Join(out, "\n"),
|
|
||||||
Class: "no-updates",
|
|
||||||
Percentage: n,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if n > 0 {
|
|
||||||
log.Println("Sending DBUS notification")
|
|
||||||
m.JSON.Class = "updates"
|
|
||||||
m.Notify(m.JSON.Tooltip, 10000)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write output for waybar module
|
|
||||||
log.Println("Writing JSON output")
|
|
||||||
f, err = os.Create(outfile)
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
m.JSON.Write(f)
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
module github.com/nboughton/dotfiles/waybar/modules/aur-vcheck/scratch
|
|
||||||
|
|
||||||
go 1.15
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/nboughton/dotfiles/waybar/modules/gobar v0.0.0-20201209215918-92c9d95cf046
|
|
||||||
github.com/nboughton/go-utils v0.0.0-20200108161841-5007e997f484
|
|
||||||
)
|
|
@ -1,10 +0,0 @@
|
|||||||
github.com/esiqveland/notify v0.9.1 h1:hX6ZD3FCQJXI46AzUM/iWekcMfnZ9TPE4uIu9Hrn1D4=
|
|
||||||
github.com/esiqveland/notify v0.9.1/go.mod h1:63UbVSaeJwF0LVJARHFuPgUAoM7o1BEvCZyknsuonBc=
|
|
||||||
github.com/godbus/dbus/v5 v5.0.3 h1:ZqHaoEF7TBzh4jzPmqVhE/5A1z9of6orkAe5uHoAeME=
|
|
||||||
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
|
||||||
github.com/nboughton/dotfiles/waybar/modules/gobar v0.0.0-20201209205251-0cb3d887b86b h1:31iZB5HtYjck3DHFi4siAL/PhUAzicnGSV7/yL6JokM=
|
|
||||||
github.com/nboughton/dotfiles/waybar/modules/gobar v0.0.0-20201209205251-0cb3d887b86b/go.mod h1:9MC4JW6muedO0QtIPqhZLM01B7ZjUGD6mDjdePRA1M0=
|
|
||||||
github.com/nboughton/dotfiles/waybar/modules/gobar v0.0.0-20201209215918-92c9d95cf046 h1:dRU4VhJuR2nyC8lWNwuFgWPxDEueb6pKENNZzUpur8c=
|
|
||||||
github.com/nboughton/dotfiles/waybar/modules/gobar v0.0.0-20201209215918-92c9d95cf046/go.mod h1:9MC4JW6muedO0QtIPqhZLM01B7ZjUGD6mDjdePRA1M0=
|
|
||||||
github.com/nboughton/go-utils v0.0.0-20200108161841-5007e997f484 h1:mqED7SC5umrSOUC4eUleOuHUsrwvbVl/DQy+jVHFlvo=
|
|
||||||
github.com/nboughton/go-utils v0.0.0-20200108161841-5007e997f484/go.mod h1:iSex0rTt7j+NRoVAEwO0ADC0jkx53W/3OsbYgNMxSWU=
|
|
Loading…
Reference in New Issue
Block a user