From 1009b299959148e97fc3e1ccdaefdddcd1761e5f Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Sun, 19 May 2024 06:07:52 +0200 Subject: [PATCH 1/4] cli: fix spelling error in queue adding commands --- grzegorz_clients/cli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grzegorz_clients/cli.py b/grzegorz_clients/cli.py index 1912084..cc65f8a 100644 --- a/grzegorz_clients/cli.py +++ b/grzegorz_clients/cli.py @@ -64,7 +64,7 @@ def _add( api.playlist_goto(current_index if put_pre else current_index + 1) api.set_playing(True) -@cli.command(help="Add one ore more items to the playlist") +@cli.command(help="Add one or more items to the playlist") def play( urls: list[str], pre: bool = False, @@ -72,14 +72,14 @@ def play( ): _add(urls, put_post=not pre, put_pre=pre, play=True, api_base=api_base) -@cli.command(help="Add one ore more items to the playlist") +@cli.command(help="Add one or more items to the playlist") def next( urls: list[str], api_base: str = DEFAULT_API_BASE, ): _add(urls, put_post=True, api_base=api_base) -@cli.command(help="Add one ore more items to the playlist") +@cli.command(help="Add one or more items to the playlist") def queue( urls: list[str], play: bool = True, From 2b8ecf124dc90591c98da17d5d319fa0bf7a0380 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Sun, 19 May 2024 06:08:18 +0200 Subject: [PATCH 2/4] cli: add function to toggle playback status --- grzegorz_clients/cli.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grzegorz_clients/cli.py b/grzegorz_clients/cli.py index cc65f8a..10b8602 100644 --- a/grzegorz_clients/cli.py +++ b/grzegorz_clients/cli.py @@ -107,6 +107,12 @@ def pause( api_base: str = DEFAULT_API_BASE ): api.set_endpoint(api_base) rich.print(api.set_playing(False), file=sys.stderr) +@cli.command(help="Toggle playback") +def toggle(api_base: str = DEFAULT_API_BASE): + api.set_endpoint(api_base) + playing = api.is_playing() + rich.print(api.set_playing(not playing), file=sys.stderr) + @cli.command(help="Goto next item in playlist") def skip( api_base: str = DEFAULT_API_BASE ): api.set_endpoint(api_base) From ca78aa9e22965ee6fb4e4156169a4b92bcb8f9b3 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Sun, 19 May 2024 06:09:50 +0200 Subject: [PATCH 3/4] cli: allow relative volume adjustment using {+,-}{,%} --- grzegorz_clients/cli.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/grzegorz_clients/cli.py b/grzegorz_clients/cli.py index 10b8602..7adb11e 100644 --- a/grzegorz_clients/cli.py +++ b/grzegorz_clients/cli.py @@ -160,10 +160,19 @@ def status( @cli.command(help="Set the playback volume") def set_volume( - volume: int, + volume: str, api_base: str = DEFAULT_API_BASE, ): api.set_endpoint(api_base) + + volume = volume.removesuffix("%") + + if volume.startswith("+") or volume.startswith("-"): + current_volume = api.get_volume() + new_volume = max(0, min(100, current_volume + int(volume))) + else: + new_volume = int(volume) + rich.print(api.set_volume(volume), file=sys.stderr) From 0c45cbe1f65cff864eb633d6c9e09fa9eb1430bc Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Sun, 19 May 2024 06:39:23 +0200 Subject: [PATCH 4/4] flake: add grzegorzctl-only package which installs shell-completions --- flake.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index b00444f..e01309f 100644 --- a/flake.nix +++ b/flake.nix @@ -57,14 +57,28 @@ nativeBuildInputs = [ poetry-core ]; propagatedBuildInputs = [ setuptools flakes.self.pkgs.remi requests typer rich urllib3 ]; }; - default = flakes.self.pkgs.grzegorz-clients; + grzegorzctl = pkgs.runCommandNoCCLocal "grzegorzctl" ( + { + nativeBuildInputs = [ pkgs.installShellFiles ]; + } // + { inherit (flakes.self.pkgs.grzegorz-clients) meta; } // + { meta.mainProgram = "grzegorzctl"; } + )'' + mkdir -p $out/bin + ln -s "${flakes.self.pkgs.grzegorz-clients}/bin/grzegorzctl" $out/bin/grzegorzctl + installShellCompletion --cmd grzegorzctl \ + --bash <($out/bin/grzegorzctl --show-completion bash) \ + --zsh <($out/bin/grzegorzctl --show-completion zsh) \ + --fish <($out/bin/grzegorzctl --show-completion fish) + ''; + default = flakes.self.pkgs.grzegorzctl; }); apps = forAllSystems ({ system, ...}: rec { grzegorz-webui.type = "app"; grzegorz-webui.program = "${self.packages.${system}.grzegorz-clients}/bin/grzegorz-webui"; grzegorzctl.type = "app"; - grzegorzctl.program = "${self.packages.${system}.grzegorz-clients}/bin/grzegorzctl"; + grzegorzctl.program = "${self.packages.${system}.grzegorzctl}/bin/grzegorzctl"; default = grzegorzctl; });