diff options
author | Harvey Tindall <hrfee@protonmail.ch> | 2020-08-28 21:57:54 +0100 |
---|---|---|
committer | Harvey Tindall <hrfee@protonmail.ch> | 2020-08-28 21:57:54 +0100 |
commit | 3918d2f30eecac67cca806da7b2ebb21d8c18cfb (patch) | |
tree | 893e95594efe08ab73e711ee024cbc4cf9479936 | |
parent | 8fb822aa919e119f3e167faa4f7ce026cc917e1b (diff) | |
download | waybar-mpris-3918d2f30eecac67cca806da7b2ebb21d8c18cfb.tar.gz waybar-mpris-3918d2f30eecac67cca806da7b2ebb21d8c18cfb.zip |
ignore player-next/prev if only one player avavilable
stops the tooltip from flickering.
-rw-r--r-- | main.go | 30 | ||||
-rwxr-xr-x | waybar-mpris | bin | 953096 -> 953088 bytes |
2 files changed, 18 insertions, 12 deletions
@@ -418,21 +418,27 @@ func main() { } command := string(buf[0:nr]) if command == "player-next" { - if players.current < uint(len(players.list)-1) { - players.current += 1 - } else { - players.current = 0 + length := len(players.list) + if length != 1 { + if players.current < uint(length-1) { + players.current += 1 + } else { + players.current = 0 + } + players.Refresh() + fmt.Println(players.JSON()) } - players.Refresh() - fmt.Println(players.JSON()) } else if command == "player-prev" { - if players.current != 0 { - players.current -= 1 - } else { - players.current = uint(len(players.list) - 1) + length := len(players.list) + if length != 1 { + if players.current != 0 { + players.current -= 1 + } else { + players.current = uint(length - 1) + } + players.Refresh() + fmt.Println(players.JSON()) } - players.Refresh() - fmt.Println(players.JSON()) } else if command == "next" { players.Next() } else if command == "prev" { diff --git a/waybar-mpris b/waybar-mpris Binary files differindex 50df87b..69c4d88 100755 --- a/waybar-mpris +++ b/waybar-mpris |