diff options
| author | Přemysl Janouch <p.janouch@gmail.com> | 2017-01-03 17:53:57 +0100 | 
|---|---|---|
| committer | Přemysl Janouch <p.janouch@gmail.com> | 2017-01-03 17:53:57 +0100 | 
| commit | 662945360e5514c67788e7b12bdae12a40fe39c7 (patch) | |
| tree | 01ff56f38b5b166e53dc2a49ea2824dc43d68e62 | |
| parent | 7c16d997581cf1d2e105da210b7619c79ded3b3f (diff) | |
| download | desktop-tools-662945360e5514c67788e7b12bdae12a40fe39c7.tar.gz desktop-tools-662945360e5514c67788e7b12bdae12a40fe39c7.tar.xz desktop-tools-662945360e5514c67788e7b12bdae12a40fe39c7.zip | |
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.
| -rw-r--r-- | wmstatus.c | 28 | 
1 files changed, 20 insertions, 8 deletions
| @@ -1015,6 +1015,11 @@ backend_dwm_flush (struct backend *b)  	char *str = join_str_vector_ex (&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);  	XStoreName (self->dpy, DefaultRootWindow (self->dpy), str);  	XSync (self->dpy, False); @@ -1089,14 +1094,21 @@ backend_i3_flush (struct backend *b)  			continue;  		fputs ("{\"full_text\":\"", stdout); +		bool bold = false;  		for (const char *p = str; *p; p++) -			if (*p == '"') -				fputs ("\\\"", stdout); -			else if (*p == '\\') -				fputs ("\\\\", stdout); +			if      (*p == '"')  fputs ("\\\"",  stdout); +			else if (*p == '\\') fputs ("\\\\",  stdout); +			else if (*p == '<')  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  				fputc (*p, stdout); -		fputs ("\",\"separator\":false}", stdout); +		if (bold) +			fputs ("</span>", stdout); +		fputs ("\",\"separator\":false,\"markup\":\"pango\"}", stdout);  	}  	fputs ("]\n", stdout); @@ -1551,11 +1563,11 @@ mpd_on_info_response (const struct mpd_response *response,  	if ((value = str_map_find (&map, "title"))  	 || (value = str_map_find (&map, "name"))  	 || (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"))) -		str_append_printf (&s, " by \"%s\"", value); +		str_append_printf (&s, " by \001%s\001", value);  	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);  	ctx->mpd_song = str_steal (&s); | 
