mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-14 04:38:00 -08:00
fix: returns "" when spotify is not running + EnumWindows fix
returns "" when spotify is not running error check removed for EnumWindows In the end, the error is not very useful. Either we get a title or we get an empty string.
This commit is contained in:
parent
7cb752abcb
commit
b3618041cb
|
@ -40,6 +40,13 @@ func getWindowTitle(imageName, windowTitleRegex string) (string, error) {
|
|||
if err != nil {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// is a spotify process running?
|
||||
// no: returns an empty string
|
||||
if len(processPid) == 0 {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// returns the first window of the first pid
|
||||
_, windowTitle, err := GetWindowTitle(processPid[0], windowTitleRegex)
|
||||
if err != nil {
|
||||
|
@ -168,9 +175,6 @@ func GetWindowTitle(pid int, windowTitleRegex string) (syscall.Handle, string, e
|
|||
return 1 // continue enumeration
|
||||
})
|
||||
// Enumerates all top-level windows on the screen
|
||||
err = EnumWindows(cb, 0)
|
||||
if err != nil || hwnd == 0 {
|
||||
return 0, "", fmt.Errorf("No window with title '%b' found", pid)
|
||||
}
|
||||
_ = EnumWindows(cb, 0)
|
||||
return hwnd, title, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue