···11+/*
22+Cover-viewer notifies and display album cover art.
33+This program is designed to be used with cmus.
44+55+Usage:
66+77+ cover-viewer --mode [visualizer|notify]
88+99+Flags:
1010+1111+ --mode [visualizer|notify]
1212+ Runs cover-viewer in visualizer or notify. In visualizer mode it displays the
1313+ album cover of the file read from the socket. In notify, reads cmus status line
1414+ from stdin and sends the file path to the socket.
1515+ --socket
1616+ Allows to change the location of the UNIX socket used to send and read the cmus
1717+ status line.
1818+*/
119package main
220321import (
···1432 "github.com/dhowden/tag"
1533)
16343535+// cmusKeys is the set of keys that could appear in the cmus status line.
1736var cmusKeys = map[string]bool{
1837 "status": true,
1938 "file": true,
···2544 "duration": true,
2645}
27464747+// lastPath indicates the path of the last file read to display the cover,
4848+// used to avoid read again the same file again.
2849var lastPath string
29503051func main() {
···110131 }
111132112133 showCover(path)
113113-114134 lastPath = path
115135}
116136137137+// parseCmusLine reads the status line from cmus and parse it to extract the path to
138138+// the file
117139func parseCmusLine(input string) map[string]string {
118140 parts := strings.Fields(input)
119141 result := make(map[string]string)
···199221 Height(features.WindowRows).
200222 Scale(termimg.ScaleFit).
201223 Print()
202202-203224}