diff options
author | Harvey Tindall <hrfee@protonmail.ch> | 2020-09-11 21:24:11 +0100 |
---|---|---|
committer | Harvey Tindall <hrfee@protonmail.ch> | 2020-09-11 21:24:11 +0100 |
commit | 018e3ce34ee573eefd8fdc6b9c536a0106bef724 (patch) | |
tree | 2744d90dd0b3f4df6146d766e541033c08c16f98 | |
parent | 8343e713fe29f2bbbb17ef9aedf2a506576b04a7 (diff) | |
download | waybar-mpris-018e3ce34ee573eefd8fdc6b9c536a0106bef724.tar.gz waybar-mpris-018e3ce34ee573eefd8fdc6b9c536a0106bef724.zip |
fix crash when tracklength not available
-rw-r--r-- | main.go | 9 | ||||
-rwxr-xr-x | waybar-mpris | bin | 973736 -> 973504 bytes |
2 files changed, 7 insertions, 2 deletions
@@ -157,7 +157,13 @@ func µsToString(µs int64) string { func (p *Player) Position() string { // position is in microseconds so we prob need int64 to be safe - l := p.metadata["mpris:length"].Value().(int64) + v := p.metadata["mpris:length"].Value() + var l int64 + if v != nil { + l = v.(int64) + } else { + return "" + } length := µsToString(l) if length == "" { return "" @@ -436,7 +442,6 @@ func main() { os.Remove(SOCK) os.Exit(1) }() - defer os.Remove(SOCK) if err != nil { log.Fatalln("Couldn't establish socket connection at", SOCK) } diff --git a/waybar-mpris b/waybar-mpris Binary files differindex 05bdd65..30f751b 100755 --- a/waybar-mpris +++ b/waybar-mpris |