summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhostNaN <GhostNaN@protonmail.com>2021-06-03 09:08:49 -0400
committerGhostNaN <GhostNaN@protonmail.com>2021-06-03 09:08:49 -0400
commitbee58087cb0c593cca28bcf14a36eab3d29619aa (patch)
treeb9ea1dd16e8596c132efcad8d2568d2c0ddfca51
parentd8e5f2373b7da3de77d89f6b28fe2bb09ec2b8a7 (diff)
Add auto-next option and fix usage text
- Added a small convenience option "auto-next" Best used with "loop loop-playlist" mpv options - Usage text now shows required args
-rw-r--r--src/holder.c9
-rw-r--r--src/main.c39
2 files changed, 33 insertions, 15 deletions
diff --git a/src/holder.c b/src/holder.c
index 32027b3..81df59e 100644
--- a/src/holder.c
+++ b/src/holder.c
@@ -309,6 +309,7 @@ static void parse_command_line(int argc, char **argv, struct wl_state *state) {
{"fork", no_argument, NULL, 'f'},
{"auto-pause", no_argument, NULL, 'p'},
{"auto-stop", no_argument, NULL, 's'},
+ {"auto-next", required_argument, NULL, 'n'},
{"layer", required_argument, NULL, 'l'},
{"mpv-options", required_argument, NULL, 'o'},
{0, 0, 0, 0}
@@ -316,18 +317,18 @@ static void parse_command_line(int argc, char **argv, struct wl_state *state) {
const char *usage =
"Usage: mpvpaper-holder <mpvpaper options>\n"
- "Descrition:\n"
+ "Description:\n"
"mpvpaper-holder acts as a lean gate keeper before mpvpaper can run\n"
"\n"
"It's sole purpose is to check if there is:\n"
- "Any program is that running from the stoplist file\n"
+ "Any program that is running from the stoplist file\n"
"- Set in \"~/.config/mpvpaper/stoplist\"\n"
- "If the wallpaper needs to be seen when drawn\n"
+ "And if the wallpaper needs to be seen when drawn\n"
"- Set with \"-s\" or \"--auto-stop\" mpvpaper option\n";
if(argc > 2) {
char opt;
- while((opt = getopt_long(argc, argv, "hvfpsl:o:Z:", long_options, NULL)) != -1) {
+ while((opt = getopt_long(argc, argv, "hvfpsn:l:o:Z:", long_options, NULL)) != -1) {
switch (opt) {
case 'h':
diff --git a/src/main.c b/src/main.c
index 5f6f025..7196e35 100644
--- a/src/main.c
+++ b/src/main.c
@@ -77,6 +77,7 @@ static struct {
static pthread_t threads[5];
+static uint AUTO_NEXT_TIME = 0;
static bool VERBOSE = 0;
static void nop() {}
@@ -342,8 +343,16 @@ static void *handle_auto_stop() {
static void *handle_mpv_events() {
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
bool mpv_paused = 0;
+ time_t start_time = time(NULL);
while (!halt_info.kill_render_loop) {
+ if (AUTO_NEXT_TIME) {
+ if ((time(NULL) - start_time) >= AUTO_NEXT_TIME) {
+ mpv_command_async(mpv, 0, (const char*[]) {"playlist-next", NULL});
+ start_time = time(NULL);
+ }
+ }
+
mpv_event* event = mpv_wait_event(mpv, 0);
if (event->event_id == MPV_EVENT_SHUTDOWN || event->event_id == MPV_EVENT_IDLE)
exit_mpvpaper(0);
@@ -779,6 +788,7 @@ static void parse_command_line(int argc, char **argv, struct wl_state *state) {
{"fork", no_argument, NULL, 'f'},
{"auto-pause", no_argument, NULL, 'p'},
{"auto-stop", no_argument, NULL, 's'},
+ {"auto-next", required_argument, NULL, 'n'},
{"layer", required_argument, NULL, 'l'},
{"mpv-options", required_argument, NULL, 'o'},
{0, 0, 0, 0}
@@ -786,17 +796,18 @@ static void parse_command_line(int argc, char **argv, struct wl_state *state) {
const char *usage =
"Usage: mpvpaper [options] <output> <url|path filename>\n"
- "Example: mpvpaper -o \"no-audio loop\" DP-2 /path/to/video\n"
+ "Example: mpvpaper -vs -o \"no-audio loop\" DP-2 /path/to/video\n"
"Options:\n"
- "--help -h Displays this help message\n"
- "--verbose -v Be more verbose\n"
- "--fork -f Forks mpvpaper so you can close the terminal\n"
- "--auto-pause -p Automagically pause mpv when the wallpaper is hidden\n"
- " This saves CPU usage, more or less, seamlessly\n"
- "--auto-stop -s Automagically stop mpv when the wallpaper is hidden\n"
- " This saves CPU/RAM usage, although more abruptly\n"
- "--layer -l Specifies shell surface layer to run on (background by default)\n"
- "--mpv-options -o Forwards mpv options (Must be within quotes\"\")\n";
+ "--help -h Displays this help message\n"
+ "--verbose -v Be more verbose\n"
+ "--fork -f Forks mpvpaper so you can close the terminal\n"
+ "--auto-pause -p Automagically pause mpv when the wallpaper is hidden\n"
+ " This saves CPU usage, more or less, seamlessly\n"
+ "--auto-stop -s Automagically stop mpv when the wallpaper is hidden\n"
+ " This saves CPU/RAM usage, although more abruptly\n"
+ "--auto-next -n SECS Play the next video in a playlist every ? seconds\n"
+ "--layer -l LAYER Specifies shell surface layer to run on (background by default)\n"
+ "--mpv-options -o \"OPTIONS\" Forwards mpv options (Must be within quotes\"\")\n";
if(argc > 2) {
@@ -804,7 +815,7 @@ static void parse_command_line(int argc, char **argv, struct wl_state *state) {
char *mpv_options;
char opt;
- while((opt = getopt_long(argc, argv, "hvfpsl:o:Z:", long_options, NULL)) != -1) {
+ while((opt = getopt_long(argc, argv, "hvfpsn:l:o:Z:", long_options, NULL)) != -1) {
switch (opt) {
case 'h':
@@ -829,6 +840,12 @@ static void parse_command_line(int argc, char **argv, struct wl_state *state) {
halt_info.auto_stop = 1;
halt_info.auto_pause = 0;
break;
+ case 'n':
+ AUTO_NEXT_TIME = atoi(optarg);
+ if (AUTO_NEXT_TIME == 0)
+ cflp_warning("0 or invaild time set for auto-next\n"
+ "Please use a postitive integer");
+ break;
case 'l':
layer_name = strdup(optarg);
if(layer_name == NULL) {