diff --git a/CHANGELOG.md b/CHANGELOG.md index d6774a620e6cb763c7aba1a9f1e8f4e9f4a2dd2b..3abafaa25ffa66d0585e767dfc64449ba072af6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ - Add the \_\_flat command to set all priorities to 1 in the queue - Add MPD commands: seek, seekid, seekcur, delete (partial), playlistid - Alias list\* commands as find +- lkt handle the playlistid (queue id) and \_\_flat (queue flatten) commands +- lkt shuffle works the same way as klkt, it doens't force the 'play' command but unpause, i.e it doesn't replay the kara - Remove archlinux package support (replaced by AppImage) - Fix dl process with the repo module - Fix: the moveid was in fact a move command, no range supported diff --git a/src/main/lkt.c b/src/main/lkt.c index 62eaa6210b692d14d9f794f8dbc3c8dbfbf8a0e5..8f9ada2a1006104b9737bc4843423544073ec15f 100644 --- a/src/main/lkt.c +++ b/src/main/lkt.c @@ -304,12 +304,13 @@ just_send_one_arg(queue_dump__, "__dump") fail_if(args->argc, "This command takes no arguments"); \ lkt_send_and_exit(msg, sizeof(msg)); \ } -just_send(queue_clear__, "clear\n") -just_send(queue_crop__, "crop\n") -just_send(next__, "next\n") -just_send(prev__, "previous\n") -just_send(stop__, "stop\n") -just_send(shuffle__, "shuffle\nplay\n") +just_send(queue_clear__, "clear\n") +just_send(queue_crop__, "crop\n") +just_send(next__, "next\n") +just_send(prev__, "previous\n") +just_send(stop__, "stop\n") +just_send(shuffle__, "shuffle\npause 0\n") +just_send(queue_flatten__, "__flat\n") #undef just_send noreturn void @@ -499,19 +500,11 @@ ping__(struct cmd_args *args) exit(write(1, "OK\n", sizeof("OK\n")) == 0); } -noreturn void -current__(struct cmd_args *args) +static noreturn void +__read_kara_and_exit(FILE *sock) { - if (args->argc != 0) - fail("Invalid argument, the current command takes no arguments"); - - static const char current_song__[] = "currentsong\n"; - char buff[LKT_MESSAGE_MAX]; - char *mem = NULL; - FILE *sock = lkt_connect(); - - write_socket(sock, current_song__); + char buff[LKT_MESSAGE_MAX]; assert(mem = calloc(6 * LKT_MESSAGE_MAX, sizeof(char))); assert(memset(mem, 0, 6 * LKT_MESSAGE_MAX * sizeof(char))); @@ -567,6 +560,29 @@ ok: exit(EXIT_SUCCESS); } +noreturn void +queue_id__(struct cmd_args *args) +{ + if (args->argc != 1) + fail("Invalid argument, the current command takes one argument"); + char probe_id__[LKT_LINE_MAX]; + safe_snprintf(probe_id__, LKT_LINE_MAX, "playlistid %ld\n", strtol(args->argv[0], NULL, 0)); + FILE *sock = lkt_connect(); + write_socket(sock, probe_id__); + __read_kara_and_exit(sock); +} + +noreturn void +current__(struct cmd_args *args) +{ + if (args->argc != 0) + fail("Invalid argument, the current command takes no arguments"); + static const char current_song__[] = "currentsong\n"; + FILE *sock = lkt_connect(); + write_socket(sock, current_song__); + __read_kara_and_exit(sock); +} + noreturn void queue_pop__(struct cmd_args *args) { @@ -1130,6 +1146,8 @@ static struct cmd_opt options_queue[] = { { .name = "crop", .call = queue_crop__ }, { .name = "replace", .call = queue_replace__ }, { .name = "dump", .call = queue_dump__ }, + { .name = "id", .call = queue_id__ }, + { .name = "flatten", .call = queue_flatten__ }, CMD_OPT_DEFAULT(queue_list__), };