-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
70 lines (57 loc) · 1.27 KB
/
main.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"fmt"
"os"
"github.com/Pauloo27/tuner/album"
"github.com/Pauloo27/tuner/display"
"github.com/Pauloo27/tuner/img"
"github.com/Pauloo27/tuner/integrations"
"github.com/Pauloo27/tuner/keybind"
"github.com/Pauloo27/tuner/mode"
"github.com/Pauloo27/tuner/mpris"
"github.com/Pauloo27/tuner/player"
"github.com/Pauloo27/tuner/version"
)
const VERSION = "0.0.4-dev"
func exitWithInvalidUsage() {
fmt.Println("Invalid mode. Valid modes are:")
for mode := range modes {
fmt.Printf(" %s\n", mode)
}
os.Exit(-1)
}
var modes = map[string]mode.Mode{
"play": mode.PlayMode,
"p": mode.PlayMode,
"simple-play": mode.SimplePlayMode,
"sp": mode.SimplePlayMode,
"default": mode.DefaultMode,
}
func main() {
var mode string
if len(os.Args) == 1 {
mode = "default"
} else {
mode = os.Args[1]
}
selectedMode, ok := modes[mode]
if !ok {
exitWithInvalidUsage()
}
player.Initialize()
if player.State.Data.ShowInDiscord {
integrations.ConnectToDiscord()
}
// load mpv-mpris
mpris.LoadScript()
version.Migrate(VERSION)
if selectedMode.Displayed {
keybind.RegisterDefaultKeybinds()
display.RegisterHooks()
album.RegisterHooks()
if player.State.Data.FetchAlbum {
img.StartDaemon()
}
}
selectedMode.Handler()
}