Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I3bar json #1690

Merged
merged 5 commits into from
Apr 2, 2018
Merged

I3bar json #1690

merged 5 commits into from
Apr 2, 2018

Conversation

ddevault
Copy link
Contributor

Test plan:

bar {
    status_command i3status
}

Bonus: test click events by running the bar manually with -d and it'll log each block that's clicked.

block->short_text = short_text ?
strdup(json_object_get_string(short_text)) : NULL;
if (color) {
block->color = malloc(sizeof(uint32_t));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allocating a single uint32_t?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah cause it can be NULL

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 != NULL in this case

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an accompanying "is_valid" bool would be more appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nack

swaybar/i3bar.c Outdated
json_object_object_add(event_json, "x", json_object_new_int(x));
json_object_object_add(event_json, "y", json_object_new_int(y));

char event_buf[1024];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could rid of the need for this by using dprintf instead.

dprintf(write_fd, "%s\n", json_object_to_json_string(event_json));

@emersion
Copy link
Member

emersion commented Mar 31, 2018

Crashes with my config:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00005608462d486b in render_status_block (cairo=0x56084850aaa0, config=0x5608484873e0, 
    output=0x560848490580, block=0x560848516200, x=0x7fff0b5aecd0, height=24, focused=true, edge=false)
    at ../swaybar/render.c:104
104		if (!block->full_text || !*block->full_text) {
(gdb) bt
#0  0x00005608462d486b in render_status_block (cairo=0x56084850aaa0, config=0x5608484873e0, output=0x560848490580, block=0x560848516200, x=0x7fff0b5aecd0, height=24, focused=true, edge=false)
    at ../swaybar/render.c:104
#1  0x00005608462d47cb in render_status_line_i3bar (cairo=0x56084850aaa0, config=0x5608484873e0, output=0x560848490580, status=0x560848489ca0, focused=true, x=0x7fff0b5aecd0, width=1024, height=24)
    at ../swaybar/render.c:234
#2  0x00005608462d4205 in render_status_line (cairo=0x56084850aaa0, config=0x5608484873e0, output=0x560848490580, status=0x560848489ca0, focused=true, x=0x7fff0b5aecd0, width=1024, height=24)
    at ../swaybar/render.c:254
#3  0x00005608462d37bf in render_to_cairo (cairo=0x56084850aaa0, bar=0x5608464dc780 <swaybar>, output=0x560848490580) at ../swaybar/render.c:412
#4  0x00005608462d343f in render_frame (bar=0x5608464dc780 <swaybar>, output=0x560848490580)
    at ../swaybar/render.c:437
#5  0x00005608462cf0c3 in layer_surface_configure (data=0x560848490580, surface=0x5608484a8460, serial=91, width=1024, height=24) at ../swaybar/bar.c:44
#6  0x00007f7b3e5811c8 in ffi_call_unix64 () at /usr/lib/libffi.so.6
#7  0x00007f7b3e580c2a in ffi_call () at /usr/lib/libffi.so.6
#8  0x00007f7b43582ddd in wl_closure_invoke (closure=<optimized out>, flags=<optimized out>, target=<optimized out>, opcode=0, data=<optimized out>) at src/connection.c:995
#9  0x00007f7b43581127 in dispatch_event (display=<optimized out>, queue=<optimized out>)
    at src/wayland-client.c:1434
#10 0x00007f7b43580bb9 in dispatch_queue (display=<optimized out>, queue=<optimized out>)
    at src/wayland-client.c:1580
#11 0x00007f7b43580bb9 in wl_display_dispatch_queue_pending (display=0x560848489980, queue=0x560848489a48) at src/wayland-client.c:1822
#12 0x00007f7b43580582 in wl_display_dispatch_queue (display=0x560848489980, queue=0x560848489a48)
    at src/wayland-client.c:1795
#13 0x00007f7b435802ab in wl_display_roundtrip_queue (display=0x560848489980, queue=0x560848489a48)
    at src/wayland-client.c:1245
#14 0x00005608462d34c1 in render_frame (bar=0x5608464dc780 <swaybar>, output=0x560848490580)
    at ../swaybar/render.c:449
#15 0x00005608462cfcfd in render_all_frames (bar=0x5608464dc780 <swaybar>) at ../swaybar/bar.c:243
#16 0x00005608462cfea1 in status_in (fd=5, mask=1, _bar=0x5608464dc780 <swaybar>)
    at ../swaybar/bar.c:319
#17 0x00005608462d0bae in event_loop_poll () at ../swaybar/event_loop.c:122
#18 0x00005608462cfdb1 in bar_run (bar=0x5608464dc780 <swaybar>) at ../swaybar/bar.c:330
#19 0x00005608462d3315 in main (argc=4, argv=0x7fff0b5af438) at ../swaybar/main.c:104

@ddevault
Copy link
Contributor Author

Your config?

@emersion
Copy link
Member

emersion commented Mar 31, 2018

i3status config: https://sr.ht/PHIw.config

@emersion
Copy link
Member

emersion commented Apr 2, 2018

The blocks are printed in the reverse order.

There's also this weird bug: when I put a space right after a FontAwesome icon, it prints an invalid 0x0020 codepoint. Any other character is fine.

@emersion
Copy link
Member

emersion commented Apr 2, 2018

That 0x0020 thing is actually this bug https://bugs.archlinux.org/task/56899

@ddevault
Copy link
Contributor Author

ddevault commented Apr 2, 2018

woot

@emersion
Copy link
Member

emersion commented Apr 2, 2018

Build failed

@ddevault
Copy link
Contributor Author

ddevault commented Apr 2, 2018

Build unfailed

@ddevault ddevault merged commit 4134407 into wlroots Apr 2, 2018
@ddevault ddevault deleted the i3bar-json branch April 2, 2018 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants