ignore playerctld
playerctld displays and controls other players, so including it is pointless.
This commit is contained in:
parent
623adf487e
commit
25f40dc9e0
12
main.go
12
main.go
@ -3,14 +3,15 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/godbus/dbus/v5"
|
|
||||||
flag "github.com/spf13/pflag"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/godbus/dbus/v5"
|
||||||
|
flag "github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
var knownPlayers = map[string]string{
|
var knownPlayers = map[string]string{
|
||||||
@ -225,7 +226,6 @@ func (ls List) Swap(i, j int) {
|
|||||||
ls[i], ls[j] = ls[j], ls[i]
|
ls[i], ls[j] = ls[j], ls[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Doesn't retain order since sorting if constantly done anyway
|
|
||||||
func (pl *PlayerList) Remove(fullName string) {
|
func (pl *PlayerList) Remove(fullName string) {
|
||||||
currentName := pl.list[pl.current].fullName
|
currentName := pl.list[pl.current].fullName
|
||||||
var i int
|
var i int
|
||||||
@ -265,7 +265,8 @@ func (pl *PlayerList) Reload() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, name := range buses {
|
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)
|
pl.New(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -401,7 +402,8 @@ func main() {
|
|||||||
case string:
|
case string:
|
||||||
var pid uint32
|
var pid uint32
|
||||||
conn.BusObject().Call("org.freedesktop.DBus.GetConnectionUnixProcessID", 0, name).Store(&pid)
|
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 {
|
if pid == 0 {
|
||||||
// fmt.Println("Removing", name)
|
// fmt.Println("Removing", name)
|
||||||
players.Remove(name)
|
players.Remove(name)
|
||||||
|
BIN
waybar-mpris
BIN
waybar-mpris
Binary file not shown.
Loading…
Reference in New Issue
Block a user