From 775c0f580b527d3b19af52e4fa512599c6c76fb2 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sat, 31 Aug 2024 13:25:10 +0100 Subject: [PATCH] examples/events: init --- examples/events/events.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/events/events.go diff --git a/examples/events/events.go b/examples/events/events.go new file mode 100644 index 0000000..c44e262 --- /dev/null +++ b/examples/events/events.go @@ -0,0 +1,30 @@ +// Basic example on how to handle events in hyprland-go. +package main + +import ( + "fmt" + + "github.com/thiagokokada/hyprland-go/event" +) + +type ev struct { + event.NoopEventHandler +} + +func (e *ev) Workspace(w event.WorkspaceName) { + fmt.Printf("Workspace: %+v\n", w) +} + +func (e *ev) ActiveWindow(w event.ActiveWindow) { + fmt.Printf("ActiveWindow: %+v\n", w) +} + +func main() { + c := event.MustEventClient() + event.Subscribe( + c, &ev{}, + event.EventWorkspace, + event.EventActiveWindow, + ) + +}