From 438b866993c900ad4c53b7cdf1f30b4cae9e52c0 Mon Sep 17 00:00:00 2001 From: Marc Jessome Date: Sun, 10 Jul 2011 15:21:34 -0700 Subject: [PATCH] Add -s/--screen option to launch to a specific screen. --- doc/ncmpcpp.1 | 3 +++ src/helpers.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index 20e0be1f..f65e539d 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -24,6 +24,9 @@ Display version information. .B \-\-now\-playing Display now playing song [{{(%l) }{{%a - }%t}}|{%f}}] .TP +.B \-\-screen +Specify the startup screen. +.TP .B play Start playing and exit. .TP diff --git a/src/helpers.cpp b/src/helpers.cpp index 1cc80926..6e7977d3 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -29,6 +29,11 @@ #include "playlist.h" #include "status.h" #include "tag_editor.h" +#include "help.h" +#include "playlist_editor.h" +#include "browser.h" +#include "media_library.h" +#include "search_engine.h" bool ConnectToMPD() { @@ -120,6 +125,7 @@ void ParseArgv(int argc, char **argv) << " -?, --help show this help message\n" << " -v, --version display version information\n" << " --now-playing display now playing song [" << now_playing_format << "]\n" + << " --screen specify the startup screen\n" << "\n" << " play start playing\n" << " pause pause the currently playing song\n" @@ -135,7 +141,47 @@ void ParseArgv(int argc, char **argv) if (!ConnectToMPD()) exit(0); - if (!strcmp(argv[i], "--now-playing")) + if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--screen")) + { + i++; + if (i == argc) { + std::cout << "ncmpcpp: no screen specified" << std::endl; + exit(0); + } + if (!strcmp(argv[i], "help")) + Config.startup_screen = myHelp; + else if (!strcmp(argv[i], "playlist")) + Config.startup_screen = myPlaylist; + else if (!strcmp(argv[i], "browser")) + Config.startup_screen = myBrowser; + else if (!strcmp(argv[i], "search")) + Config.startup_screen = mySearcher; + else if (!strcmp(argv[i], "media-library") || !strcmp(argv[i], "library")) + Config.startup_screen = myLibrary; + else if (!strcmp(argv[i], "playlist-editor")) + Config.startup_screen = myPlaylistEditor; +# ifdef HAVE_TAGLIB_H + else if (!strcmp(argv[i], "tag-editor")) + Config.startup_screen = myTagEditor; +# endif // HAVE_TAGLIB_H +# ifdef ENABLE_OUTPUTS + else if (!strcmp(argv[i], "outputs")) + Config.startup_screen = myOutputs; +# endif // ENABLE_OUTPUTS +# ifdef ENABLE_VISUALIZER + else if (!strcmp(argv[i], "visualizer")) + Config.startup_screen = myVisualizer; +# endif // ENABLE_VISUALIZER +# ifdef ENABLE_CLOCK + else if (!strcmp(argv[i], "clock")) + Config.startup_screen = myClock; +# endif // ENABLE_CLOCK + else { + std::cout << "ncmpcpp: invalid screen: " << argv[i] << std::endl; + exit(0); + } + } + else if (!strcmp(argv[i], "--now-playing")) { Mpd.UpdateStatus(); if (!Mpd.GetErrorMessage().empty())