blahsd/snwe

iTunes / Spotify Integration

blahsd opened this issue ยท 9 comments

iTunes / Spotify Integration

The iTunes module is not working for me.

After opening the preference window and selecting the iTunes option, opening iTunes, and playing a song, there is no song information shown. The player buttons are interactable but do not control iTunes. Opening the preference window again shows that the iTunes option is no longer selected and that no option is selected under the music player menu. It seems that the iTunes selection in that menu is not being persisted.

Alright, this is going to be a tough one because I can't reproduce it, even after deleting everything and doing a clean clone of the repo. I've opened a new branch 'debug' in order to pin this down. If you clone from that branch, the following should happen:

  • When you open the preference pane, you should get an alert indicating which module is loaded

  • When you select a different option, you should get (a) two alerts, one from the preference pane and one from the bar itself, indicating the currently loaded module, and (b) two alerts, indicating the module that is getting loaded.

  • Whenever you select any other preference you should get the same alerts, which are not useful in that case.

If this happens, the module is getting loaded and we'll have to look somewhere else.
If this doesn't happen something is wrong with the loading of the module.

Let me know!

I'm on the most recent commit, switched to the debug branch, and ran the application again (after deleting the app/css/colors-wal.css file) but there's no change in behavior... I don't see any notifications nor can I see track info, unfortunately.

I don't have Spotify installed. Is this set up similar to the supernerd widget so that it would work only if Spotify and iTunes are installed on the same system?

I don't have Spotify installed. Is this set up similar to the supernerd widget so that it would work only if Spotify and iTunes are installed on the same system?

Nope. It's two separate modules so it should be absolutely irrelevant. For good measure I uninstalled it from my system too, and it still works for me.

If you want, you could try activating the debug window on your copy of snwe to help me pin down the problem. Here's what you'd have to do:

  1. Navigate to the ../snwe folder
  2. Open main.js. At line 24 you should have the following:

// win.webContents.openDevTools();

Remove the two slashes to uncomment the line and activate it.

  1. At line 14 you should have:

height: 64,

Substitute '64' with 'height' in order to have:

height: height,

  1. Open ./js/windowManager.js. At line 39 you should have the following:

//popWindow.webContents.openDevTools();

Again, uncomment the line.

What you are doing is the following: 2 and 4 make it so that spawning a new window does so while also spawning the developer tools, which include a console that the program uses to pass output to the user. Step 3 is needed so that the console is actually large enough for you to see the output. When you launch snwe the console will take up the entire screen โ€“ you can close it at any time by closing snwe or by clicking the little x up and rightmost. Best thing to do would be to click the "pop out" icon so that the developer console becomes a window in its own right and stops taking up so much space and you can resize it how you want.

In the developer tools, click on the tab named 'Console'. You should now see that most things you do (clicking around, changing preferences, etc.) result in some kind of message being printed (some might not be very helpful or sound stupid, they weren't intended to be seen by others :P). You might see red lines indicating errors. What you should do is try to open up the preference pane a couple of times, change preferences, close it down, etc. and copy here your console output. If you see anything suspicious (esp. red lines ofc) take a note of what you did that got you a red line, and see if you can reproduce it.

Thanks!!!

Made the above changes to the program files and after running npm start and opening the resulting console view, I get the following error immediately on startup:

error

Username redacted, but the path is just the expansion of $HOME/bin/snwe/app/js/itunes

If I'm interpreting this properly, it seems that it is not reading the itunes.js file properly. Strange, considering that file exists in the appropriate directory...

Here is the output of tree in the cloned repo (ignoring the node_modules and .git directories):

~/bin/snwe debug*
โฏ tree -a -I '.git|node_modules'
.
โ”œโ”€โ”€ .DS_Store
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ app
โ”‚   โ”œโ”€โ”€ css
โ”‚   โ”‚   โ”œโ”€โ”€ center.css
โ”‚   โ”‚   โ”œโ”€โ”€ colors-wal.css -> $HOME/.cache/wal/colors.css
โ”‚   โ”‚   โ”œโ”€โ”€ colors.css
โ”‚   โ”‚   โ”œโ”€โ”€ common.css
โ”‚   โ”‚   โ”œโ”€โ”€ flat.css
โ”‚   โ”‚   โ”œโ”€โ”€ four.css
โ”‚   โ”‚   โ”œโ”€โ”€ mono.css
โ”‚   โ”‚   โ””โ”€โ”€ settings.css
โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ”œโ”€โ”€ js
โ”‚   โ”‚   โ”œโ”€โ”€ index.js
โ”‚   โ”‚   โ”œโ”€โ”€ itunes.js
โ”‚   โ”‚   โ”œโ”€โ”€ mpd.js
โ”‚   โ”‚   โ”œโ”€โ”€ settings.js
โ”‚   โ”‚   โ”œโ”€โ”€ settingsManager.js
โ”‚   โ”‚   โ”œโ”€โ”€ spotify.js
โ”‚   โ”‚   โ””โ”€โ”€ windowManager.js
โ”‚   โ””โ”€โ”€ settings.html
โ”œโ”€โ”€ log.txt
โ”œโ”€โ”€ main.js
โ”œโ”€โ”€ package-lock.json
โ””โ”€โ”€ package.json

3 directories, 24 files

Alright I think I got it. The preference pane is looking for /itunes instead of /itunes.js by mistake.

I think you had your preferences set by a previous commit which wasn't setting them correctly, then I fixed it, but your preferences were fucked up now, so it couldn't even get to the point of loading them to fix them. Try this:

Open settingsManager.js โ€“ at the very end, make a new line and add the following:

initializePreferences();

This will call upon the function that sets up fresh preferences โ€“ it's generally only used when the preferences are not defined yet, but in your case it will wipe your preferences (sorry) and set them up correctly.
If I'm right this will fix the issue. After it's fixed, you should go back and delete that line, so that your preferences go back to being persistent. And then I should get it to do automatically when the preferences don't work correctly.

You're the best debugger I've ever had btw hahaha

EDIT: This could also fix one of the issues in #3 !

its_working_star_wars

Made the above change to settingsManager.js, started the debug branch app, opened iTunes, and started playing a song. Works as expected, now!

This does resolve issue #3 as well! Themes change now and I can change between the pywal and default colorschemes. Regenerating a pywal theme while snwe is open no longer results in snwe disappearing.

Thank you! You're one of the best devs I've helped debug software for :+)

One more thing I noticed:

error

It seems like there are errors thrown when certain osascript functions are executed? I register these errors in the preference window debugging window but not in the main interface window. The first error refers to the function in settingsManager.js that creates a symlink to the pywal-generated CSS file and the second error is the script in itunes.js that checks if iTunes is playing and, if it is, to get the artist and track name. The second errorr is mirrored when changing the Player option to Spotify since there are similar scripts in spotify.js.

So far as I know, the functions run just fine since everything appears to be working well. I'm not sure why those errors are there.

It seems like there are errors thrown when certain osascript functions are executed?

Luckily these were just electron quirks; the function was accessible, but was declared in some other file, so the program thought it wasn't declared, but it ended up being so โ€“ hence error called, but execution fine. However I'm happy to have gotten those out of the way โ€“ would have probably popped up while I was trying to debug something else and be a nuisance.

Made the above change to settingsManager.js, started the debug branch app, opened iTunes, and started playing a song. Works as expected, now!

Good.

This does resolve issue #3 as well! Themes change now and I can change between the pywal and default colorschemes. Regenerating a pywal theme while snwe is open no longer results in snwe disappearing.

Great!!

Thank you! You're one of the best devs I've helped debug software for :+)

Fucking fantastic :D

Also +1 for the use of that specific gif