Oh-my-posh3: Spotify segment doesn't work on Windows

Created on 13 Nov 2020  路  14Comments  路  Source: JanDeDobbeleer/oh-my-posh3

Prerequisites

  • [x] I have read and understand the CONTRIBUTING guide
  • [x] I looked for duplicate issues before submitting this one

Description

The spotify-segment doesn't work on Windows, at least with Microsoft Store version. Not only that, but the segment also breaks oh-my-posh3 when Spotify-process is not running.

Environment

  • Oh my Posh version: 3.34.0 beta
  • Theme: jandedobbeleer (and custom theme)
  • Operating System: Windows 10 20H2
  • Shell: PowerShell 7.1
  • Terminal: Windows Temrinal 1.4.3141.0

Steps to Reproduce

  1. Install Spotify using Microsoft Store (haven't tested standalone version)
  2. Open PowerShell and set theme to jandedobbeleer
  3. Verify spotify icon shows stopped-icon
  4. Play song in spotify - should still show stopped-icon
  5. Close/exit spotify and write ex. cls
  6. Oh-my-posh prompt is gone. Only showing PS>

Expected behavior:
Song playing: Spotify segment should show song
Song stoppped: Spotify segment should show stopped icon
Spotify not running: Spotify segment should not be visible

Actual behavior:
Song playing: Spotify segment shows stopped icon
Song stoppped: Spotify segment shows stopped icon
Spotify not running: Oh-my-posh prompt missing

bug

All 14 comments

The broken prompt when spotify isn't running might be same as issue mentioned PR #152, but it doesn't mention song-detection bugfix. MS Store-version of Spotify also shows song in title, so the concept should work

@fflaten merged the bugfix, can you check when that release drops? Should be pretty fast.

Great. It fixed the crash (missing prompt) and song is detected. 馃憦

Would still like the Spotify-segment to be invisible when the process is not running. Currently shows stopped icon. New issue?

That's by design on Windows if I'm not mistaken.

What do you expect to see? I didn't write this myself, credit goes to @lnu

I'd expect it to be hidden when not applicable (no process running), just like git, python virtenv (iirc) etc.

I'd expect it to hidden when not applicable (no process running), just like git, python virtenv (iirc) etc.

That's how it works on MacOS. I'll adjust 馃憤馃徎

I fixed it in my pull request
Please note that on windows, we can get the title and artist only when playing. There is no paused status as in macOS. So stopped is basically the same as when Spotify is closed.

@fflaten @lnu merged 馃憤馃徎

What a quick response - thanks! Now it's hidden when spotify is closed 馃帀

I fixed it in my pull request
Please note that on windows, we can get the title and artist only when playing. There is no paused status as in macOS. So stopped is basically the same as when Spotify is closed.

That's correct, but we could still show stopped-icon. Did we go too far this time? Now paused/stopped song is no longer detected even though it is possible.

Stopped/paused can be identified by a spotify.exe process with a windowtitle that does not contain the track separator - (and/or matches "Spotify*")

# Paused/stopped
Get-Process spotify | ? MainWindowTitle | ft ProcessName, MainWindowTitle

ProcessName MainWindowTitle
----------- ---------------
Spotify     Spotify Premium

# Playing
Get-Process spotify | ? MainWindowTitle | ft ProcessName, MainWindowTitle

ProcessName MainWindowTitle
----------- ---------------
Spotify     Phlake - Angel Zoo

How is this in MacOS? I'd guess the paused/stopped stated is shown with an icon as well. Windows should be as similar as possible since this is cross-platform. In this case I'd expect a stopped-icon since we can't show the song during pause/stop anyway.

Sorry for being so picky 馃槃

MacOS gives the ability to get the track title when it's paused/stopped. That doesn't seem possible on Windows. We could however resort to only show the playing state everywhere and disable the segment in all other cases. Would make sense.

If a platform offers more capabilities like macos does, let鈥檚 keep it rather than going to the lowest common denominator?
What do you think?
And for info, on windows the track and artist is retrieved from the windows title. When paused, the windows title returns 芦聽Spotify premium聽禄. That鈥檚 why we cannot show the title and artist when the song is not playing.

rather than going to the lowest common denominator

Agreed. This way at least it's working as you'd expect. There's bound to be platform restrictions anyways. On MacOS the functionality is super slow, so there's that too 馃槵

I agree that MacOS should not be downgraded. It's the ideal scenario which other OSes should try to offer, as close as possible.

Closed vs stopped/paused is a useful distinction, so adding the stopped-icon on stop/pause is the best we can do on Windows - for now.

If you guys don't like it, then feel free to close the issue. The original bugs are solved 馃憤

The problem is there's no other info rather than a stopped icon which is rather sad (IMHO). Let's close this for now, if more people stumble upon this we'll revisit 馃槈

Was this page helpful?
0 / 5 - 0 ratings