2

I was wondering if there's a way to get the current song in Elementary OS from the volume menu item.

Screenshot of volume

So, is there a command I can use to get it, or detect when the song changes? I'm essentially trying to write a program that automatically runs a script whenever the song changes (or just updates occasionally) with my current song.

I'm using the Nuvola Player

2

The indicator is using the MPRIS dbus interface. So you could listen to dbus. For example something like this.

dbus-monitor --session "path=/org/mpris/MediaPlayer2" --monitor | awk '
  /string  *"xesam:artist/{
    while (1) {
      getline line
      if (line ~ /string "/){
        sub(/.*string "/, "artist:", line)
        sub(/".*$/, "", line)
        print line
        break
      }
    }
  }
  /string  *"xesam:title/{
    while (1) {
      getline line
      if (line ~ /string "/){
        sub(/.*string "/, "title:", line)
        sub(/".*$/, "", line)
        print line
        break
      }
    }
  }
'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.