commit d376ed774596b7f104d31a066cf2289bc66a3f4d Author: Tim Biermann <tbier@posteo.de> Date: Sat Feb 29 23:58:17 2020 +0000 i3status-rust: cherry pick commit to fix music block diff --git a/i3status-rust/561.patch b/i3status-rust/561.patch new file mode 100644 index 000000000..81bdbe514 --- /dev/null +++ b/i3status-rust/561.patch @@ -0,0 +1,61 @@ +From c644cb4e61f5519bfb50e45efed4db9e765ed425 Mon Sep 17 00:00:00 2001 +From: Riey <creeper844@gmail.com> +Date: Mon, 10 Feb 2020 14:38:48 +0900 +Subject: [PATCH] Fix artist parsing from metadata + +--- + src/blocks/music.rs | 34 +++++++++++++++------------------- + 1 file changed, 15 insertions(+), 19 deletions(-) + +diff --git a/src/blocks/music.rs b/src/blocks/music.rs +index 1be56517..3c951d2b 100644 +--- a/src/blocks/music.rs ++++ b/src/blocks/music.rs +@@ -318,6 +318,20 @@ impl Block for Music { + } + } + ++fn extract_artist_from_value(value: &dyn arg::RefArg) -> Result<&str> { ++ if let Some(artist) = value.as_str() { ++ Ok(artist) ++ } else { ++ extract_artist_from_value( ++ value ++ .as_iter() ++ .block_error("music", "failed to extract artist")? ++ .next() ++ .block_error("music", "failed to extract artist")?, ++ ) ++ } ++} ++ + fn extract_from_metadata(metadata: &Box<dyn arg::RefArg>) -> Result<(String, String)> { + let mut title = String::new(); + let mut artist = String::new(); +@@ -334,25 +348,7 @@ fn extract_from_metadata(metadata: &Box<dyn arg::RefArg>) -> Result<(String, Str + .as_str() + .block_error("music", "failed to extract metadata")? + { +- "xesam:artist" => { +- artist = String::from( +- value +- .as_iter() +- .block_error("music", "failed to extract metadata")? +- .nth(0) +- .block_error("music", "failed to extract metadata")? +- .as_iter() +- .block_error("music", "failed to extract metadata")? +- .nth(0) +- .block_error("music", "failed to extract metadata")? +- .as_iter() +- .block_error("music", "failed to extract metadata")? +- .nth(0) +- .block_error("music", "failed to extract metadata")? +- .as_str() +- .block_error("music", "failed to extract metadata")?, +- ) +- } ++ "xesam:artist" => artist = String::from(extract_artist_from_value(value)?), + "xesam:title" => { + title = String::from( + value diff --git a/i3status-rust/Pkgfile b/i3status-rust/Pkgfile index 1a2115a12..4fd54ff53 100644 --- a/i3status-rust/Pkgfile +++ b/i3status-rust/Pkgfile @@ -1,18 +1,20 @@ # Description: i3status replacement written in rust # URL: https://github.com/greshake/i3status-rust # Maintainer: Tim Biermann, tbier at posteo dot de -# Depends on: dbus flac libogg libsndfile libvorbis pulseaudio rust +# Depends on: dbus pulseaudio rust name=i3status-rust version=0.13.1 -release=1 -source=(https://github.com/greshake/i3status-rust/archive/v$version/$name-$version.t...) +release=2 +source=(https://github.com/greshake/i3status-rust/archive/v$version/$name-$version.t... + 561.patch) build() { cd $name-$version prt-get isinst sccache && export RUSTC_WRAPPER=/usr/bin/sccache mkdir "$PKGMK_SOURCE_DIR/rust" || true export CARGO_HOME="$PKGMK_SOURCE_DIR/rust" + patch -Np1 -i $SRC/561.patch cargo fetch cargo build --release install -Dt $PKG/usr/bin target/release/i3status-rs