mpris: don't put ellipsis after whitespace

pull/2011/head
chayleaf 2023-02-21 03:38:26 +07:00
parent e5524d5059
commit 0cfd1c7094
3 changed files with 19 additions and 18 deletions

View File

@ -50,30 +50,30 @@ The *mpris* module displays currently playing media via libplayerctl.
*artist-len*: ++ *artist-len*: ++
typeof: integer ++ typeof: integer ++
Maximum length of the Artist tag (Wide/Fullwidth Unicode characters Maximum length of the Artist tag (Wide/Fullwidth Unicode characters
count as two). count as two). Set to zero to hide the artist in `{dynamic}` tag.
*album-len*: ++ *album-len*: ++
typeof: integer ++ typeof: integer ++
Maximum length of the Album tag (Wide/Fullwidth Unicode characters count Maximum length of the Album tag (Wide/Fullwidth Unicode characters count
as two). as two). Set to zero to hide the album in `{dynamic}` tag.
*title-len*: ++ *title-len*: ++
typeof: integer ++ typeof: integer ++
Maximum length of the Title tag (Wide/Fullwidth Unicode characters count Maximum length of the Title tag (Wide/Fullwidth Unicode characters count
as two). as two). Set to zero to hide the title in `{dynamic}` tag.
*dynamic-len*: ++ *dynamic-len*: ++
typeof: integer ++ typeof: integer ++
Maximum length of the Dynamic tag (Wide/Fullwidth Unicode characters Maximum length of the Dynamic tag (Wide/Fullwidth Unicode characters ++
count as two). The dynamic tag will not truncate any tags beyond their count as two). The dynamic tag will not truncate any tags beyond their ++
set length limits, instead, it will attempt to fit as much of the set length limits, instead, it will attempt to fit as much of the ++
available tags as possible. It is recommended you set title-len to available tags as possible. It is recommended you set title-len to ++
something less than or equal to this value, so the title will always be something less than or equal to this value, so the title will always be ++
displayed. displayed.
*dynamic-priority* ++ *dynamic-priority*: ++
typeof: []string ++ typeof: []string ++
default: ["title", "length", "position", "artist", "album"] default: ["title", "length", "position", "artist", "album"] ++
Priority of the tags when truncating the Dynamic tag (absence in this Priority of the tags when truncating the Dynamic tag (absence in this
list means force inclusion). list means force inclusion).
@ -108,7 +108,8 @@ The *mpris* module displays currently playing media via libplayerctl.
*align*: ++ *align*: ++
typeof: float ++ typeof: float ++
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. The alignment of the text, where 0 is left-aligned and 1 is right-aligned.
If the module is rotated, it will follow the flow of the text.
*on-click*: ++ *on-click*: ++
typeof: string ++ typeof: string ++
@ -126,11 +127,11 @@ The *mpris* module displays currently playing media via libplayerctl.
Overwrite default action toggles. Overwrite default action toggles.
*player-icons*: ++ *player-icons*: ++
typeof: map[string]string typeof: map[string]string ++
Allows setting _{player-icon}_ based on player-name property. Allows setting _{player-icon}_ based on player-name property.
*status-icons*: ++ *status-icons*: ++
typeof: map[string]string typeof: map[string]string ++
Allows setting _{status-icon}_ based on player status (playing, paused, Allows setting _{status-icon}_ based on player status (playing, paused,
stopped). stopped).

View File

@ -32,7 +32,6 @@ Mpris::Mpris(const std::string& id, const Json::Value& config)
player_("playerctld"), player_("playerctld"),
manager(), manager(),
player() { player() {
if (config_["format-playing"].isString()) { if (config_["format-playing"].isString()) {
format_playing_ = config_["format-playing"].asString(); format_playing_ = config_["format-playing"].asString();
} }
@ -197,7 +196,8 @@ size_t utf8_truncate(std::string& str, size_t width = std::string::npos) {
} }
data = g_utf8_find_next_char(data, end); data = g_utf8_find_next_char(data, end);
if (width != std::string::npos && total_width <= width) trunc_end = data; if (width != std::string::npos && total_width <= width && !g_unichar_isspace(c))
trunc_end = data;
} }
if (trunc_end) str.resize(trunc_end - str.data()); if (trunc_end) str.resize(trunc_end - str.data());