aboutsummaryrefslogtreecommitdiffstats
path: root/swaymsg/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaymsg/main.c')
-rw-r--r--swaymsg/main.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/swaymsg/main.c b/swaymsg/main.c
index c08406e2..573a7b16 100644
--- a/swaymsg/main.c
+++ b/swaymsg/main.c
@@ -1,4 +1,3 @@
1#define _POSIX_C_SOURCE 200809L
2 1
3#include <limits.h> 2#include <limits.h>
4#include <stdio.h> 3#include <stdio.h>
@@ -60,7 +59,7 @@ static void pretty_print_cmd(json_object *r) {
60 if (!success_object(r)) { 59 if (!success_object(r)) {
61 json_object *error; 60 json_object *error;
62 if (!json_object_object_get_ex(r, "error", &error)) { 61 if (!json_object_object_get_ex(r, "error", &error)) {
63 printf("An unknkown error occurred"); 62 printf("An unknown error occurred");
64 } else { 63 } else {
65 printf("Error: %s\n", json_object_get_string(error)); 64 printf("Error: %s\n", json_object_get_string(error));
66 } 65 }
@@ -185,12 +184,14 @@ static void pretty_print_seat(json_object *i) {
185} 184}
186 185
187static void pretty_print_output(json_object *o) { 186static void pretty_print_output(json_object *o) {
188 json_object *name, *rect, *focused, *active, *ws, *current_mode; 187 json_object *name, *rect, *focused, *active, *power, *ws, *current_mode, *non_desktop;
189 json_object_object_get_ex(o, "name", &name); 188 json_object_object_get_ex(o, "name", &name);
190 json_object_object_get_ex(o, "rect", &rect); 189 json_object_object_get_ex(o, "rect", &rect);
191 json_object_object_get_ex(o, "focused", &focused); 190 json_object_object_get_ex(o, "focused", &focused);
192 json_object_object_get_ex(o, "active", &active); 191 json_object_object_get_ex(o, "active", &active);
192 json_object_object_get_ex(o, "power", &power);
193 json_object_object_get_ex(o, "current_workspace", &ws); 193 json_object_object_get_ex(o, "current_workspace", &ws);
194 json_object_object_get_ex(o, "non_desktop", &non_desktop);
194 json_object *make, *model, *serial, *scale, *scale_filter, *subpixel, 195 json_object *make, *model, *serial, *scale, *scale_filter, *subpixel,
195 *transform, *max_render_time, *adaptive_sync_status; 196 *transform, *max_render_time, *adaptive_sync_status;
196 json_object_object_get_ex(o, "make", &make); 197 json_object_object_get_ex(o, "make", &make);
@@ -213,10 +214,19 @@ static void pretty_print_output(json_object *o) {
213 json_object_object_get_ex(current_mode, "height", &height); 214 json_object_object_get_ex(current_mode, "height", &height);
214 json_object_object_get_ex(current_mode, "refresh", &refresh); 215 json_object_object_get_ex(current_mode, "refresh", &refresh);
215 216
216 if (json_object_get_boolean(active)) { 217 if (json_object_get_boolean(non_desktop)) {
218 printf(
219 "Output %s '%s %s %s' (non-desktop)\n",
220 json_object_get_string(name),
221 json_object_get_string(make),
222 json_object_get_string(model),
223 json_object_get_string(serial)
224 );
225 } else if (json_object_get_boolean(active)) {
217 printf( 226 printf(
218 "Output %s '%s %s %s'%s\n" 227 "Output %s '%s %s %s'%s\n"
219 " Current mode: %dx%d @ %.3f Hz\n" 228 " Current mode: %dx%d @ %.3f Hz\n"
229 " Power: %s\n"
220 " Position: %d,%d\n" 230 " Position: %d,%d\n"
221 " Scale factor: %f\n" 231 " Scale factor: %f\n"
222 " Scale filter: %s\n" 232 " Scale filter: %s\n"
@@ -231,6 +241,7 @@ static void pretty_print_output(json_object *o) {
231 json_object_get_int(width), 241 json_object_get_int(width),
232 json_object_get_int(height), 242 json_object_get_int(height),
233 (double)json_object_get_int(refresh) / 1000, 243 (double)json_object_get_int(refresh) / 1000,
244 json_object_get_boolean(power) ? "on" : "off",
234 json_object_get_int(x), json_object_get_int(y), 245 json_object_get_int(x), json_object_get_int(y),
235 json_object_get_double(scale), 246 json_object_get_double(scale),
236 json_object_get_string(scale_filter), 247 json_object_get_string(scale_filter),
@@ -247,7 +258,7 @@ static void pretty_print_output(json_object *o) {
247 json_object_get_string(adaptive_sync_status)); 258 json_object_get_string(adaptive_sync_status));
248 } else { 259 } else {
249 printf( 260 printf(
250 "Output %s '%s %s %s' (inactive)\n", 261 "Output %s '%s %s %s' (disabled)\n",
251 json_object_get_string(name), 262 json_object_get_string(name),
252 json_object_get_string(make), 263 json_object_get_string(make),
253 json_object_get_string(model), 264 json_object_get_string(model),
@@ -262,14 +273,22 @@ static void pretty_print_output(json_object *o) {
262 for (size_t i = 0; i < modes_len; ++i) { 273 for (size_t i = 0; i < modes_len; ++i) {
263 json_object *mode = json_object_array_get_idx(modes, i); 274 json_object *mode = json_object_array_get_idx(modes, i);
264 275
265 json_object *mode_width, *mode_height, *mode_refresh; 276 json_object *mode_width, *mode_height, *mode_refresh,
277 *mode_picture_aspect_ratio;
266 json_object_object_get_ex(mode, "width", &mode_width); 278 json_object_object_get_ex(mode, "width", &mode_width);
267 json_object_object_get_ex(mode, "height", &mode_height); 279 json_object_object_get_ex(mode, "height", &mode_height);
268 json_object_object_get_ex(mode, "refresh", &mode_refresh); 280 json_object_object_get_ex(mode, "refresh", &mode_refresh);
281 json_object_object_get_ex(mode, "picture_aspect_ratio",
282 &mode_picture_aspect_ratio);
269 283
270 printf(" %dx%d @ %.3f Hz\n", json_object_get_int(mode_width), 284 printf(" %dx%d @ %.3f Hz", json_object_get_int(mode_width),
271 json_object_get_int(mode_height), 285 json_object_get_int(mode_height),
272 (double)json_object_get_int(mode_refresh) / 1000); 286 (double)json_object_get_int(mode_refresh) / 1000);
287 if (mode_picture_aspect_ratio &&
288 strcmp("none", json_object_get_string(mode_picture_aspect_ratio)) != 0) {
289 printf(" (%s)", json_object_get_string(mode_picture_aspect_ratio));
290 }
291 printf("\n");
273 } 292 }
274 } 293 }
275 294