fix hyphen bug in music regex
[scripts.git] / i3blocks-music.pl
index 9bee37a5e2ae3deb956e30041f705dd8cc16f900..97deed4df26bd1da26d436955dd5f1cffc3410d2 100755 (executable)
@@ -27,9 +27,15 @@ my $artist = qx(playerctl $player_arg metadata artist);
 push(@metadata, $artist) if $artist;
 
 my $title = qx(playerctl $player_arg metadata title);
-$title =~ s/(?:[ ][( ][Ff]eat[. ].*)|(?:[( ][Ff]t[. ].*)//;
+$title =~ s/(\s|\s\()[Ff]([et]at[. ].*|t.*)//;
+$title =~ s/((\s(\(|\[).+(\)|\]).*)|(\s-\s.+))//;
 push(@metadata, $title) if $title;
 
+for (@metadata){
+  s/\n//;   # remove newlines
+  s/&/&/;   # fix ampersand rendering for i3bar
+}
+
 # Print stuff
 print(join(" - ", @metadata)) if @metadata;
 print("</span>");