sigap

Simplest audio player possible bundled signal based queue manager
Log | Files | Refs | README | LICENSE

commit e005bb35fceb5fca0a353848b09f2a9d06e28be7
parent e541f8f411995b2aff33a5c599620f5a60fd730a
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Thu, 15 Jul 2021 20:08:22 -0700

Add queue looping

Diffstat:
Msigap.1 | 4+++-
Msigap.c | 11++++++++---
2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/sigap.1 b/sigap.1 @@ -7,7 +7,7 @@ .Nd signal audio player .Sh SYNOPSIS .Nm -.Op Fl p +.Op Fl lp .Op Fl e Ar player .Ar file ... .Sh DESCRIPTION @@ -27,6 +27,8 @@ Use .Ar player instead of the default .Pa ap . +.It Fl l +Loop the queue. .It Fl p Ignore player errors. .El diff --git a/sigap.c b/sigap.c @@ -38,6 +38,7 @@ static struct player { } player; static char *ap[] = { "ap", NULL }; +static int loop; static int persist; void @@ -102,16 +103,19 @@ main(int argc, char *argv[]) die("pledge"); #endif - while ((c = getopt(argc, argv, "e:p")) != -1) { + while ((c = getopt(argc, argv, "e:lp")) != -1) { switch (c) { case 'e': *ap = optarg; break; + case 'l': + loop = 1; + break; case 'p': persist = 1; break; default: - fprintf(stderr, "usage: %s [-p] [-e player] [file ...]\n", + fprintf(stderr, "usage: %s [-lp] [-e player] file ...\n", *argv); return 1; } @@ -123,7 +127,8 @@ main(int argc, char *argv[]) signal(SIGINFO, handle); signal(SIGINT, handle); - for (i = 0; i < argc && (persist || player.status == 0); ++i) { + for (i = 0; i < argc && (persist || player.status == 0); + i = ((loop) ? ((i + 1) % argc) : (i + 1))) { if (play(argv[i])) die(argv[i]); puts(player.path);