Closed c7v closed 1 year ago
@c7v Hi, and thank you for the issue.
I have a question: Is spotify running on the computer? Pytify is just a CLI that talks directly to the spotify application.
@bjarneo Hi! Yes, spotify running on the computer. Yes, I know that Pytify is a terminal control, but in a bash script I can execute commands, which is what I'm trying to do.
Alright, so, since you are running linux, try this command directly (pytify is using this command under the hood):
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
This will be the equivalent of running pytify -pp
Does that work?
If it works: Something is not OK with Pytify If it does not: Something is wrong at your end
@c7v and I believe cron is running as root, right? And the Spotify player is by your user? Might be causing this as well. 🤔
@bjarneo cron can run as root or as a different user, it already depends on which user you opened crontab -e under.
Tried to use your command through the terminal, the command worked and the music started.
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
But when I run the command in a cron task, I get an error:
Failed to open connection to "session" message bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
But running a cron task under a different user is more likely..
If you correct this command in the terminal, the username will be corrected in the file.
artem@MS-7991:~$ echo $USER >> /home/artem/cron.log
However, when this command is run in a cron job, the file is created at the specified time, as suggested by the cron job, but the file is empty.
It looks like the cron command is running under an invisible user. :rofl: :laughing:
Hm. Quite interesting read, I must say. Awesome debugging :)
Let me know if you figure out how to solve it.
Found this comment though: https://stackoverflow.com/a/70560980
После этого https://stackoverflow.com/a/70560980, только хуже получилось
artem@MS-7991:~$ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.mpris.MediaPlayer2.spotify was not provided by any .service files
Хорошо, я попробую решить эту проблему и напишу о решении тут, не закрывайте эту задачу.
Хорошо, я попробую решить эту проблему и напишу о решении тут, не закрывайте эту задачу. Ok, I will try to solve this problem and write about the solution here, do not close this task.
Alright, cool :)
Hello, due to the sanctions against Russia, I can no longer work on your task, because I can not renew my subscription and include music.
I will return to this task when Spotify gets tired of sitting without money from Russia. 💸
aww, that sucks man, I will leave this issue open, and hope for you to one day come back to solve it 🤞
I have a bash script file that is set to run automatically: https://github.com/c7v/work_run/blob/master/work_run.sh and I start Spotify before work.I was hoping that there would be music on Spotify at exactly 9:00, which would let me know if I'm not at the computer about the start of work hours. I was planning to run music in Spotify via cron using a script:
as a result, the script worked, but the music did not turn on, the following error was issued:
How can I start Spotify music at 9 am automatically?
Thanks for the help and software! ❤️