dweymouth / supersonic

A lightweight and full-featured cross-platform desktop client for self-hosted music servers
GNU General Public License v3.0
918 stars 46 forks source link

Ability to control playback with command-line flags #377

Closed Underpath closed 4 months ago

Underpath commented 6 months ago

Currently, it is possible to control playback using the standard media keys on keyboard (forward, play/pause, etc.). For added flexibility I would love to have additional ways to controlling playback through one of these options:

  1. Applescript. Other media players can take commands this way, for example: tell application "Spotify" to playpause
  2. Command line. Other media players can take commands this way, for example: clementine --play-pause
  3. Custom global shortcuts, see options from Strawberry player: image

Enabling any of these options would allow for the player to be controlled through automations and scripts. Currently I'm unable to reliably do this because the media keys in macOS control all media, so watching a Youtube video in a browser hijacks them even when I only want to control my music player.

Underpath commented 6 months ago

Had a look at the code and unfortunately I'm not knowledgeable in Go so I couldn't find a way to fix this myself. Seems option 2 would be the most viable.

Global shortcuts are not supported in fyne so something like this would be needed for option 3: https://github.com/golang-design/hotkey

dweymouth commented 6 months ago

Command-line arguments would certainly be the easiest to add, but I have a feeling like they might only be useful on Linux? On Windows, a GUI app actually cannot access command-line arguments (yes it's a very weird choice by Microsoft). And on Mac, they can, but you have to use the full path to the binary inside of the .app bundle, AFAIK. Do you know how other GUI apps on Mac that also accept CLI arguments set it up?

Edit: on Windows it's actually that a GUI app can't attach to a console, which is a bit different

Underpath commented 6 months ago

Both Clementine and Strawberry have very similar implementations, not surprising given Strawberry is a fork of Clementine:

Interesting to know the limitation on Windows, but for macOS I don't think that's much of a problem, using the full path to the binary seems easy enough to me.

xisonc commented 6 months ago

I'd also like to see this, then I can bind my own keyboard shortcuts and also programmatically control playback.

For instance on my laptop I have a custom script that runs to pause my music when I lock my screen. This currently is not possible with supersonic, but I used regularly with Clementine/Strawberry.