hypr/model_event.go

65 lines
2.3 KiB
Go

package hypr
import (
"encoding/json"
"strings"
)
type Event struct {
Type EventType `json:"type"`
Data []string `json:"data"`
}
func parseEvent(str string) Event {
data := strings.Split(str, ">>")
return Event{
Type: EventType(data[0]),
Data: strings.Split(data[1], ","),
}
}
func (e Event) String() string {
data, _ := json.MarshalIndent(e, "", "\t")
return string(data)
}
type EventType = string
const (
EventTypeTick EventType = "tick"
EventTypeActiveWindow EventType = "activewindow"
EventTypeActiveWindowV2 EventType = "activewindowv2"
EventTypeKeyboardFocus EventType = "keyboardfocus"
EventTypeMoveWorkspace EventType = "moveworkspace"
EventTypeFocusedMon EventType = "focusedmon"
EventTypeMoveWindow EventType = "movewindow"
EventTypeOpenLayer EventType = "openlayer"
EventTypeCloseLayer EventType = "closelayer"
EventTypeOpenWindow EventType = "openwindow"
EventTypeCloseWindow EventType = "closewindow"
EventTypeUrgent EventType = "urgent"
EventTypeMinimize EventType = "minimize"
EventTypeMonitorAdded EventType = "monitoradded"
EventTypeMonitorRemoved EventType = "monitorremoved"
EventTypeCreateWorkspace EventType = "createworkspace"
EventTypeDestroyWorkspace EventType = "destroyworkspace"
EventTypeFullscreen EventType = "fullscreen"
EventTypeChangeFloatingMode EventType = "changefloatingmode"
EventTypeWorkspace EventType = "workspace"
EventTypeSubmap EventType = "submap"
EventTypeMouseMove EventType = "mousemove"
EventTypeMouseButton EventType = "mousebutton"
EventTypeMouseAxis EventType = "mouseaxis"
EventTypeTouchDown EventType = "touchdown"
EventTypeTouchUp EventType = "touchup"
EventTypeTouchMove EventType = "touchmove"
EventTypeActiveLayout EventType = "activelayout"
EventTypePreRender EventType = "prerender"
EventTypeScreencast EventType = "screencast"
EventTypeRender EventType = "render"
EventTypeWindowtitle EventType = "windowtitle"
EventTypeConfigReloaded EventType = "configreloaded"
EventTypePreConfigReload EventType = "preconfigreload"
EventTypeKeyPress EventType = "keypress"
)