Blur and Command line opts
* blur background image
* command line options for
* background blur radius
* background opacity
* path to image folder
* timeout for password rotation
This commit is contained in:
50
src/main.cpp
50
src/main.cpp
@@ -5,27 +5,51 @@
|
||||
#include <sys/file.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void usage(std::string programName) {
|
||||
std::cerr << "Usage: " << programName << " [-t rotation_seconds] [-o background_opacity(0..255)] [-b blur_radius] -p image_folder" << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned int rotationSeconds = 30;
|
||||
std::string path = "";
|
||||
|
||||
int pid_file = open("/tmp/slide.pid", O_CREAT | O_RDWR, 0666);
|
||||
int rc = flock(pid_file, LOCK_EX | LOCK_NB);
|
||||
if(rc) {
|
||||
if(EWOULDBLOCK == errno) {
|
||||
std::cout << "Already running. Exiting" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (argc < 2) {
|
||||
std::cout << "Error: Path expected." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
QApplication a(argc, argv);
|
||||
|
||||
MainWindow w;
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "b:p:t:o:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'p':
|
||||
path = optarg;
|
||||
break;
|
||||
case 't':
|
||||
rotationSeconds = atoi(optarg);
|
||||
break;
|
||||
case 'b':
|
||||
w.setBlurRadius(atoi(optarg));
|
||||
break;
|
||||
case 'o':
|
||||
w.setBackgroundOpacity(atoi(optarg));
|
||||
break;
|
||||
default: /* '?' */
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (path.empty()) {
|
||||
std::cout << "Error: Path expected." << std::endl;
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
w.show();
|
||||
|
||||
ImageSelector is(w, 30000, argv[1]);
|
||||
ImageSelector is(w, rotationSeconds * 1000, path);
|
||||
is.start();
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user