remove socket on exit; fix --position crash
This commit is contained in:
parent
6ed1eb428f
commit
8343e713fe
11
main.go
11
main.go
@ -8,6 +8,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -428,6 +429,14 @@ func main() {
|
|||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
listener, err := net.Listen("unix", SOCK)
|
listener, err := net.Listen("unix", SOCK)
|
||||||
|
c := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(c, os.Interrupt)
|
||||||
|
go func() {
|
||||||
|
<-c
|
||||||
|
os.Remove(SOCK)
|
||||||
|
os.Exit(1)
|
||||||
|
}()
|
||||||
|
defer os.Remove(SOCK)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("Couldn't establish socket connection at", SOCK)
|
log.Fatalln("Couldn't establish socket connection at", SOCK)
|
||||||
}
|
}
|
||||||
@ -504,10 +513,12 @@ func main() {
|
|||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
time.Sleep(1000 * time.Millisecond)
|
time.Sleep(1000 * time.Millisecond)
|
||||||
|
if len(players.list) != 0 {
|
||||||
if players.list[players.current].playing {
|
if players.list[players.current].playing {
|
||||||
go fmt.Println(players.JSON())
|
go fmt.Println(players.JSON())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
c := make(chan *dbus.Signal, 10)
|
c := make(chan *dbus.Signal, 10)
|
||||||
|
BIN
waybar-mpris
BIN
waybar-mpris
Binary file not shown.
Loading…
Reference in New Issue
Block a user