2

I have written a script that responds to a keyboard shortcut by, if it is not already open, execute the Spotify application.

If Spotify is already opened, the script uses xdotool to activate the window (bring it "to the front"). These work very well on their own -- but for one problem. If you "close" the Spotify window (hitting the X in the corner, for instance) the window goes away completely and is only accessible through the system tray. Spotify is still running, but xdotool cannot activate the window -- it does nothing.

How can I bring a "closed" Window to the front in this case? Is it just impossible because of the way Spotify is written? xdotool will actually return the window's ID properly even when it's closed.

I've tried the "windowmap" function and "windowmove 0 0", but neither effects any change, really.

EDIT: User muru suggests re-executing Spotify, in my case, which actually ends up mostly working, although it previously did not. It depends on how Spotify handles being re-opened. I'd love to hear of a generic solution if one exists.

  • 1
    What happens when you run Spotify again after minimizing to tray? Some applications reopen the window instead of starting a new one. Maybe Spotify does too. – muru Sep 4 '14 at 18:40
  • I ran into the same issue when I wrote a similar script a while ago. Didn't manage to find a generic solution (calling the executable, as pointed out by @muru, works for a few applications). Would love to see if there's a way to do this. – Glutanimate Sep 5 '14 at 14:21
  • Good call, muru. I tried that a few weeks ago and the already-open Spotify window WOULD successfully re-activate again, but with a big error at the top of the screen and, as well, the media buttons that I had set up not working. BUT it's worth saying that now when I try it, the error still shows, but my media buttons DO still work. So I guess that's acceptable for me. I'm going to revise the question, though, to ask for a generic solution. – Offlein Sep 5 '14 at 14:21
  • Just a thought, but is the (hidden?) window listed in the wmctrl -l output? If so, what does it say about size/location? If you have the id, what does xprop -id <id> say about the window? Oh, I see the question is old.... Is it still relevant? – Jacob Vlijm Mar 29 '15 at 9:35
1

In a remote-control script for example, I managed to 'raise' Clementine from tray via D-Bus:

qdbus org.mpris.clementine /org/mpris/MediaPlayer2 Raise

This should work similarly with Spotify, as it supports the D-Bus protocol. The corresponding command would be:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Raise

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.