[GH-ISSUE #279] Support handling CLI commands without a running spotify_player instance #1080

Closed
opened 2026-03-14 13:21:22 +03:00 by kerem · 8 comments
Owner

Originally created by @chrisgrieser on GitHub (Oct 28, 2023).
Original GitHub issue: https://github.com/aome510/spotify-player/issues/279

Is your feature request related to a problem? Please describe.
spotify_player playback … requires a running instance of spotify_player. However, when playing via Spotify Connect, you do not always really need a daemon or the TUI running, often something like spotify_player playback next is enough.

Describe the solution you'd like
A way to send playback commands to a Spotify Connect device. spotify-tui allows you to do this via spt playback --next – no daemon, no running TUI, affecting the Spotify Connect Device.

Describe alternatives you've considered
Running spotifiy_player in the background all the time, even if not needed.

Additional context
Looking to replace the unmaintained spotify-tui. Basically, this is the only feature missing that I need before being able to switch.

Thanks for the cli, its UI is much better than of other players I tried.

Originally created by @chrisgrieser on GitHub (Oct 28, 2023). Original GitHub issue: https://github.com/aome510/spotify-player/issues/279 **Is your feature request related to a problem? Please describe.** `spotify_player playback …` requires a running instance of `spotify_player`. However, when playing via `Spotify Connect`, you do not always really need a daemon or the TUI running, often something like `spotify_player playback next` is enough. **Describe the solution you'd like** A way to send playback commands to a Spotify Connect device. `spotify-tui` allows you to do this via `spt playback --next` – no daemon, no running TUI, affecting the Spotify Connect Device. **Describe alternatives you've considered** Running `spotifiy_player` in the background all the time, even if not needed. **Additional context** Looking to replace the unmaintained `spotify-tui`. Basically, this is the only feature missing that I need before being able to switch. Thanks for the cli, its UI is much better than of other players I tried.
kerem 2026-03-14 13:21:22 +03:00
Author
Owner

@aome510 commented on GitHub (Oct 28, 2023):

The design for CLI support between spotify_player and spotify-tui are different. spotify-tui treats CLI as a separate application, while spotify_player treats CLI as a tool to interact with the main application.

Because CLI is a separate application, each time spotify-tui want to handle a CLI command, e.g player next, it will need to initialize a Spotify client from scratch, which includes fetching credentials. The credential fetching part can make handling the CLI command slow. spotify_player CLI handles those commands instantly. Of course, this is a trade-off between flexibility and performance.

Currently, the spotify_player CLI architecture is implemented based on the assumption that it's a tool to communicate with the main application. Will need to find a good way to abstract the codes to support both modes.

<!-- gh-comment-id:1783884431 --> @aome510 commented on GitHub (Oct 28, 2023): The design for CLI support between `spotify_player` and `spotify-tui` are different. `spotify-tui` treats CLI as a separate application, while `spotify_player` treats CLI as a tool to interact with the main application. Because CLI is a separate application, each time `spotify-tui` want to handle a CLI command, e.g `player next`, it will need to initialize a Spotify client from scratch, which includes fetching credentials. The credential fetching part can make handling the CLI command slow. `spotify_player` CLI handles those commands _instantly_. Of course, this is a trade-off between flexibility and performance. Currently, the `spotify_player` CLI architecture is implemented based on the assumption that it's a tool to communicate with the main application. Will need to find a good way to abstract the codes to support both modes.
Author
Owner

@catgoose commented on GitHub (Nov 1, 2023):

I used to use spotify_tui in neovim with the toggle term plugin. It was simple to open a floating window to control spotify. I don't really want to have an application running, I would really like to dispatch commands to a CLI when neaded.

<!-- gh-comment-id:1789846742 --> @catgoose commented on GitHub (Nov 1, 2023): I used to use `spotify_tui` in neovim with the toggle term plugin. It was simple to open a floating window to control spotify. I don't really want to have an application running, I would really like to dispatch commands to a CLI when neaded.
Author
Owner

@aome510 commented on GitHub (Nov 13, 2023):

@catgoose @chrisgrieser the support for running CLI commands without a running instance is implemented in https://github.com/aome510/spotify-player/pull/290.

Can you guys checkout master and run the application cargo run --release -- {command} to see it works as expected?

Just a note that without a running instance, the latency of the command will increase significantly (~100x based in my local machine):

Without a running instance

  • playback next
$ time test_spotify_player playback next
________________________________________________________
Executed in    1.15 secs      fish           external
   usr time   28.03 millis    0.23 millis   27.80 millis
   sys time   18.36 millis    1.83 millis   16.54 millis
  • get key playback
> time test_spotify_player get key playback
________________________________________________________
Executed in    1.27 secs      fish           external
   usr time   29.29 millis    0.25 millis   29.04 millis
   sys time   23.85 millis    2.13 millis   21.71 millis

With a running instance

  • playback next
> time test_spotify_player playback next
________________________________________________________
Executed in   14.94 millis    fish           external
   usr time    7.58 millis    0.19 millis    7.39 millis
   sys time    5.54 millis    1.54 millis    4.00 millis
  • get key playback
> time test_spotify_player get key playback
________________________________________________________
Executed in   16.28 millis    fish           external
   usr time    7.54 millis    0.19 millis    7.35 millis
   sys time    5.90 millis    1.63 millis    4.27 millis

The bottleneck seems to come from network requests to get API token and send Spotify APIs. I will be surprised if spotify-tui CLI's latency is much better than this.

<!-- gh-comment-id:1807383261 --> @aome510 commented on GitHub (Nov 13, 2023): @catgoose @chrisgrieser the support for running CLI commands without a running instance is implemented in https://github.com/aome510/spotify-player/pull/290. Can you guys checkout `master` and run the application `cargo run --release -- {command}` to see it works as expected? Just a note that without a running instance, the latency of the command will increase significantly (~100x based in my local machine): > ### Without a running instance > > * `playback next` > ``` > $ time test_spotify_player playback next > ________________________________________________________ > Executed in 1.15 secs fish external > usr time 28.03 millis 0.23 millis 27.80 millis > sys time 18.36 millis 1.83 millis 16.54 millis > ``` > * `get key playback` > > ``` > > time test_spotify_player get key playback > ________________________________________________________ > Executed in 1.27 secs fish external > usr time 29.29 millis 0.25 millis 29.04 millis > sys time 23.85 millis 2.13 millis 21.71 millis > ``` > > ## With a running instance > > * `playback next` > ``` > > time test_spotify_player playback next > ________________________________________________________ > Executed in 14.94 millis fish external > usr time 7.58 millis 0.19 millis 7.39 millis > sys time 5.54 millis 1.54 millis 4.00 millis > ``` > * `get key playback` > > ``` > > time test_spotify_player get key playback > ________________________________________________________ > Executed in 16.28 millis fish external > usr time 7.54 millis 0.19 millis 7.35 millis > sys time 5.90 millis 1.63 millis 4.27 millis > ``` The bottleneck seems to come from network requests to get API token and send Spotify APIs. I will be surprised if `spotify-tui` CLI's latency is much better than this.
Author
Owner

@chrisgrieser commented on GitHub (Nov 13, 2023):

yeah, spotify-tui also has 1-2 seconds of latency for that. That's ok.

Just checked out master the common commands (playback next, playback play-pause) work as expected on my end :)

<!-- gh-comment-id:1807897506 --> @chrisgrieser commented on GitHub (Nov 13, 2023): yeah, `spotify-tui` also has 1-2 seconds of latency for that. That's ok. Just checked out master the common commands (`playback next`, `playback play-pause`) work as expected on my end :)
Author
Owner

@catgoose commented on GitHub (Nov 13, 2023):

prev, next, play-pause work for me! Could there be an argument to volume to increase/decrease by a percentage? My use case is to use neovim key bindings to do prev/nex/pause and lower/raise volume, so if I could adjust volume in that way it would be really nice!

<!-- gh-comment-id:1808434412 --> @catgoose commented on GitHub (Nov 13, 2023): prev, next, play-pause work for me! Could there be an argument to `volume` to increase/decrease by a percentage? My use case is to use neovim key bindings to do prev/nex/pause and lower/raise volume, so if I could adjust volume in that way it would be really nice!
Author
Owner

@aome510 commented on GitHub (Nov 13, 2023):

prev, next, play-pause work for me! Could there be an argument to volume to increase/decrease by a percentage? My use case is to use neovim key bindings to do prev/nex/pause and lower/raise volume, so if I could adjust volume in that way it would be really nice!

spotify_player supports increasing/decreasing by an offset with --offset option:

> spotify_player playback volume -h
Set the volume percentage

Usage: spotify_player playback volume [OPTIONS] <percent>

Arguments:
  <percent>

Options:
      --offset  Increase the volume percent by an offset

Decreasing just means using negative value.

<!-- gh-comment-id:1808756161 --> @aome510 commented on GitHub (Nov 13, 2023): > prev, next, play-pause work for me! Could there be an argument to `volume` to increase/decrease by a percentage? My use case is to use neovim key bindings to do prev/nex/pause and lower/raise volume, so if I could adjust volume in that way it would be really nice! `spotify_player` supports increasing/decreasing by an offset with `--offset` option: ``` > spotify_player playback volume -h Set the volume percentage Usage: spotify_player playback volume [OPTIONS] <percent> Arguments: <percent> Options: --offset Increase the volume percent by an offset ``` Decreasing just means using negative value.
Author
Owner

@catgoose commented on GitHub (Nov 14, 2023):

prev, next, play-pause work for me! Could there be an argument to volume to increase/decrease by a percentage? My use case is to use neovim key bindings to do prev/nex/pause and lower/raise volume, so if I could adjust volume in that way it would be really nice!

spotify_player supports increasing/decreasing by an offset with --offset option:

> spotify_player playback volume -h
Set the volume percentage

Usage: spotify_player playback volume [OPTIONS] <percent>

Arguments:
  <percent>

Options:
      --offset  Increase the volume percent by an offset

Decreasing just means using negative value.

❯ cargo run --release -- playback volume --offset 10
    Finished release [optimized + debuginfo] target(s) in 0.19s
     Running `target/release/spotify_player playback volume --offset 10`
Bad request: http error: status code 400 Bad Request

I get a similar error if I try to set volume to a percentage:

❯ cargo run --release -- playback volume 30
    Finished release [optimized + debuginfo] target(s) in 0.19s
     Running `target/release/spotify_player playback volume 30`
Bad request: http error: status code 403 Forbidden
<!-- gh-comment-id:1810259584 --> @catgoose commented on GitHub (Nov 14, 2023): > > prev, next, play-pause work for me! Could there be an argument to `volume` to increase/decrease by a percentage? My use case is to use neovim key bindings to do prev/nex/pause and lower/raise volume, so if I could adjust volume in that way it would be really nice! > > `spotify_player` supports increasing/decreasing by an offset with `--offset` option: > > ``` > > spotify_player playback volume -h > Set the volume percentage > > Usage: spotify_player playback volume [OPTIONS] <percent> > > Arguments: > <percent> > > Options: > --offset Increase the volume percent by an offset > ``` > > Decreasing just means using negative value. ``` ❯ cargo run --release -- playback volume --offset 10 Finished release [optimized + debuginfo] target(s) in 0.19s Running `target/release/spotify_player playback volume --offset 10` Bad request: http error: status code 400 Bad Request ``` I get a similar error if I try to set volume to a percentage: ``` ❯ cargo run --release -- playback volume 30 Finished release [optimized + debuginfo] target(s) in 0.19s Running `target/release/spotify_player playback volume 30` Bad request: http error: status code 403 Forbidden ```
Author
Owner

@aome510 commented on GitHub (Nov 14, 2023):

prev, next, play-pause work for me! Could there be an argument to volume to increase/decrease by a percentage? My use case is to use neovim key bindings to do prev/nex/pause and lower/raise volume, so if I could adjust volume in that way it would be really nice!

spotify_player supports increasing/decreasing by an offset with --offset option:

> spotify_player playback volume -h
Set the volume percentage

Usage: spotify_player playback volume [OPTIONS] <percent>

Arguments:
  <percent>

Options:
      --offset  Increase the volume percent by an offset

Decreasing just means using negative value.

❯ cargo run --release -- playback volume --offset 10
    Finished release [optimized + debuginfo] target(s) in 0.19s
     Running `target/release/spotify_player playback volume --offset 10`
Bad request: http error: status code 400 Bad Request

I get a similar error if I try to set volume to a percentage:

❯ cargo run --release -- playback volume 30
    Finished release [optimized + debuginfo] target(s) in 0.19s
     Running `target/release/spotify_player playback volume 30`
Bad request: http error: status code 403 Forbidden

weird, it works well for me (both command) to change volume of the official Spotify app. Bad request may mean that there is no active playback.

<!-- gh-comment-id:1810334654 --> @aome510 commented on GitHub (Nov 14, 2023): > > > prev, next, play-pause work for me! Could there be an argument to `volume` to increase/decrease by a percentage? My use case is to use neovim key bindings to do prev/nex/pause and lower/raise volume, so if I could adjust volume in that way it would be really nice! > > > > > > `spotify_player` supports increasing/decreasing by an offset with `--offset` option: > > ``` > > > spotify_player playback volume -h > > Set the volume percentage > > > > Usage: spotify_player playback volume [OPTIONS] <percent> > > > > Arguments: > > <percent> > > > > Options: > > --offset Increase the volume percent by an offset > > ``` > > > > > > > > > > > > > > > > > > > > > > > > Decreasing just means using negative value. > > ``` > ❯ cargo run --release -- playback volume --offset 10 > Finished release [optimized + debuginfo] target(s) in 0.19s > Running `target/release/spotify_player playback volume --offset 10` > Bad request: http error: status code 400 Bad Request > ``` > > I get a similar error if I try to set volume to a percentage: > > ``` > ❯ cargo run --release -- playback volume 30 > Finished release [optimized + debuginfo] target(s) in 0.19s > Running `target/release/spotify_player playback volume 30` > Bad request: http error: status code 403 Forbidden > ``` weird, it works well for me (both command) to change volume of the official Spotify app. Bad request may mean that there is no active playback.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-player#1080
No description provided.