mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
hyperiond: add ability to export default config and effects (#244)
* - embed default config - add possibility to export effects and embeded default config to filesystem * do some code style
This commit is contained in:
parent
eeb9b0f7da
commit
858125510e
@ -1,6 +1,5 @@
|
|||||||
$(document).ready( function() {
|
$(document).ready( function() {
|
||||||
$("#main-nav").hide();
|
$("#main-nav").hide();
|
||||||
$("#page-content").hide();
|
|
||||||
$("#loading_overlay").addClass("overlay");
|
$("#loading_overlay").addClass("overlay");
|
||||||
loadContentTo("#container_connection_lost","connection_lost");
|
loadContentTo("#container_connection_lost","connection_lost");
|
||||||
initWebSocket();
|
initWebSocket();
|
||||||
@ -62,7 +61,6 @@ $(document).ready( function() {
|
|||||||
});
|
});
|
||||||
$("#loading_overlay").removeClass("overlay");
|
$("#loading_overlay").removeClass("overlay");
|
||||||
$("#main-nav").show('slide', {direction: 'left'}, 1000);
|
$("#main-nav").show('slide', {direction: 'left'}, 1000);
|
||||||
$("#page-content").show('slide', {direction: 'down'}, 2000);
|
|
||||||
|
|
||||||
}); // end cmd-serverinfo
|
}); // end cmd-serverinfo
|
||||||
|
|
||||||
|
@ -16,8 +16,6 @@ echo create $outfile
|
|||||||
tar --create --verbose --gzip --absolute-names --show-transformed-names \
|
tar --create --verbose --gzip --absolute-names --show-transformed-names \
|
||||||
--file "$outfile" \
|
--file "$outfile" \
|
||||||
--transform "s:$builddir/bin/:hyperion/bin/:" \
|
--transform "s:$builddir/bin/:hyperion/bin/:" \
|
||||||
--transform "s:$repodir/effects/:hyperion/effects/:" \
|
|
||||||
--transform "s:$repodir/config/:hyperion/config/:" \
|
|
||||||
--transform "s:$repodir/bin/hyperion.init.sh:hyperion/init.d/hyperion.init.sh:" \
|
--transform "s:$repodir/bin/hyperion.init.sh:hyperion/init.d/hyperion.init.sh:" \
|
||||||
--transform "s://:/:g" \
|
--transform "s://:/:g" \
|
||||||
"$builddir/bin/hyperiond" \
|
"$builddir/bin/hyperiond" \
|
||||||
@ -25,6 +23,4 @@ tar --create --verbose --gzip --absolute-names --show-transformed-names \
|
|||||||
"$builddir/bin/hyperion-v4l2" \
|
"$builddir/bin/hyperion-v4l2" \
|
||||||
"$builddir/bin/gpio2spi" \
|
"$builddir/bin/gpio2spi" \
|
||||||
"$builddir/bin/dispmanx2png" \
|
"$builddir/bin/dispmanx2png" \
|
||||||
"$repodir/effects/"* \
|
|
||||||
"$repodir/bin/hyperion.init.sh" \
|
"$repodir/bin/hyperion.init.sh" \
|
||||||
"$repodir/config/hyperion.config.json"
|
|
||||||
|
@ -20,8 +20,12 @@ install_file()
|
|||||||
echo "--- hyperion ambient light postinstall ---"
|
echo "--- hyperion ambient light postinstall ---"
|
||||||
echo "- install configuration template"
|
echo "- install configuration template"
|
||||||
mkdir -p /etc/hyperion
|
mkdir -p /etc/hyperion
|
||||||
install_file /usr/share/hyperion/config/hyperion.config.json.default /etc/hyperion/hyperion.config.json
|
|
||||||
|
|
||||||
|
if [ ! -e "/etc/hyperion/hyperion.config.json" ]
|
||||||
|
then
|
||||||
|
echo "install default config to /etc/hyperion"
|
||||||
|
/usr/bin/hyperiond --export-config /etc/hyperion/hyperion.config.json
|
||||||
|
fi
|
||||||
|
|
||||||
HYPERION_RUNNING=false
|
HYPERION_RUNNING=false
|
||||||
pgrep hyperiond > /dev/null 2>&1 && HYPERION_RUNNING=true
|
pgrep hyperiond > /dev/null 2>&1 && HYPERION_RUNNING=true
|
||||||
|
@ -42,6 +42,7 @@ public:
|
|||||||
QString value(Parser &parser);
|
QString value(Parser &parser);
|
||||||
std::string getStdString(Parser &parser);
|
std::string getStdString(Parser &parser);
|
||||||
std::wstring getStdWString(Parser &parser);
|
std::wstring getStdWString(Parser &parser);
|
||||||
|
const char* getCString(Parser &parser);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef HYPERION_COMMANDLINEPARSER_H
|
#pragma once
|
||||||
#define HYPERION_COMMANDLINEPARSER_H
|
|
||||||
|
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
@ -71,50 +70,75 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Parser(QString description=QString())
|
Parser(QString description=QString())
|
||||||
{if(description.size())setApplicationDescription(description);};
|
{
|
||||||
|
if(description.size())setApplicationDescription(description);
|
||||||
|
};
|
||||||
|
|
||||||
QCommandLineOption addHelpOption()
|
QCommandLineOption addHelpOption()
|
||||||
{ return _parser.addHelpOption(); }
|
{
|
||||||
|
return _parser.addHelpOption();
|
||||||
|
};
|
||||||
|
|
||||||
bool addOption(Option &option);
|
bool addOption(Option &option);
|
||||||
bool addOption(Option *option);
|
bool addOption(Option *option);
|
||||||
void addPositionalArgument(const QString &name, const QString &description, const QString &syntax = QString())
|
void addPositionalArgument(const QString &name, const QString &description, const QString &syntax = QString())
|
||||||
{ _parser.addPositionalArgument(name, description, syntax); }
|
{
|
||||||
|
_parser.addPositionalArgument(name, description, syntax);
|
||||||
|
};
|
||||||
|
|
||||||
QCommandLineOption addVersionOption()
|
QCommandLineOption addVersionOption()
|
||||||
{ return _parser.addVersionOption(); }
|
{
|
||||||
|
return _parser.addVersionOption();
|
||||||
|
};
|
||||||
|
|
||||||
QString applicationDescription() const
|
QString applicationDescription() const
|
||||||
{ return _parser.applicationDescription(); }
|
{ return _parser.applicationDescription(); }
|
||||||
|
|
||||||
void clearPositionalArguments()
|
void clearPositionalArguments()
|
||||||
{ _parser.clearPositionalArguments(); }
|
{ _parser.clearPositionalArguments(); }
|
||||||
|
|
||||||
QString helpText() const
|
QString helpText() const
|
||||||
{ return _parser.helpText(); }
|
{ return _parser.helpText(); }
|
||||||
|
|
||||||
bool isSet(const QString &name) const
|
bool isSet(const QString &name) const
|
||||||
{ return _parser.isSet(name); }
|
{ return _parser.isSet(name); }
|
||||||
|
|
||||||
bool isSet(const Option &option) const
|
bool isSet(const Option &option) const
|
||||||
{ return _parser.isSet(option); }
|
{ return _parser.isSet(option); }
|
||||||
|
|
||||||
bool isSet(const Option *option) const
|
bool isSet(const Option *option) const
|
||||||
{ return _parser.isSet(*option); }
|
{ return _parser.isSet(*option); }
|
||||||
|
|
||||||
QStringList optionNames() const
|
QStringList optionNames() const
|
||||||
{ return _parser.optionNames(); }
|
{ return _parser.optionNames(); }
|
||||||
|
|
||||||
QStringList positionalArguments() const
|
QStringList positionalArguments() const
|
||||||
{ return _parser.positionalArguments(); }
|
{ return _parser.positionalArguments(); }
|
||||||
|
|
||||||
void setApplicationDescription(const QString &description)
|
void setApplicationDescription(const QString &description)
|
||||||
{ _parser.setApplicationDescription(description); }
|
{ _parser.setApplicationDescription(description); }
|
||||||
|
|
||||||
void setSingleDashWordOptionMode(QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode)
|
void setSingleDashWordOptionMode(QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode)
|
||||||
{ _parser.setSingleDashWordOptionMode(singleDashWordOptionMode); }
|
{ _parser.setSingleDashWordOptionMode(singleDashWordOptionMode); }
|
||||||
|
|
||||||
void showHelp(int exitCode = 0)
|
void showHelp(int exitCode = 0)
|
||||||
{ _parser.showHelp(exitCode); }
|
{ _parser.showHelp(exitCode); }
|
||||||
|
|
||||||
QStringList unknownOptionNames() const
|
QStringList unknownOptionNames() const
|
||||||
{ return _parser.unknownOptionNames(); }
|
{ return _parser.unknownOptionNames(); }
|
||||||
|
|
||||||
QString value(const QString &optionName) const
|
QString value(const QString &optionName) const
|
||||||
{ return _parser.value(optionName); }
|
{ return _parser.value(optionName); }
|
||||||
|
|
||||||
QString value(const Option &option) const
|
QString value(const Option &option) const
|
||||||
{ return _parser.value(option); }
|
{ return _parser.value(option); }
|
||||||
|
|
||||||
QStringList values(const QString &optionName) const
|
QStringList values(const QString &optionName) const
|
||||||
{ return _parser.values(optionName); }
|
{ return _parser.values(optionName); }
|
||||||
|
|
||||||
QStringList values(const Option &option) const
|
QStringList values(const Option &option) const
|
||||||
{ return _parser.values(option); }
|
{ return _parser.values(option); }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //HYPERION_COMMANDLINEPARSER_H
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace FileUtils {
|
namespace FileUtils {
|
||||||
|
|
||||||
std::string getBaseName( std::string sourceFile);
|
std::string getBaseName( std::string sourceFile);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Process {
|
namespace Process {
|
||||||
|
@ -24,3 +24,8 @@ std::wstring Option::getStdWString(Parser &parser)
|
|||||||
return value(parser).toStdWString();
|
return value(parser).toStdWString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* Option::getCString(Parser &parser)
|
||||||
|
{
|
||||||
|
return value(parser).toLocal8Bit().constData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file alias="hyperion-schema">hyperion.schema.json</file>
|
<file alias="hyperion-schema">hyperion.schema.json</file>
|
||||||
|
<file alias="hyperion_default.config">../../config/hyperion.config.json.default</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -53,7 +53,7 @@ int main(int argc, char** argv)
|
|||||||
// create the option parser and initialize all parameters
|
// create the option parser and initialize all parameters
|
||||||
Parser parser("V4L capture application for Hyperion");
|
Parser parser("V4L capture application for Hyperion");
|
||||||
|
|
||||||
Option & argDevice = parser.add<Option> ('d', "device", "The device to use [default: %1]", "/dev/video0");
|
Option & argDevice = parser.add<Option> ('d', "device", "The device to use [default: %1]", "auto");
|
||||||
SwitchOption<VideoStandard> & argVideoStandard= parser.add<SwitchOption<VideoStandard>>('v', "video-standard", "The used video standard. Valid values are PAL, NTSC or no-change. [default: %1]", "no-change");
|
SwitchOption<VideoStandard> & argVideoStandard= parser.add<SwitchOption<VideoStandard>>('v', "video-standard", "The used video standard. Valid values are PAL, NTSC or no-change. [default: %1]", "no-change");
|
||||||
SwitchOption<PixelFormat> & argPixelFormat = parser.add<SwitchOption<PixelFormat>> (0x0, "pixel-format", "The use pixel format. Valid values are YUYV, UYVY, RGB32 or no-change. [default: %1]", "no-change");
|
SwitchOption<PixelFormat> & argPixelFormat = parser.add<SwitchOption<PixelFormat>> (0x0, "pixel-format", "The use pixel format. Valid values are YUYV, UYVY, RGB32 or no-change. [default: %1]", "no-change");
|
||||||
IntOption & argInput = parser.add<IntOption> (0x0, "input", "Input channel (optional)", "-1");
|
IntOption & argInput = parser.add<IntOption> (0x0, "input", "Input channel (optional)", "-1");
|
||||||
|
@ -41,5 +41,3 @@ endif ()
|
|||||||
|
|
||||||
install ( TARGETS hyperiond DESTINATION "share/hyperion/bin/" COMPONENT "${PLATFORM}" )
|
install ( TARGETS hyperiond DESTINATION "share/hyperion/bin/" COMPONENT "${PLATFORM}" )
|
||||||
install ( DIRECTORY ${CMAKE_SOURCE_DIR}/bin/service DESTINATION "share/hyperion/" COMPONENT "${PLATFORM}" )
|
install ( DIRECTORY ${CMAKE_SOURCE_DIR}/bin/service DESTINATION "share/hyperion/" COMPONENT "${PLATFORM}" )
|
||||||
install ( DIRECTORY ${CMAKE_SOURCE_DIR}/config DESTINATION "share/hyperion/" COMPONENT "${PLATFORM}" )
|
|
||||||
install ( DIRECTORY ${CMAKE_SOURCE_DIR}/assets/webconfig DESTINATION "share/hyperion/" COMPONENT "${PLATFORM}" )
|
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QResource>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include "HyperionConfig.h"
|
#include "HyperionConfig.h"
|
||||||
|
|
||||||
@ -71,6 +74,9 @@ int main(int argc, char** argv)
|
|||||||
BooleanOption & silentOption = parser.add<BooleanOption>('s', "silent", "do not print any outputs");
|
BooleanOption & silentOption = parser.add<BooleanOption>('s', "silent", "do not print any outputs");
|
||||||
BooleanOption & verboseOption = parser.add<BooleanOption>('v', "verbose", "Increase verbosity");
|
BooleanOption & verboseOption = parser.add<BooleanOption>('v', "verbose", "Increase verbosity");
|
||||||
BooleanOption & debugOption = parser.add<BooleanOption>('d', "debug", "Show debug messages");
|
BooleanOption & debugOption = parser.add<BooleanOption>('d', "debug", "Show debug messages");
|
||||||
|
Option & exportConfigOption = parser.add<Option> (0x0, "export-config", "export default config to file");
|
||||||
|
Option & exportEfxOption = parser.add<Option> (0x0, "export-effects", "export effects to given path");
|
||||||
|
|
||||||
parser.addPositionalArgument("config-files", QCoreApplication::translate("main", "Configuration files"), "[files...]");
|
parser.addPositionalArgument("config-files", QCoreApplication::translate("main", "Configuration files"), "[files...]");
|
||||||
|
|
||||||
parser.process(app);
|
parser.process(app);
|
||||||
@ -112,6 +118,54 @@ int main(int argc, char** argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parser.isSet(exportConfigOption))
|
||||||
|
{
|
||||||
|
Q_INIT_RESOURCE(resource);
|
||||||
|
if (QFile::copy(":/hyperion_default.config",exportConfigOption.value(parser)))
|
||||||
|
{
|
||||||
|
Info(log, "export complete.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Error(log, "can not export to %s",exportConfigOption.getCString(parser));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parser.isSet(exportEfxOption))
|
||||||
|
{
|
||||||
|
Q_INIT_RESOURCE(EffectEngine);
|
||||||
|
QDir directory(":/effects/");
|
||||||
|
QDir destDir(exportEfxOption.value(parser));
|
||||||
|
if (directory.exists() && destDir.exists())
|
||||||
|
{
|
||||||
|
std::cout << "extract to folder: " << std::endl;
|
||||||
|
QStringList filenames = directory.entryList(QStringList() << "*.json", QDir::Files, QDir::Name | QDir::IgnoreCase);
|
||||||
|
foreach (const QString & filename, filenames)
|
||||||
|
{
|
||||||
|
if (QFile::exists(destDir.dirName()+"/"+filename))
|
||||||
|
{
|
||||||
|
QFile::remove(destDir.dirName()+"/"+filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Extract: " << filename.toStdString() << " ... ";
|
||||||
|
if (QFile::copy(QString(":/effects/")+filename, destDir.dirName()+"/"+filename))
|
||||||
|
{
|
||||||
|
std::cout << "ok" << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "error, aborting" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Error(log, "can not export to %s",exportEfxOption.getCString(parser));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (configFiles.size() == 0)
|
if (configFiles.size() == 0)
|
||||||
{
|
{
|
||||||
Error(log, "Missing required configuration file. Usage: hyperiond <options ...> [config.file ...]");
|
Error(log, "Missing required configuration file. Usage: hyperiond <options ...> [config.file ...]");
|
||||||
@ -139,7 +193,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
if ( argvId < 0)
|
if ( argvId < 0)
|
||||||
{
|
{
|
||||||
Error(log, "No valid config found");
|
Warning(log, "No valid config found");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user