wmstatus: use bold formatting in i3
Instead of that fuck ugly quoting. Keep using quoting in dwm as I still may want to decide to run it.
This commit is contained in:
parent
7c16d99758
commit
662945360e
28
wmstatus.c
28
wmstatus.c
|
@ -1015,6 +1015,11 @@ backend_dwm_flush (struct backend *b)
|
||||||
char *str = join_str_vector_ex (&self->items, " ");
|
char *str = join_str_vector_ex (&self->items, " ");
|
||||||
str_vector_reset (&self->items);
|
str_vector_reset (&self->items);
|
||||||
|
|
||||||
|
// We don't have formatting, so let's at least quote those spans
|
||||||
|
for (char *p = str; *p; p++)
|
||||||
|
if (*p == '\001')
|
||||||
|
*p = '"';
|
||||||
|
|
||||||
print_debug ("setting status to: %s", str);
|
print_debug ("setting status to: %s", str);
|
||||||
XStoreName (self->dpy, DefaultRootWindow (self->dpy), str);
|
XStoreName (self->dpy, DefaultRootWindow (self->dpy), str);
|
||||||
XSync (self->dpy, False);
|
XSync (self->dpy, False);
|
||||||
|
@ -1089,14 +1094,21 @@ backend_i3_flush (struct backend *b)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
fputs ("{\"full_text\":\"", stdout);
|
fputs ("{\"full_text\":\"", stdout);
|
||||||
|
bool bold = false;
|
||||||
for (const char *p = str; *p; p++)
|
for (const char *p = str; *p; p++)
|
||||||
if (*p == '"')
|
if (*p == '"') fputs ("\\\"", stdout);
|
||||||
fputs ("\\\"", stdout);
|
else if (*p == '\\') fputs ("\\\\", stdout);
|
||||||
else if (*p == '\\')
|
else if (*p == '<') fputs ("<", stdout);
|
||||||
fputs ("\\\\", stdout);
|
else if (*p == '>') fputs (">", stdout);
|
||||||
|
else if (*p == '&') fputs ("&", stdout);
|
||||||
|
else if (*p == '\001')
|
||||||
|
fputs ((bold = !bold)
|
||||||
|
? "<span weight='bold'>" : "</span>", stdout);
|
||||||
else
|
else
|
||||||
fputc (*p, stdout);
|
fputc (*p, stdout);
|
||||||
fputs ("\",\"separator\":false}", stdout);
|
if (bold)
|
||||||
|
fputs ("</span>", stdout);
|
||||||
|
fputs ("\",\"separator\":false,\"markup\":\"pango\"}", stdout);
|
||||||
}
|
}
|
||||||
fputs ("]\n", stdout);
|
fputs ("]\n", stdout);
|
||||||
|
|
||||||
|
@ -1551,11 +1563,11 @@ mpd_on_info_response (const struct mpd_response *response,
|
||||||
if ((value = str_map_find (&map, "title"))
|
if ((value = str_map_find (&map, "title"))
|
||||||
|| (value = str_map_find (&map, "name"))
|
|| (value = str_map_find (&map, "name"))
|
||||||
|| (value = str_map_find (&map, "file")))
|
|| (value = str_map_find (&map, "file")))
|
||||||
str_append_printf (&s, "\"%s\"", value);
|
str_append_printf (&s, "\001%s\001", value);
|
||||||
if ((value = str_map_find (&map, "artist")))
|
if ((value = str_map_find (&map, "artist")))
|
||||||
str_append_printf (&s, " by \"%s\"", value);
|
str_append_printf (&s, " by \001%s\001", value);
|
||||||
if ((value = str_map_find (&map, "album")))
|
if ((value = str_map_find (&map, "album")))
|
||||||
str_append_printf (&s, " from \"%s\"", value);
|
str_append_printf (&s, " from \001%s\001", value);
|
||||||
|
|
||||||
free (ctx->mpd_song);
|
free (ctx->mpd_song);
|
||||||
ctx->mpd_song = str_steal (&s);
|
ctx->mpd_song = str_steal (&s);
|
||||||
|
|
Loading…
Reference in New Issue