oh-my-posh: Spotify segment not working

Code of Conduct

  • I agree to follow this project’s Code of Conduct

What happened?

I’m trying to make Spotify segment to work. But nothing happens! It seems to load well, but a matching Window Title is not found. Spotify version: Spotify for Windows 1.1.81.604.gccacfc8c (Installed from Web, not Store (already tried with the Store version))

I made two scripts to get all process windows titles. One using C# and the other using Powershell itself. These are the string I got from the logs: C# version (Id, Name and MainWindowTitle, respectively): | Process Spotify | ID: 14620 | Window Title: Demon Hunter - Collapsing (feat. Björn "Speed" Strid)

Powershell version (Id, Name and MainWindowTitle, respectively): 14620 Spotify Demon Hunter - Collapsing (feat. Björn "Speed" Strid)

Theme

My custom theme URL

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Log output

oh-my-posh debug log:

Segments:
spotify(false) -  57 ms -

Logs:
2022/04/04 14:56:12 error: QueryWindowTitles
no matching window title found
2022/04/04 14:56:12 WindowTitle duration: 30.0003ms, args: ^(Spotify.*)|(.*\s-\s.*)$
2022/04/04 14:56:12 error: QueryWindowTitles
no matching window title found
2022/04/04 14:56:12 WindowTitle duration: 27.9637ms, args: ^(Spotify.*)
2022/04/04 14:56:12 debug: Pwd

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Yup, there’s no error message. Grasping for straws here as this is deep into the win32 API. @marechal-dev OK if I provide a custom build so we can see a crazy amount of logging? Wouldn’t want that for everyone 😃

@marechal-dev my man. That’s the issue. That error is localized 😂

@JanDeDobbeleer For me the spotify segment is working. But when Spotify is not running, I get following error output (on Windows, WSL is working fine):

oh-my-posh fatal error rendering spotify segment:runtime error: invalid memory address or nil pointer dereference

goroutine 11 [running]:
runtime/debug.Stack()
        /opt/hostedtoolcache/go/1.18.0/x64/src/runtime/debug/stack.go:24 +0x65
oh-my-posh/engine.(*Segment).renderText.func1()
        /home/runner/work/oh-my-posh/oh-my-posh/src/engine/segment.go:326 +0x58
panic({0x12f0b20, 0x1da5900})
        /opt/hostedtoolcache/go/1.18.0/x64/src/runtime/panic.go:838 +0x207
oh-my-posh/environment.queryWindowTitles({0x13906ab, 0xb}, {0x139bcec, 0x19})
        /home/runner/work/oh-my-posh/oh-my-posh/src/environment/windows_win32.go:113 +0xf6
oh-my-posh/environment.(*ShellEnvironment).QueryWindowTitles(0xc000280150, {0x13906ab, 0xb}, {0x139bcec, 0x19})
        /home/runner/work/oh-my-posh/oh-my-posh/src/environment/windows.go:75 +0x118
oh-my-posh/segments.(*Spotify).Enabled(0xc00040c3c0)
        /home/runner/work/oh-my-posh/oh-my-posh/src/segments/spotify_windows.go:12 +0x49
oh-my-posh/engine.(*Segment).renderText(0xc0002ae780, {0x14c01d0?, 0xc000280150?})
        /home/runner/work/oh-my-posh/oh-my-posh/src/engine/segment.go:335 +0xa2
oh-my-posh/engine.(*Block).renderSegmentsText.func1(0x0?)
        /home/runner/work/oh-my-posh/oh-my-posh/src/engine/block.go:88 +0x65
created by oh-my-posh/engine.(*Block).renderSegmentsText
        /home/runner/work/oh-my-posh/oh-my-posh/src/engine/block.go:86 +0x98

@marechal-dev the regex matches, so the title isn’t the issue here. I have no idea what just yet.

image