diff options
author | Harvey Tindall <hrfee@protonmail.ch> | 2020-08-25 14:40:56 +0100 |
---|---|---|
committer | Harvey Tindall <hrfee@protonmail.ch> | 2020-08-25 14:40:56 +0100 |
commit | 25f40dc9e03d750e720ba594a06db0e0f51d2eac (patch) | |
tree | ee64d79a785c9b334796f80ee89156fd7fadb0cb | |
parent | 623adf487e56da10d9d0fbac914ab90cbdc68a1e (diff) | |
download | waybar-mpris-25f40dc9e03d750e720ba594a06db0e0f51d2eac.tar.gz waybar-mpris-25f40dc9e03d750e720ba594a06db0e0f51d2eac.zip |
ignore playerctld
playerctld displays and controls other players, so including it is
pointless.
-rw-r--r-- | main.go | 12 | ||||
-rwxr-xr-x | waybar-mpris | bin | 4473532 -> 4469436 bytes |
2 files changed, 7 insertions, 5 deletions
@@ -3,14 +3,15 @@ package main import ( "encoding/json" "fmt" - "github.com/godbus/dbus/v5" - flag "github.com/spf13/pflag" "io/ioutil" "log" "net" "os" "sort" "strings" + + "github.com/godbus/dbus/v5" + flag "github.com/spf13/pflag" ) var knownPlayers = map[string]string{ @@ -225,7 +226,6 @@ func (ls List) Swap(i, j int) { ls[i], ls[j] = ls[j], ls[i] } -// Doesn't retain order since sorting if constantly done anyway func (pl *PlayerList) Remove(fullName string) { currentName := pl.list[pl.current].fullName var i int @@ -265,7 +265,8 @@ func (pl *PlayerList) Reload() error { return err } for _, name := range buses { - if strings.HasPrefix(name, INTERFACE) { + // Don't add playerctld, it just duplicates other players + if strings.HasPrefix(name, INTERFACE) && !strings.Contains(name, "playerctld") { pl.New(name) } } @@ -401,7 +402,8 @@ func main() { case string: var pid uint32 conn.BusObject().Call("org.freedesktop.DBus.GetConnectionUnixProcessID", 0, name).Store(&pid) - if strings.Contains(name, INTERFACE) { + // Ignore playerctld again + if strings.Contains(name, INTERFACE) && !strings.Contains(name, "playerctld") { if pid == 0 { // fmt.Println("Removing", name) players.Remove(name) diff --git a/waybar-mpris b/waybar-mpris Binary files differindex 07e2232..05cdf8e 100755 --- a/waybar-mpris +++ b/waybar-mpris |