aboutsummaryrefslogtreecommitdiff
path: root/swaybar/swaybar-protocol.7.scd
blob: 7a9dc572e0ebb470b522a797980c48670c213c27 (plain)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
swaybar-protocol(7)

# NAME

swaybar-protocol - JSON status line protocol for swaybar

# SUMMARY

swaybar defines the following JSON protocol to specify what information is
displayed in the status line on the right side of swaybar. The protocol
comprises a header, that is a JSON object, followed by a newline (*0x0A*),
followed by an infinite JSON array that represents the information to display.
All communication is done by writing the status line to standard output and
reading events from standard input.

# HEADER

The header is a JSON object with support for the following properties (only
_version_ is required):
[- *PROPERTY*
:- *DATA TYPE*
:- *DEFAULT*
:- *DESCRIPTION*
|- version
:  integer
:  -
:[ The protocol version to use. Currently, this must be *1*
|- click_events
:  boolean
:  false
:  Whether to receive click event information to standard input
|- cont_signal
:  integer
:  SIGCONT
:  The signal that swaybar should send to continue processing
|- stop_signal
:  integer
:  SIGSTOP
:  The signal that swaybar should send to stop processing

## MINIMAL HEADER
```
{
	"version": 1
}
```

## FULL HEADER
```
{
	"version": 1,
	"click_events": true,
	"cont_signal": 18,
	"stop_signal": 19
}
```

# BODY

The body is an infinite array, where each element of the array is a
representation of the status line at the time that the element was written.
Each element of the array is itself an array of JSON objects, where each
object represents a block in the status line. Each block can have the following
properties (only _full_text_ is required):

[- *PROPERTY*
:- *DATA TYPE*
:- *DESCRIPTION*
|- full_text
:  string
:[ The text that will be displayed. *If missing, the block will be skipped.*
|- short_text
:  string
:  If given and the text needs to be shortened due to space, this will be
   displayed instead of _full_text_
|- color
:  string
:  The text color to use in #RRGGBBAA or #RRGGBB notation
|- background
:  string
:  The background color for the block in #RRGGBBAA or #RRGGBB notation
|- border
:  string
:  The border color for the block in #RRGGBBAA or #RRGGBB notation
|- border_top
:  integer
:  The height in pixels of the top border. The default is 1
|- border_bottom
:  integer
:  The height in pixels of the bottom border. The default is 1
|- border_left
:  integer
:  The width in pixels of the left border. The default is 1
|- border_right
:  integer
:  The width in pixels of the right border. The default is 1
|- min_width
:  integer or string
:  The minimum width to use for the block. This can either be given in pixels
   or a string can be given to allow for it to be calculated based on the
   width of the string.
|- align
:  string
:  If the text does not span the full width of the block, this specifies how
   the text should be aligned inside of the block. This can be _left_
   (default), _right_, or _center_.
|- name
:  string
:  A name for the block. This is only used to identify the block for click
   events. If set, each block should have a unique _name_ and _instance_ pair.
|- instance
:  string
:  The instance of the _name_ for the block. This is only used to identify the
   block for click events. If set, each block should have a unique _name_ and
   _instance_ pair.
|- urgent
:  boolean
:  Whether the block should be displayed as urgent. Currently swaybar utilizes
   the colors set in the sway config for urgent workspace buttons. See
   *sway-bar*(5) for more information on bar color configuration.
|- separator
:  boolean
:  Whether the bar separator should be drawn after the block. See *sway-bar*(5)
   for more information on how to set the separator text.
|- separator_block_width
:  integer
:  The amount of pixels to leave blank after the block. The separator text will
   be displayed centered in this gap. The default is 9 pixels.
|- markup
:  string
:  The type of markup to use when parsing the text for the block. This can
   either be _pango_ or _none_ (default).

Other properties may be given and swaybar will ignore any property that it does
not know. It is recommended to prefix any custom properties with an underscore
to make it easier to distinguish them from protocol properties.

## BODY EXAMPLE

```
[
	[
		{
			"full_text": "25%",
			"min_width": "100%",
			"urgent": false
		},
		{
			"full_text": "Thu 30 May 2019 02:15:15"
		}
	],
	[
		{
			"full_text": "20%",
			"min_width": "100%",
			"urgent": false
		},
		{
			"full_text": "Thu 30 May 2019 02:20:52"
		}
	],
	[
		{
			"full_text": "15%",
			"min_width": "100%",
			"urgent": true
		},
		{
			"full_text": "Thu 30 May 2019 02:25:41"
		}
	],
	...
```

## FULL BLOCK EXAMPLE
```
{
	"full_text": "Thu 30 May 2019 02:09:15",
	"short_text": "02:09",
	"color": "#ccccccff",
	"background": "#111111ff",
	"border": "#222222ff",
	"border_top": 1,
	"border_bottom": 1,
	"border_left": 1,
	"border_right": 1,
	"min_width": 100,
	"align": "center",
	"name": "clock",
	"instance": "edt",
	"urgent": false,
	"separator": true,
	"separator_block_width": 5,
	"markup": "none"
}
```

# CLICK EVENTS

If requested in the header, swaybar will write a JSON object, that can be read
from standard in, when the user clicks on a block. The event object will have
the following properties:

[- *PROPERTY*
:- *DATA TYPE*
:- *DESCRIPTION*
|- name
:  string
:[ The name of the block, if set
|- instance
:  string
:  The instance of the block, if set
|- x
:  integer
:  The x location that the click occurred at
|- y
:  integer
:  The y location that the click occurred at
|- button
:  integer
:  The x11 button number for the click. If the button does not have an x11
   button mapping, this will be _0_.
|- event
:  integer
:  The event code that corresponds to the button for the click
|- relative_x
:  integer
:  The x location of the click relative to the top-left of the block
|- relative_y
:  integer
:  The y location of the click relative to the top-left of the block
|- width
:  integer
:  The width of the block in pixels
|- height
:  integer
:  The height of the block in pixels

*Differences from i3bar's protocol:*
- _button_ may be _0_ for buttons that do not have x11 button mappings
- _event_ has been introduced to allow for non-x11 buttons to be represented
- The _modifiers_ property is not currently added by swaybar

## EXAMPLE

```
{
	"name": "clock",
	"instance": "edt",
	"x": 1900,
	"y": 10,
	"button": 1,
	"event": 274,
	"relative_x": 100,
	"relative_y": 8,
	"width": 120,
	"height": 18
}
```

# SEE ALSO

*sway-bar*(5)