swaybar-protocol - JSON status line protocol for swaybar
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.
The header is a JSON object with support for the following properties (only version is required): |
{
"version": 1 |
}
{
"version": 1, | |
"click_events": true, | |
"cont_signal": 18, | |
"stop_signal": 19 |
}
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):
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.
[
[ |
||||
{ |
||||
"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_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" |
}
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:
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
{
"name": "clock", | ||
"instance": "edt", | ||
"x": 1900, | ||
"y": 10, | ||
"button": 1, | ||
"event": 274, | ||
"relative_x": 100, | ||
"relative_y": 8, | ||
"width": 120, | ||
"height": 18 |
}
sway-bar(5)