Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions doc/config
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,17 @@
#
#mpd_crossfade_time = 5
#
# Exclude pattern for random song action
# http://www.boost.org/doc/libs/1_46_1/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html
## Random default type add (*s*ongs/*a*rtists/album*A*rtists/al*b*ums)
##
#random_default_type = "s"
#
## Number of random songs/artists/albumArtists/albums to add
##
#random_default_number = 20
#
## Exclude pattern for random song action
## http://www.boost.org/doc/libs/1_46_1/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html
##
#random_exclude_pattern = "^(temp|midi_songs).*"
#
##### music visualizer #####
Expand Down
34 changes: 22 additions & 12 deletions src/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2219,15 +2219,20 @@ void AddRandomItems::run()
{
using Global::wFooter;
char rnd_type = 0;
if (!Config.random_default_type.empty())
{
Statusbar::ScopedLock slock;
Statusbar::put() << "Add random? "
<< "[" << NC::Format::Bold << 's' << NC::Format::NoBold << "ongs"
<< "/" << NC::Format::Bold << 'a' << NC::Format::NoBold << "rtists"
<< "/" << "album" << NC::Format::Bold << 'A' << NC::Format::NoBold << "rtists"
<< "/" << "al" << NC::Format::Bold << 'b' << NC::Format::NoBold << "ums"
<< "] ";
rnd_type = Statusbar::Helpers::promptReturnOneOf({'s', 'a', 'A', 'b'});
rnd_type = Config.random_default_type[0];
} else {
{
Statusbar::ScopedLock slock;
Statusbar::put() << "Add random? "
<< "[" << NC::Format::Bold << 's' << NC::Format::NoBold << "ongs"
<< "/" << NC::Format::Bold << 'a' << NC::Format::NoBold << "rtists"
<< "/" << "album" << NC::Format::Bold << 'A' << NC::Format::NoBold << "rtists"
<< "/" << "al" << NC::Format::Bold << 'b' << NC::Format::NoBold << "ums"
<< "] ";
rnd_type = Statusbar::Helpers::promptReturnOneOf({'s', 'a', 'A', 'b'});
}
}

mpd_tag_type tag_type = MPD_TAG_ARTIST;
Expand All @@ -2240,11 +2245,16 @@ void AddRandomItems::run()
else
tag_type_str = "song";

unsigned number;
unsigned number = 0;
if (Config.random_default_number > 0)
{
Statusbar::ScopedLock slock;
Statusbar::put() << "Number of random " << tag_type_str << "s: ";
number = fromString<unsigned>(wFooter->prompt());
number = Config.random_default_number;
} else {
{
Statusbar::ScopedLock slock;
Statusbar::put() << "Number of random " << tag_type_str << "s: ";
number = fromString<unsigned>(wFooter->prompt());
}
}
if (number > 0)
{
Expand Down
2 changes: 2 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno
p.add("mpd_music_dir", &mpd_music_dir, "~/music", adjust_directory);
p.add("mpd_connection_timeout", &mpd_connection_timeout, "5");
p.add("mpd_crossfade_time", &crossfade_time, "5");
p.add("random_default_type", &random_default_type, "");
p.add("random_default_number", &random_default_number, "");
p.add("random_exclude_pattern", &random_exclude_pattern, "");
p.add("visualizer_data_source", &visualizer_data_source, "/tmp/mpd.fifo", adjust_path);
p.add("visualizer_output_name", &visualizer_output_name, "Visualizer feed");
Expand Down
2 changes: 2 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ struct Configuration
boost::optional<ScreenType> startup_slave_screen_type;
std::vector<ScreenType> screen_sequence;

std::string random_default_type;
unsigned random_default_number;
std::string random_exclude_pattern;
SortMode browser_sort_mode;

Expand Down