MCPcopy Create free account
hub / github.com/efogdev/mpris-timer / main

Function main

cmd/main.go:15–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13)
14
15func main() {
16 stopProf := profile()
17 if stopProf != nil {
18 defer stopProf()
19 }
20
21 ctx, cancel := context.WithCancel(context.Background())
22 defer cancel()
23
24 glibDone := core.RegisterApp(ctx)
25 core.LoadPrefs()
26 core.LoadFlags()
27 go core.InitCache()
28
29 if core.Overrides.Sound {
30 go func() { _ = core.LoadSound() }()
31 }
32
33 if core.Overrides.UseUI && core.Overrides.Duration > 0 {
34 log.Fatalf("UI can't be used with -start")
35 }
36
37 // UI by default
38 if !core.Overrides.UseUI && core.Overrides.Duration == 0 {
39 core.Overrides.UseUI = true
40 }
41
42 if core.Overrides.UseUI {
43 log.Println("UI requested")
44 <-glibDone
45 ui.Init()
46 }
47
48 timer, err := core.NewTimerPlayer(core.Overrides.Duration, core.Overrides.Title)
49 if err != nil {
50 log.Fatalf("create timer: %v", err)
51 }
52
53 log.Printf("timer requested, duration = %d sec", core.Overrides.Duration)
54 if err = timer.Start(); err != nil {
55 log.Fatalf("start timer: %v", err)
56 }
57
58 if (!core.IsGnome && !core.IsPlasma) || core.Overrides.ForceTrayIcon {
59 go ui.CreateTrayIcon(timer)
60 }
61
62 sigChan := make(chan os.Signal, 1)
63 signal.Notify(sigChan, os.Interrupt)
64
65 select {
66 case <-timer.Done:
67 log.Println("timer done")
68 wg := sync.WaitGroup{}
69
70 if core.Overrides.Notify {
71 wg.Add(1)
72 log.Printf("notification requested")

Callers

nothing calls this directly

Calls 13

StartMethod · 0.95
DestroyMethod · 0.95
RegisterAppFunction · 0.92
LoadPrefsFunction · 0.92
LoadFlagsFunction · 0.92
InitCacheFunction · 0.92
LoadSoundFunction · 0.92
InitFunction · 0.92
NewTimerPlayerFunction · 0.92
CreateTrayIconFunction · 0.92
NotifyFunction · 0.92
PlaySoundFunction · 0.92

Tested by

no test coverage detected