1

I usually have music playing on my Mac while wearing earphones. And I often change the volume with my wired keyboard keys.

I imagine that it is an issue with the keyboard itself, but sometimes (rarely), when I increase the volume, despite the fact that I'm no longer pressing the keys, the volume still goes up to the max.

And of course, my earphones explode on me before I realise what's going on.

To solve this, rather than changing my volume-adjusting habits, I was wondering if there is some way to put a volume hard-limit in the system. Like, "whatever happens, don't let me go beyond 70%" or something.

OSX Mavericks.

1

I do not know about the "Hard limit" but you can use the

sudo osascript -e "set Volume 10" 

for max

or sudo osascript -e "set Volume 5" 

for mid range

and so on.

0

It’s 2019 and sadly this is still relevant.

I was using Konstantin Anoshkin’s (now extinct) background daemon and I ended creating one myself that solved some things I did not like.

The script uses AppleScript and Javascript to create a slightly more complex app that you can close and that shows a notification and emit a “bip” when you exceed your volume limit.

class Volimiter {
  constructor(appName, maxVolume) {
    this.app = Application.currentApplication();
    this.app.includeStandardAdditions = true;
    this.appName = appName;
    this.maxVolume = maxVolume;
  }

  get currentVolume() {
    const { outputVolume } = this.app.getVolumeSettings();
    return outputVolume;
  }

  limitVolume() {
    if (this.currentVolume > this.maxVolume) {
      this.app.beep();
      this.app.setVolume(null, { outputVolume: this.maxVolume });
    }
  }

  showNotification() {
    this.app.displayNotification("", {
      withTitle: this.appName,
      subtitle: `Limiting your 🎧 volume to ${
        this.maxVolume
      }% to protect your ears`
    });
  }
}

const PurrfectVolume = new Volimiter("Purrfect volume 😸", 25);
PurrfectVolume.showNotification();

function idle() {
  PurrfectVolume.limitVolume();
  return 0.5;
}
´´´

You can set your desired maximum volume on the second parameter of Volimiter, on line 27. Just play with what it feels right.

To be able to go over the volume limit (i.e. you switch to speakers and want to watch a movie) you can quit the script/app from your task manager.

I wrote everything about it in this in [this blog post](https://medium.com/trabe/limiting-your-macs-volume-in-2019-f314e20408ab). You can ask as many questions as you like to adapt it to your needs.

I hope it helps people with this problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .