Skip to content

Instantly share code, notes, and snippets.

@bdavidhicks
Last active March 2, 2019 05:26
Show Gist options
  • Save bdavidhicks/cb0d6b74ad3296cfae501d15bd9991db to your computer and use it in GitHub Desktop.
Save bdavidhicks/cb0d6b74ad3296cfae501d15bd9991db to your computer and use it in GitHub Desktop.
systemd service configuration for user service to run on startup to unmute sound when Spotify notification occurs (i.e. when a song plays)
#!/bin/bash
interface=org.freedesktop.Notifications
member=Notify
dbus-monitor --profile "interface='$interface',member='$member',arg0='Spotify'" |
while read -r line; do
amixer -q -D pulse sset Master unmute;
done;
[Unit]
After=network.target
[Service]
ExecStart=/home/bhix/spotify_unmuter.sh
[Install]
WantedBy=default.target
@bdavidhicks
Copy link
Author

bdavidhicks commented Feb 9, 2019

  1. Save the file spotify_unmuter.sh in your home directory, i.e. /home/bhix
  2. Create the directory ~/.config/systemd/user/
  3. Save the file unmuter.service in the ~/.config/systemd/user/ directory
  4. Modify the file unmuter.service and change the path for ExecStart= to be the full path of your home directory, i.e. /home/YOUR_USER/spotify_unmuter.sh
  5. Run the command sudo chmod 744 ~/spotify_unmuter.sh to make it executable
  6. Run the command sudo chmod 664 ~/.config/systemd/user/unmuter.service to make it readable/writeable
  7. Run the command systemctl start --user unmuter.service to start the service.
  8. Run the command systemctl enable --user unmuter.service to enable it to start when the sytem starts.
  9. Restart your computer for the changes to take effect on next login
  10. Check that everything took by running systemctl --user status unmuter.service
    • You should see that it is active and can test by opening Spotify and muting your speakers and then begin playing a song or go to next song
    • The idea here is that when ads come on, you have to MANUALLY mute the sound, but then this service will unmute when a SONG comes on using the notification in Gnome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment