1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
open! Ppx_yojson_conv_lib.Yojson_conv
module Tags = struct
type t =
{ output : string
; viewed : int list
; occupied : int list
; urgent : int list
; focused : int list
}
[@@deriving yojson]
end
module Window = struct
type t =
{ id : int
; identifier : string option
; title : string option
; app_id : string option
; output : string option
; tags : int list
; focused : bool
; urgent : bool
; captured : bool
; hidden : bool
; presentation : string
; sticky : string
; scratchpad : string option
; stashed : bool
; swallowing : bool
; labels : string list
}
[@@deriving yojson]
end
module Output = struct
type t =
{ name : string option
; labels : string list
; focused : bool
; captured : bool
}
[@@deriving yojson]
end
module Layout = struct
type t =
{ output : string
; layout : string
; scheme : string option
; symbol : string
}
[@@deriving yojson]
end
module Mode = struct
type t =
{ seat : string
; mode : string
}
[@@deriving yojson]
end
module Focus = struct
type t =
{ seat : string
; output : string option
; title : string option
; app_id : string option
; tags : int list option
}
[@@deriving yojson]
end
type t =
| Tags
| Window
| Layout
| Mode
| Focus
| Output
let all = [ Tags; Window; Layout; Mode; Focus; Output ]
let equal (a : t) (b : t) = a = b
let of_string = function
| "tags" -> Ok Tags
| "window" -> Ok Window
| "layout" -> Ok Layout
| "mode" -> Ok Mode
| "focus" -> Ok Focus
| "output" -> Ok Output
| s -> Error (Printf.sprintf "unrecognized event kind: %s" s)
;;
let to_string = function
| Tags -> "tags"
| Window -> "window"
| Layout -> "layout"
| Mode -> "mode"
| Focus -> "focus"
| Output -> "output"
;;
let t_of_yojson = function
| `String s ->
(match of_string s with
| Ok t -> t
| Error msg -> failwith msg)
| j -> of_yojson_error "Record.t_of_yojson: string expected" j
;;
let yojson_of_t t = `String (to_string t)