remove unneeded comments

This commit is contained in:
frosty 2024-08-24 19:42:48 -04:00
parent d87187f61b
commit 79d644a712

11
main.go
View file

@ -40,7 +40,6 @@ var (
sigChan = make(chan os.Signal, 1024) sigChan = make(chan os.Signal, 1024)
signalMap = make(map[os.Signal][]*Module) signalMap = make(map[os.Signal][]*Module)
// X connection data
x *xgb.Conn x *xgb.Conn
root xproto.Window root xproto.Window
) )
@ -55,7 +54,6 @@ type Module struct {
Template string Template string
Signal int Signal int
// Internal
pos int pos int
} }
@ -72,7 +70,6 @@ func (m *Module) Run() {
output.WriteString("failed") output.WriteString("failed")
} else { } else {
if m.Template != "" { if m.Template != "" {
// Parse the output and apply the provided template
tmpl, err := template.New("module").Parse(m.Template) tmpl, err := template.New("module").Parse(m.Template)
if err != nil { if err != nil {
log.Printf("template parsing error: %v\n", err) log.Printf("template parsing error: %v\n", err)
@ -84,7 +81,6 @@ func (m *Module) Run() {
return return
} }
} else { } else {
// Use the output as is
fmt.Fprintf(&output, "%v", info) fmt.Fprintf(&output, "%v", info)
} }
} }
@ -155,10 +151,8 @@ func monitorUpdates(setXRootName bool) {
if !bytes.Equal(combinedOutputBytes, lastOutput) { if !bytes.Equal(combinedOutputBytes, lastOutput) {
if setXRootName { if setXRootName {
// Set X root window name
xproto.ChangeProperty(x, xproto.PropModeReplace, root, xproto.AtomWmName, xproto.AtomString, 8, uint32(len(combinedOutputBytes)), combinedOutputBytes) xproto.ChangeProperty(x, xproto.PropModeReplace, root, xproto.AtomWmName, xproto.AtomString, 8, uint32(len(combinedOutputBytes)), combinedOutputBytes)
} else { } else {
// Send to stdout
fmt.Printf("%s\n", combinedOutputBytes) fmt.Printf("%s\n", combinedOutputBytes)
} }
lastOutput = append([]byte(nil), combinedOutputBytes...) lastOutput = append([]byte(nil), combinedOutputBytes...)
@ -174,12 +168,10 @@ func handleSignal(sig os.Signal) {
} }
func main() { func main() {
// Parse flags
var flags Flags var flags Flags
flag.BoolVar(&flags.SetXRootName, "x", false, "set x root window name") flag.BoolVar(&flags.SetXRootName, "x", false, "set x root window name")
flag.Parse() flag.Parse()
// Grab X root window if requested
if flags.SetXRootName { if flags.SetXRootName {
var err error var err error
x, root, err = grabXRootWindow() x, root, err = grabXRootWindow()
@ -189,15 +181,12 @@ func main() {
defer x.Close() defer x.Close()
} }
// Initialize modules
for i := range modules { for i := range modules {
go modules[i].Init(i) go modules[i].Init(i)
} }
// Monitor changes to the combined output
go monitorUpdates(flags.SetXRootName) go monitorUpdates(flags.SetXRootName)
// Handle signals sent for modules
for sig := range sigChan { for sig := range sigChan {
go handleSignal(sig) go handleSignal(sig)
} }