From a2948bf94215a5cee53b567aee3a1295ae3bb53c Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 17 Dec 2017 18:13:26 +0200 Subject: [PATCH] print available layouts from command line --- app/importer.cpp | 16 ++++++++++++++++ app/importer.h | 1 + app/main.cpp | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/app/importer.cpp b/app/importer.cpp index ab4be2ba9..ec7c790c6 100644 --- a/app/importer.cpp +++ b/app/importer.cpp @@ -450,6 +450,22 @@ bool Importer::importHelper(QString fileName) return true; } +QStringList Importer::availableLayouts() +{ + QDir layoutDir(QDir::homePath() + "/.config/latte"); + QStringList filter; + filter.append(QString("*.layout.latte")); + QStringList files = layoutDir.entryList(filter, QDir::Files | QDir::NoSymLinks); + + QStringList layoutNames; + + foreach (auto file, files) { + layoutNames.append(LayoutSettings::layoutName(file)); + } + + return layoutNames; +} + QString Importer::nameOfConfigFile(const QString &fileName) { diff --git a/app/importer.h b/app/importer.h index 7d97a1adc..fe0b5fad6 100644 --- a/app/importer.h +++ b/app/importer.h @@ -69,6 +69,7 @@ public: static bool importHelper(QString fileName); static QString nameOfConfigFile(const QString &fileName); static QString uniqueLayoutName(QString name); + static QStringList availableLayouts(); private: //! check if this layout exists already in the latte directory diff --git a/app/main.cpp b/app/main.cpp index 0096c5b33..0645960c6 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -83,6 +83,7 @@ int main(int argc, char **argv) , {{"d", "debug"}, i18nc("command line", "Show the debugging messages on stdout.")} , {"graphics", i18nc("command line", "Draw boxes around of the applets.")} , {"with-window", i18nc("command line", "Open a window with much debug information.")} + , {"layouts", i18nc("command line", "Print available layouts")} , {"default-layout", i18nc("command line", "Import and load default layout.")} , {"import", i18nc("command line", "Import full configuration."), i18nc("command line: import", "file_name")} , {"mask", i18nc("command line" , "Show messages of debugging for the mask (Only useful to devs).")} @@ -92,6 +93,23 @@ int main(int argc, char **argv) parser.process(app); + if (parser.isSet(QStringLiteral("layouts"))) { + QStringList layouts = Latte::Importer::availableLayouts(); + + if (layouts.count() > 0) { + qInfo() << i18n("Available layouts that can be used to start Latte:"); + + foreach (auto layout, layouts) { + qInfo() << " " << layout; + } + } else { + qInfo() << i18n("There are no available layouts, during startup Default will be used."); + } + + qGuiApp->exit(); + return 0; + } + QLockFile lockFile {QDir::tempPath() + "/latte-dock.lock"}; int timeout {100};