forked from Mirrors/weechat-mpd-np
Meep?
This commit is contained in:
parent
660aa6cd7e
commit
ebf8334929
1 changed files with 7 additions and 11 deletions
18
np.pl
18
np.pl
|
@ -26,8 +26,8 @@ Define colors for messages:
|
|||
|
||||
Define format for now playing:
|
||||
/set plugins.var.perl.np.format <format>
|
||||
\%title\%, \%artist\%, \%album\%, \%date\% in addition to text
|
||||
Default: \"\%title\% by \%artist\% from \%album\% (\%date\%)\"
|
||||
\%title\%, \%artist\%, \%album\% in addition to text
|
||||
Default: \"\%title\% by \%artist\% from \%album\%\"
|
||||
|
||||
|
||||
", '', 'start', '');
|
||||
|
@ -39,17 +39,16 @@ sub start {
|
|||
my $output = "/me is now playing: ";
|
||||
|
||||
my %data = (
|
||||
"title" => `mpc -f %title% | head -n 1`,
|
||||
"artist" =>`mpc -f %artist% | head -n 1`,
|
||||
"album" => `mpc -f %album% | head -n 1`,
|
||||
"date" => `mpc -f %date% | head -n 1`
|
||||
"title" => `playerctl metadata title`,
|
||||
"artist" =>`playerctl metadata artist`,
|
||||
"album" => `playerctl metadata album`,
|
||||
);
|
||||
chomp %data;
|
||||
|
||||
%data = addColor(\%data) unless weechat::config_get_plugin("use_color") eq "off";
|
||||
|
||||
# Todo: Add ability to change foramt
|
||||
$output .= $data{"title"}." by ".$data{"artist"}." from ".$data{"album"}." (".$data{"date"}.")";
|
||||
$output .= $data{"title"}." by ".$data{"artist"}." from ".$data{"album"}."";
|
||||
|
||||
weechat::command(weechat::current_buffer, $output)
|
||||
}
|
||||
|
@ -65,19 +64,16 @@ sub addColor {
|
|||
weechat::config_set_plugin("color.title", "lightmagenta") if weechat::config_get_plugin("color.title") eq "";
|
||||
weechat::config_set_plugin("color.artist", "lightblue") if weechat::config_get_plugin("color.artist") eq "";
|
||||
weechat::config_set_plugin("color.album", "lightgreen") if weechat::config_get_plugin("color.album") eq "";
|
||||
weechat::config_set_plugin("color.date", "yellow") if weechat::config_get_plugin("color.date") eq "";
|
||||
|
||||
# Convert to raw color codes
|
||||
my $color_title = "\cC" . $color_table{(weechat::config_get_plugin("color.title"))};
|
||||
my $color_artist = "\cC" . $color_table{(weechat::config_get_plugin("color.artist"))};
|
||||
my $color_album = "\cC" . $color_table{(weechat::config_get_plugin("color.album"))};
|
||||
my $color_date = "\cC" . $color_table{(weechat::config_get_plugin("color.date"))};
|
||||
my $reset_color = "\cC00";
|
||||
|
||||
return (
|
||||
"title" => $color_title.$_[0]{"title"}.$reset_color,
|
||||
"artist" => $color_artist.$_[0]{"artist"}.$reset_color,
|
||||
"album" => $color_album.$_[0]{"album"}.$reset_color,
|
||||
"date" => $color_date.$_[0]{"date"}.$reset_color
|
||||
"album" => $color_album.$_[0]{"album"}.$reset_color
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue