Dynamically generate capabilities header

Signed-off-by: AKP <tom@tdpain.net>
This commit is contained in:
akp 2022-05-27 14:03:57 +01:00
parent 29ac240241
commit 43ce8474cb
No known key found for this signature in database
GPG key ID: AA5726202C8879B7
2 changed files with 9 additions and 7 deletions

View file

@ -6,7 +6,7 @@
This is a i3wm status bar that's built as a toy project. It's pretty basic, doesn't have many features and isn't very configurable unless you want to edit the source and recompile it.
This interacts with i3 using the [i3bar input protocol](https://i3wm.org/docs/i3bar-protocol.html).
This interacts with i3 using the [i3bar input protocol](https://i3wm.org/docs/i3bar-protocol.html). i3 versions earlier than v4.3 are not supported.
### Features

View file

@ -31,15 +31,17 @@ func New(writer io.Writer, updateInterval time.Duration, updateSignal syscall.Si
}
func (b *I3bar) Initialise() error {
_, err := b.writer.Write([]byte(
[]byte("{\"version\":1}\n"), // This means that versions of i3 prior to
// 4.3 can still work with this bar. We do not use touch features, nor
//do we use any special stop/start handling. That's handled by the OS.
))
capabilities, err := json.Marshal(map[string]any{
"version": 1,
"click_events": true,
})
if err != nil {
return err
}
if _, err := b.writer.Write(append(capabilities, '\n')); err != nil {
return err
}
b.hasInitialised = true
return nil