diff --git a/doc/config b/doc/config index 791f2084..69eca525 100644 --- a/doc/config +++ b/doc/config @@ -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 ##### diff --git a/src/actions.cpp b/src/actions.cpp index eaf75feb..5686a5f2 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -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; @@ -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(wFooter->prompt()); + number = Config.random_default_number; + } else { + { + Statusbar::ScopedLock slock; + Statusbar::put() << "Number of random " << tag_type_str << "s: "; + number = fromString(wFooter->prompt()); + } } if (number > 0) { diff --git a/src/settings.cpp b/src/settings.cpp index ddde73e0..713d3825 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -229,6 +229,8 @@ bool Configuration::read(const std::vector &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"); diff --git a/src/settings.h b/src/settings.h index e9a8af08..0f05c4f6 100644 --- a/src/settings.h +++ b/src/settings.h @@ -221,6 +221,8 @@ struct Configuration boost::optional startup_slave_screen_type; std::vector screen_sequence; + std::string random_default_type; + unsigned random_default_number; std::string random_exclude_pattern; SortMode browser_sort_mode;