aboutsummaryrefslogtreecommitdiffstats
path: root/swaymsg
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-03-12 13:48:42 +0100
committerLibravatar emersion <contact@emersion.fr>2018-03-12 13:48:42 +0100
commit4ab55060644a9c7f01e8f257b7dd34067adfaaf8 (patch)
tree837339ed8929c7c21630b3f4b49d53a0482b5a97 /swaymsg
parentMerge pull request #1617 from swaywm/drop-travis (diff)
downloadsway-4ab55060644a9c7f01e8f257b7dd34067adfaaf8.tar.gz
sway-4ab55060644a9c7f01e8f257b7dd34067adfaaf8.tar.zst
sway-4ab55060644a9c7f01e8f257b7dd34067adfaaf8.zip
ipc: add output modes
Diffstat (limited to 'swaymsg')
-rw-r--r--swaymsg/main.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/swaymsg/main.c b/swaymsg/main.c
index 88b14813..c9be3a86 100644
--- a/swaymsg/main.c
+++ b/swaymsg/main.c
@@ -125,13 +125,16 @@ static void pretty_print_output(json_object *o) {
125 json_object_object_get_ex(rect, "y", &y); 125 json_object_object_get_ex(rect, "y", &y);
126 json_object_object_get_ex(rect, "width", &width); 126 json_object_object_get_ex(rect, "width", &width);
127 json_object_object_get_ex(rect, "height", &height); 127 json_object_object_get_ex(rect, "height", &height);
128 json_object *modes;
129 json_object_object_get_ex(o, "modes", &modes);
130
128 printf( 131 printf(
129 "Output %s '%s %s %s'%s%s\n" 132 "Output %s '%s %s %s'%s%s\n"
130 " Mode: %dx%d @ %f Hz\n" 133 " Current mode: %dx%d @ %f Hz\n"
131 " Position: %d,%d\n" 134 " Position: %d,%d\n"
132 " Scale factor: %dx\n" 135 " Scale factor: %dx\n"
133 " Transform: %s\n" 136 " Transform: %s\n"
134 " Workspace: %s\n\n", 137 " Workspace: %s\n",
135 json_object_get_string(name), 138 json_object_get_string(name),
136 json_object_get_string(make), 139 json_object_get_string(make),
137 json_object_get_string(model), 140 json_object_get_string(model),
@@ -145,6 +148,25 @@ static void pretty_print_output(json_object *o) {
145 json_object_get_string(transform), 148 json_object_get_string(transform),
146 json_object_get_string(ws) 149 json_object_get_string(ws)
147 ); 150 );
151
152 size_t modes_len = json_object_array_length(modes);
153 if (modes_len > 0) {
154 printf(" Available modes:\n");
155 for (size_t i = 0; i < modes_len; ++i) {
156 json_object *mode = json_object_array_get_idx(modes, i);
157
158 json_object *mode_width, *mode_height, *mode_refresh;
159 json_object_object_get_ex(mode, "width", &mode_width);
160 json_object_object_get_ex(mode, "height", &mode_height);
161 json_object_object_get_ex(mode, "refresh", &mode_refresh);
162
163 printf(" %dx%d @ %f Hz\n", json_object_get_int(mode_width),
164 json_object_get_int(mode_height),
165 (float)json_object_get_int(mode_refresh) / 1000);
166 }
167 }
168
169 printf("\n");
148} 170}
149 171
150static void pretty_print_version(json_object *v) { 172static void pretty_print_version(json_object *v) {