-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCmusNotify.go
39 lines (31 loc) · 918 Bytes
/
CmusNotify.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Author: Sebastian Janko
// Mail: [email protected]
// Github link: https://github.com/sebojanko/CmusNotify
// License: GNU GPL v3
package main
import (
"fmt"
"os"
"os/exec"
"strings"
)
func displayNotification(data []string) {
displayData := strings.Join(data, "\n")
exec.Command("notify-send", "-i", "/", "CmusNotify", displayData).Run()
}
func main() {
var argsMap = make(map[string]interface{})
for i := 1; i < len(os.Args); i += 2 {
fmt.Println(os.Args[i])
fmt.Println(os.Args[i+1])
argsMap[os.Args[i]] = os.Args[i+1]
fmt.Println(argsMap)
}
if argsMap["status"] == "playing" {
var notificationData = make([]string, 3, 3)
notificationData[0] = "<b>Artist:</b> " + argsMap["artist"].(string)
notificationData[1] = "<b>Title:</b> " + argsMap["title"].(string)
notificationData[2] = "<b>Album:</b> " + argsMap["album"].(string)
displayNotification(notificationData)
}
}