aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go30
-rwxr-xr-xwaybar-mprisbin953096 -> 953088 bytes
2 files changed, 18 insertions, 12 deletions
diff --git a/main.go b/main.go
index 97064c0..10ada9e 100644
--- a/main.go
+++ b/main.go
@@ -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
index 50df87b..69c4d88 100755
--- a/waybar-mpris
+++ b/waybar-mpris
Binary files differ