diff options
author | Mustafa Salih <37256744+MustafaSalih1993@users.noreply.github.com> | 2021-05-09 22:14:29 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-09 22:14:29 +0300 |
commit | c2a1be9cd35c044a63fcf546ffd0a41fff5e9044 (patch) | |
tree | 1370be88426ebce42afa2ea06f0f55e1dd9e664f /src/utils/spotify.rs | |
parent | 727841572fe4d15d133d9943afe04fcfdc33012c (diff) |
added limits 30 chars foreach the title and artist in spotify block, closes: #53 (#54)
Diffstat (limited to 'src/utils/spotify.rs')
-rw-r--r-- | src/utils/spotify.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/utils/spotify.rs b/src/utils/spotify.rs index 9e5c5da..c48471d 100644 --- a/src/utils/spotify.rs +++ b/src/utils/spotify.rs @@ -3,8 +3,8 @@ use crate::types::ThreadsData; use dbus::blocking::stdintf::org_freedesktop_dbus::Properties; use dbus::{arg, blocking::Connection}; use std::time::Duration; -// getting spotify current artist and title. +// getting spotify current artist and title. pub fn get_spotify() -> ThreadsData { let empty_data = ThreadsData::Spotify(String::from("")); let conn = match Connection::new_session() { @@ -27,13 +27,25 @@ pub fn get_spotify() -> ThreadsData { let artist: Option<&Vec<String>> = arg::prop_cast(&metadata, "xesam:artist"); let title = match title { - Some(title) => title, + Some(title) => { + if title.len() > 30 { + &title[..30] + } else { + title.as_str() + } + } _ => "", }; let artist = match artist { Some(artist_vec) => match artist_vec.first() { - Some(name) => name, + Some(name) => { + if name.len() > 30 { + &name[..30] + } else { + name.as_str() + } + } _ => "", }, None => "", |