-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handlers & DBus (gif, clock & counter as examples) #2
Conversation
handler.go
Outdated
) | ||
|
||
type IconHandler interface { | ||
Icon(page int, index int, key *Key, dev streamdeck.Device) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On reading this through again I realised that this name confused me. It's a noun which implies a getter but there is no return . What should an icon handler do? perhaps it needs a doc, or a more descriptive name?
The same may be true of "Key" below as well, except that could be read as a verb I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 instances of panic (either panic
or log.Panic
-one is on the dbus init which kind of makes sense.
The others are in image load, key update etc, but there are no recover clauses - so if the GUI sets the config to an invalid image or a key handler fails this daemon will quit. Seems like a bad idea
The following diff fixes a crash on first time launch. index dfac0e1..1ec2686 100644
--- a/interface.go
+++ b/interface.go
@@ -67,11 +67,10 @@ func SetKey(currentKey *Key, i int) {
func SetPage(config *Config, page int, dev streamdeck.Device) {
p = page
currentPage := config.Pages[page]
- for i := 0; i < 15; i++ {
- currentKey := ¤tPage[i]
+ for i, currentKey := range currentPage {
if currentKey.Buff == nil {
if currentKey.IconHandler == "" {
- SetKey(currentKey, i)
+ SetKey(¤tKey, i)
} else if currentKey.IconHandlerStruct == nil {
var handler IconHandler
@@ -85,7 +84,7 @@ func SetPage(config *Config, page int, dev streamdeck.Device) {
if handler == nil {
continue
}
- handler.Icon(page, i, currentKey, dev)
+ handler.Icon(page, i, ¤tKey, dev)
currentKey.IconHandlerStruct = handler
}
} else {
diff --git a/main.go b/main.go
index 5c4a68d..80e84e3 100644
--- a/main.go
+++ b/main.go
@@ -38,7 +38,9 @@ func main() {
config.Pages = append(config.Pages, Page{})
}
cleanupHook()
- SetPage(config, 0, dev)
+ if len(config.Pages) > 0 {
+ SetPage(config, 0, dev)
+ }
go InitDBUS()
Listen()
}
~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With modules on compile fails - the version of API is out of date
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, with the reservation that I think the handler API should be improved.
If that is someone else's work in a new PR then merge away
Handlers & DBus (gif, clock & counter as examples)
No description provided.