mirror of
https://codeberg.org/frosty/modbot.git
synced 2024-09-19 11:46:34 -04:00
pass update function to monitorUpdates
This commit is contained in:
parent
ab8f19441c
commit
170d4e3484
16
main.go
16
main.go
|
@ -140,7 +140,7 @@ func createOutput(b *bytes.Buffer) {
|
||||||
b.Write(suffix)
|
b.Write(suffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
func monitorUpdates(setXRootName bool) {
|
func monitorUpdates(outputHandler func([]byte)) {
|
||||||
var lastOutput []byte
|
var lastOutput []byte
|
||||||
var combinedOutput bytes.Buffer
|
var combinedOutput bytes.Buffer
|
||||||
|
|
||||||
|
@ -150,11 +150,7 @@ func monitorUpdates(setXRootName bool) {
|
||||||
combinedOutputBytes := combinedOutput.Bytes()
|
combinedOutputBytes := combinedOutput.Bytes()
|
||||||
|
|
||||||
if !bytes.Equal(combinedOutputBytes, lastOutput) {
|
if !bytes.Equal(combinedOutputBytes, lastOutput) {
|
||||||
if setXRootName {
|
outputHandler(combinedOutputBytes)
|
||||||
xproto.ChangeProperty(x, xproto.PropModeReplace, root, xproto.AtomWmName, xproto.AtomString, 8, uint32(len(combinedOutputBytes)), combinedOutputBytes)
|
|
||||||
} else {
|
|
||||||
fmt.Printf("%s\n", combinedOutputBytes)
|
|
||||||
}
|
|
||||||
lastOutput = append([]byte(nil), combinedOutputBytes...)
|
lastOutput = append([]byte(nil), combinedOutputBytes...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,7 +181,13 @@ func main() {
|
||||||
go modules[i].Init(i)
|
go modules[i].Init(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
go monitorUpdates(flags.SetXRootName)
|
go monitorUpdates(func(combinedOutputBytes []byte) {
|
||||||
|
if flags.SetXRootName {
|
||||||
|
xproto.ChangeProperty(x, xproto.PropModeReplace, root, xproto.AtomWmName, xproto.AtomString, 8, uint32(len(combinedOutputBytes)), combinedOutputBytes)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("%s\n", combinedOutputBytes)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
for sig := range sigChan {
|
for sig := range sigChan {
|
||||||
go handleSignal(sig)
|
go handleSignal(sig)
|
||||||
|
|
Loading…
Reference in a new issue