Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shortcuts for nextSong previousSong increaseVolume decreaseVolume… #1377

Merged
merged 2 commits into from
Dec 21, 2021

Conversation

InteractiveNinja
Copy link
Contributor

Code by @stankovictab Issue #1355

@khanhas
Copy link
Contributor

khanhas commented Dec 19, 2021

Do these default keyboard shortcuts actually not work on all Linux distros or just yours? Can I get some more input?
Also wrap them in a if condition checking OS, I'm sure on Windows and MacOS they work just fine.

@stankovictab
Copy link
Contributor

@khanhas That's right, they do work fine on Windows,
however I know from experience and from my friends that the shortcut doesn't work on Ubuntu, Kubuntu, Linux Mint or Manjaro.
It's been an active issue for a while now, you can see the issue here on the Spotify Community forum.
It appears to be the same on Mac, but I haven't experimented with it.
I'll add the OS check, it should work fine, but please correct it if it's wrong. 🙂

@stankovictab
Copy link
Contributor

This should do the trick.

function nextSong() {
	if (window.navigator.userAgent.indexOf("Win") == -1) // Works only on Linux and Mac
		document.querySelector(".main-skipForwardButton-button").click();
	}

function previousSong() {
	if (window.navigator.userAgent.indexOf("Win") == -1) // Works only on Linux and Mac
		document.querySelector(".main-skipBackButton-button").click();
	}

function increaseVolume() {
	if (window.navigator.userAgent.indexOf("Win") == -1) // Works only on Linux and Mac
		Spicetify.Player.origin.setVolume(Spicetify.Player.getVolume() + 0.1);
	}

function decreaseVolume() {
	if (window.navigator.userAgent.indexOf("Win") == -1) // Works only on Linux and Mac
		Spicetify.Player.origin.setVolume(Spicetify.Player.getVolume() - 0.1);
	}

@khanhas
Copy link
Contributor

khanhas commented Dec 20, 2021

Okay then.
But please wrap functions definitions and Spicetify.KeyboardShortcut calls in one if condition, not one of each in like stankovictab's code.
We don't need to add these shortcuts handler for Windows since they work out of the box.

@InteractiveNinja
Copy link
Contributor Author

Do we really need to also check the function definitions?

@khanhas khanhas merged commit cf6ce0e into spicetify:master Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants