Open blackalegator opened 4 years ago
Yes, it should be! Some features would probably be trickier to split, but there is already a bit of hacky code for partially disabling the UI when running with the "-a" cmd option.
I'm curious though, what's your use case for running the app as a daemon?
Oh, I really like the spotify visualizer. I have a nanoleaf canvas and the mic sensitivity is just too low. I also have a smart home controlled via Home Assistant. Manually powering up my pc and starting up the application every time isn't so much fun and I wanted to just host a service and control it via REST / stdin for automating this task.
Ah I see, that actually sounds like a great idea. I can also see myself making use of this.
Unfortunately it will probably take me a long time to get around to implementing this (i'm talking maybe months) due to me having zero free time right now.
The spotify visualizer really shouldn't take long to implement as a daemon, but there are two problems I anticipate: 1) The device location data is (stupidly) stored in a UI object for controlling the virtual panel preview (PanelCanvas.java). Not too big of a problem but a bit of a pain to change this. 2) The only way to authenticate with spotify's api is to go through their annoying oauth UI. I guess the url will have to be manually sent to the user somehow which pretty inconvenient. Maybe there is a workaround for this but I'm not sure. To make this worse, the app currently requires re-authentication every hour. (Of course there are refresh tokens that can be used but they actually don't work due to a bug in the code. I decided to actually not fix the bug since all users share the same api key and this potentially prevents people from going over the quota)
Hopefully I'll get a free weekend at some point so I can look into this more.
+1!
Makes sense. Now I get why all the Spotify Integration stuff is only done through apps, etc. Would be great to have a Rest API. Thanks!
I finally got around to working on this a bit (headless branch). The headless Spotify authentication is still a bit wonky, but for testing purposes for now, authenticating through the UI still works. The server runs in headless with the -s
option on port 7145. Authenticating is done by a GET /spotify/authenticate
and enabling the Spotify visualizer is done by a PUT /spotify/state/enable
with data {"value": true}
. Sensitivity, palette, and audio offset still have to be implemented in the api. (Current api documentation)
Would it be possible to split GUI and logic so that the app can be run as a daemon on a linux server/synology NAS?