diff options
| author | Harvey Tindall <hrfee@protonmail.ch> | 2020-09-06 13:13:36 +0100 | 
|---|---|---|
| committer | Harvey Tindall <hrfee@protonmail.ch> | 2020-09-06 13:13:36 +0100 | 
| commit | 8343e713fe29f2bbbb17ef9aedf2a506576b04a7 (patch) | |
| tree | 3af245a7f3f9084e425958d6879415d6631c1071 | |
| parent | 6ed1eb428f2941b6a5ea603781f6406c221a8087 (diff) | |
| download | waybar-mpris-8343e713fe29f2bbbb17ef9aedf2a506576b04a7.tar.gz waybar-mpris-8343e713fe29f2bbbb17ef9aedf2a506576b04a7.zip  | |
remove socket on exit; fix --position crash
| -rw-r--r-- | main.go | 15 | ||||
| -rwxr-xr-x | waybar-mpris | bin | 970148 -> 973736 bytes | 
2 files changed, 13 insertions, 2 deletions
@@ -8,6 +8,7 @@ import (  	"log"  	"net"  	"os" +	"os/signal"  	"sort"  	"strconv"  	"strings" @@ -428,6 +429,14 @@ func main() {  	}  	go func() {  		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 {  			log.Fatalln("Couldn't establish socket connection at", SOCK)  		} @@ -504,8 +513,10 @@ func main() {  		go func() {  			for {  				time.Sleep(1000 * time.Millisecond) -				if players.list[players.current].playing { -					go fmt.Println(players.JSON()) +				if len(players.list) != 0 { +					if players.list[players.current].playing { +						go fmt.Println(players.JSON()) +					}  				}  			}  		}() diff --git a/waybar-mpris b/waybar-mpris Binary files differindex c450ef3..05bdd65 100755 --- a/waybar-mpris +++ b/waybar-mpris  | 
