settings: make slave screen optional and unset by default
This commit is contained in:
@@ -407,9 +407,10 @@
|
||||
#
|
||||
##
|
||||
## Note: You can define startup slave screen
|
||||
## by choosing screen from the list above.
|
||||
## by choosing screen from the list above or
|
||||
## an empty value for no slave screen.
|
||||
##
|
||||
#startup_slave_screen = playlist
|
||||
#startup_slave_screen = ""
|
||||
#
|
||||
##
|
||||
## Default width of locked screen (in %).
|
||||
|
||||
@@ -272,7 +272,7 @@ If set to "previous", key_screen_switcher will switch between current and last u
|
||||
Screen that has to be displayed at start (playlist by default).
|
||||
.TP
|
||||
.B startup_slave_screen = SCREEN_NAME
|
||||
Slave screen that has to be displayed at start (playlist by default).
|
||||
Slave screen that has to be displayed at start (nothing by default).
|
||||
.TP
|
||||
.B locked_screen_width_part = 20-80
|
||||
If you want to lock a screen, ncmpcpp asks for % of locked screen's width to be reserved before that and provides a default value, which is the one you can set here.
|
||||
|
||||
@@ -135,10 +135,14 @@ int main(int argc, char **argv)
|
||||
if (Config.startup_screen_type != myScreen->type())
|
||||
toScreen(Config.startup_screen_type)->switchTo();
|
||||
|
||||
// lock current screen and go to the slave one
|
||||
if (Config.startup_slave_screen_type != myScreen->type())
|
||||
if (myScreen->lock())
|
||||
toScreen(Config.startup_slave_screen_type)->switchTo();
|
||||
// lock current screen and go to the slave one if applicable
|
||||
if (Config.startup_slave_screen_type)
|
||||
{
|
||||
auto slave_screen = *Config.startup_slave_screen_type;
|
||||
bool screen_locked = myScreen->lock();
|
||||
if (screen_locked && slave_screen != myScreen->type())
|
||||
toScreen(slave_screen)->switchTo();
|
||||
}
|
||||
|
||||
// local variables
|
||||
bool key_pressed = false;
|
||||
|
||||
@@ -518,10 +518,13 @@ bool Configuration::read(const std::string &config_path)
|
||||
}, defaults_to(startup_screen_type, ScreenType::Playlist)
|
||||
));
|
||||
p.add("startup_slave_screen", option_parser::worker([this](std::string v) {
|
||||
startup_slave_screen_type = stringtoStartupScreenType(v);
|
||||
if (startup_slave_screen_type == ScreenType::Unknown)
|
||||
throw std::runtime_error("unknown slave screen: " + v);
|
||||
}, defaults_to(startup_slave_screen_type, ScreenType::Playlist)
|
||||
if (!v.empty())
|
||||
{
|
||||
startup_slave_screen_type = stringtoStartupScreenType(v);
|
||||
if (startup_slave_screen_type == ScreenType::Unknown)
|
||||
throw std::runtime_error("unknown slave screen: " + v);
|
||||
}
|
||||
}, defaults_to(startup_slave_screen_type, boost::none)
|
||||
));
|
||||
p.add("locked_screen_width_part", assign_default<double>(
|
||||
locked_screen_width_part, 50.0, [](double v) {
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#define NCMPCPP_SETTINGS_H
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
@@ -187,7 +188,7 @@ struct Configuration
|
||||
size_t now_playing_suffix_length;
|
||||
|
||||
ScreenType startup_screen_type;
|
||||
ScreenType startup_slave_screen_type;
|
||||
boost::optional<ScreenType> startup_slave_screen_type;
|
||||
std::list<ScreenType> screen_sequence;
|
||||
|
||||
SortMode browser_sort_mode;
|
||||
|
||||
@@ -140,8 +140,7 @@ void initialize_status()
|
||||
# endif // ENABLE_OUTPUTS
|
||||
# ifdef ENABLE_VISUALIZER
|
||||
myVisualizer->ResetFD();
|
||||
if (myScreen == myVisualizer)
|
||||
myVisualizer->SetFD();
|
||||
myVisualizer->SetFD();
|
||||
myVisualizer->FindOutputID();
|
||||
# endif // ENABLE_VISUALIZER
|
||||
|
||||
|
||||
Reference in New Issue
Block a user