From e9c59a67336e19e4420b2ed0c9ea5e8ec86943d3 Mon Sep 17 00:00:00 2001 From: Alexandr Date: Tue, 22 Sep 2020 15:52:02 +0300 Subject: [PATCH] Improve player MPRIS line. --- .github/workflows/PKGBUILD | 2 +- Cargo.toml | 2 +- src/utils.rs | 46 +++++++++++++++++++++++++------------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/.github/workflows/PKGBUILD b/.github/workflows/PKGBUILD index d6cd4b6..9a3b207 100644 --- a/.github/workflows/PKGBUILD +++ b/.github/workflows/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: Alexandr Bogomyakov (ultradesu) pkgname=tmux-helper -pkgver=0.3.3 +pkgver=0.3.4 pkgrel=1 pkgdesc="Tmux helper" url="https://github.com/house-of-vanity/tmux-helper.git" diff --git a/Cargo.toml b/Cargo.toml index b358712..b77bf58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tmux-helper" -version = "0.3.3" +version = "0.3.4" description = "Utility for printing system info for tmux status line." authors = ["Ultra Desu "] edition = "2018" diff --git a/src/utils.rs b/src/utils.rs index f731aae..8b83d92 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -200,21 +200,37 @@ fn format_player(track_info: TrackInfo, config: &config::Config) { } let artist_line = shorten(track_info.artist, max_len, 6); let title_line = shorten(track_info.title, max_len, 6); - println!( - "#[none]#[bold]{}{}{}#[none]{}{}{}{} {}[{}/{}] {} {}#[default]", - config.color_track_name, - title_line, - config.color_end, - separator, - config.color_track_artist, - artist_line, - config.color_end, - config.color_track_time, - track_info.position, - track_info.duration, - track_info.status, - config.color_end, - ); + if track_info.position == "00:00" || track_info.duration == "" { + println!( + "#[none]#[bold]{}{}{}#[none]{}{}{}{} {}{} {}#[default]", + config.color_track_name, + title_line, + config.color_end, + separator, + config.color_track_artist, + artist_line, + config.color_end, + config.color_track_time, + track_info.status, + config.color_end, + ); + } else { + println!( + "#[none]#[bold]{}{}{}#[none]{}{}{}{} {}[{}/{}] {} {}#[default]", + config.color_track_name, + title_line, + config.color_end, + separator, + config.color_track_artist, + artist_line, + config.color_end, + config.color_track_time, + track_info.position, + track_info.duration, + track_info.status, + config.color_end, + ); + } } pub fn mpris(config: &config::Config) {