trim message
assuming a format like "%s %b" and the body is empty, the notification ends with a space, leading to not centered text in the window.
This commit is contained in:
parent
a426ab262e
commit
35cb023915
17
dunst.c
17
dunst.c
@ -102,6 +102,7 @@ void initmsg(msg_queue_t *msg);
|
|||||||
rule_t *initrule(void);
|
rule_t *initrule(void);
|
||||||
int is_idle(void);
|
int is_idle(void);
|
||||||
char *string_replace(const char *needle, const char *replacement, char *haystack);
|
char *string_replace(const char *needle, const char *replacement, char *haystack);
|
||||||
|
char *strtrim(char *str);
|
||||||
void run(void);
|
void run(void);
|
||||||
void setup(void);
|
void setup(void);
|
||||||
void show_win(void);
|
void show_win(void);
|
||||||
@ -558,6 +559,7 @@ initmsg(msg_queue_t *msg) {
|
|||||||
msg->msg = string_replace("%b", msg->body, msg->msg);
|
msg->msg = string_replace("%b", msg->body, msg->msg);
|
||||||
|
|
||||||
msg->msg = fix_markup(msg->msg);
|
msg->msg = fix_markup(msg->msg);
|
||||||
|
msg->msg = strtrim(msg->msg);
|
||||||
/* urgency > CRIT -> array out of range */
|
/* urgency > CRIT -> array out of range */
|
||||||
msg->urgency = msg->urgency > CRIT ? CRIT : msg->urgency;
|
msg->urgency = msg->urgency > CRIT ? CRIT : msg->urgency;
|
||||||
|
|
||||||
@ -641,6 +643,21 @@ string_replace(const char *needle, const char *replacement, char *haystack) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
strtrim(char *str) {
|
||||||
|
char *end;
|
||||||
|
while(isspace(*str)) str++;
|
||||||
|
|
||||||
|
end = str + strlen(str) - 1;
|
||||||
|
while(isspace(*end)) {
|
||||||
|
*end = '\0';
|
||||||
|
end--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
run(void) {
|
run(void) {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user