Spotify - Volume control


I have try everything to create a command to control de volume only of spotify.

Yes it is true that i’m not a programer but … I can manage simple thing.

I copy this code that i have found :

tell application "System Events"
	set MyList to (name of every process)
end tell
if (MyList contains "Spotify") is true then
	tell application "Spotify"
	    set volcheck to get sound volume
	    set volcheck to volcheck + 10
	    set sound volume to volcheck
	end tell
end if

And i have try many other combination, look the web, command definition, etc …

To debug I found that i can use “SAY” so i add every where “say volcheck”

And i discover that volcheck is stuck with the same value. The only way to change it, is to pause and restart spotify. Now he get the new value. Others wise he get stuck with the first he had.

I get the same problem when the commande was very simple :

set sound volume to sound volume + 10

It move once and stuck there. but if i press pause/play it work a second time and stuck again.

any clue what i’m doing wrong?

1 Like

What is the range of possible volume values ?

Perhaps 10 is the maximum ?

Here the information for spotify specific classes :

application n [see also Standard Suite] : The Spotify application.
current track (track, r/o) : The current playing track.
sound volume (integer) : The sound output volume (0 = minimum, 100 = maximum)
player state (stopped/‌playing/‌paused, r/o) : Is Spotify stopped, paused, or playing?
player position (real) : The player’s position within the currently playing track in seconds.
repeating enabled (boolean, r/o) : Is repeating enabled in the current playback context?
repeating (boolean) : Is repeating on or off?
shuffling enabled (boolean, r/o) : Is shuffling enabled in the current playback context?
shuffling (boolean) : Is shuffling on or off?

Looks like that would need to be explored by someone with a Spotify account, I’m afraid.

I did spend a couple of minutes downloading the app, but probably because I have no account, it crashed when I ran this:

tell application "Spotify"
	set lngVol to sound volume
	set sound volume to 50
	set lngVol to sound volume
end tell

Perhaps a note to Spotify support ?

Hey Coolsaw,

It’s broken in the most recent Spotify.

Fortunately I had an old version I tested with first. Script 1 below worked.

I then updated to the most recent version of Spotify, and the 1st script broke.

tell application "Spotify"
  if it is running then
    set aSound to sound volume
    set sound volume to ((get sound volume) + 10)
    set sound volume to ((get sound volume) - 10)
    set bSound to sound volume
  end if
end tell

With the new version get sound volume fails.

You can still set an absolute sound value, but if you run script below you’ll see aSound and bSound are not correct even though the volume IS set.

tell application "Spotify"
  if it is running then
    set aSound to sound volume
    set sound volume to 70
    set bSound to sound volume
  end if
end tell

As @ComplexPoint says you should report this as a bug.


Ok thank. I will. Thanks all

I’m glad that for a newbie i did nothing wrong :blush:

here i did :

I didn’t find a special place to report this and when i read on spotify it was saying to go on stack for non programer. I poste it here :

but not sure it will do somthing

Spotify Contact Info

Thanks @ccstone

Here the new poste :

This Applescript works like a charm with the current Spotify version (2022)

Volume up:

tell application "Spotify"
	if the sound volume is not greater than 90 then
		set sound volume to ((sound volume) + 10)
		set sound volume to 100
	end if
end tell

Volume down:

tell application "Spotify"
	if the sound volume is greater than 9 then
		set sound volume to ((sound volume) - 10)
		set sound volume to 0
	end if
end tell

FWIW a variant allowing for a custom set of volume-level notches, e.g.

  • finer grained around your typical listening level
  • coarser grained at the extremes

A single function to cover increasing and decreasing volume (first argument true or false).

Second argument should be a list of integer volume levels. (in the sample below it's just a continuous list, at intervals of 5, between 0 and 100 – enumFromThenTo(0)(5)(1000) – but you could use any list that suits you better – the intervals can be varied.

  • To test in Script Editor, set the language selector at top left to JavaScript.
  • To assign to triggers in Keyboard Maestro, use Execute JavaScript for Automation actions.
Expand disclosure triangle to view JS source
(() => {
    "use strict";


    // RobTrew @2022
    // Ver 0.2

    const granularity = 5;

    const main = () =>

    // spotifyVolumeChanged :: Bool -> [Int] -> IO Int
    const spotifyVolumeChanged = increasing =>
        volumes => {
                spotify = Application("Spotify"),
                soundVolume = spotify.soundVolume(),
                nextPosition = volumes.findIndex(
                    x => soundVolume <= x
                ) + (increasing ? 1 : -1);

            return (
                nextVolume => (
                    spotify.soundVolume = nextVolume,
                nextPosition < 0
                    ? 0
                    : nextPosition >= volumes.length
                        ? 100
                        : volumes[nextPosition]

    // --------------------- GENERIC ---------------------

    // enumFromThenTo :: Int -> Int -> Int -> [Int]
    const enumFromThenTo = m =>
    // Integer values enumerated from m to n
    // with a step defined by (nxt - m).
        nxt => n => {
            const d = nxt - m;

            return Array.from({
                length: (Math.floor(n - nxt) / d) + 2
            }, (_, i) => m + (d * i));

    return main();

HI, I am a noob. Can you please post the entire keyboard maestro command, not just the apple script. TYSM