diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2022-03-24 16:13:22 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2022-03-24 16:13:22 +0100 |
commit | c449b34d54519cab2b899b657e8dabe7f0641d41 (patch) | |
tree | d8de7d8480e2aed510c9c12a064119e7f203e220 | |
parent | Learning in progress (diff) | |
download | go2work-c449b34d54519cab2b899b657e8dabe7f0641d41.tar.gz go2work-c449b34d54519cab2b899b657e8dabe7f0641d41.tar.bz2 go2work-c449b34d54519cab2b899b657e8dabe7f0641d41.tar.xz go2work-c449b34d54519cab2b899b657e8dabe7f0641d41.tar.zst go2work-c449b34d54519cab2b899b657e8dabe7f0641d41.zip |
Learning in progress
-rw-r--r-- | src/c_go2work.go | 4 | ||||
-rw-r--r-- | src/c_player.go | 24 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/c_go2work.go b/src/c_go2work.go index 3b4e4a3..e985144 100644 --- a/src/c_go2work.go +++ b/src/c_go2work.go @@ -57,11 +57,11 @@ func main() { ticker := time.NewTicker(2 * time.Second) quit := make(chan struct{}) fmt.Println("Time is: " + t) - exec_player("mpv", "/home/jozan/mu/rock/grunge/nirvana/1993_in_utero/04_rape_me.flac") + exec_player(true, "mpv", "--no-video", "/home/jozan/mu/rock/grunge/nirvana/1993_in_utero/04_rape_me.flac") for { select { case <- ticker.C: - exec_player("mpv", "/home/jozan/mu/rock/grunge/nirvana/1993_in_utero/04_rape_me.flac") + exec_player(false, "mpv", "--no-video", "/home/jozan/mu/rock/grunge/nirvana/1993_in_utero/04_rape_me.flac") case <- quit: ticker.Stop() return diff --git a/src/c_player.go b/src/c_player.go index 399f90e..c9f804e 100644 --- a/src/c_player.go +++ b/src/c_player.go @@ -48,17 +48,25 @@ package main import ( + "bytes" "fmt" - // "log" + "log" "os/exec" ) -func exec_player(args ...string) { +func exec_player(show_fortune bool, args ...string) { + var cmd *exec.Cmd + if show_fortune == true { + cmd = exec.Command("fortune", "-s") + var out bytes.Buffer + cmd.Stdout = &out + cmd.Run() + fmt.Println(out.String()) + } fmt.Println("Playing: " + args[len(args) - 1]) - cmd := exec.Command(args) - // cmd := exec.Command("mpv", file) - // err := cmd.Run(); - // if err != nil { - // log.Fatal(err) - // } + cmd = exec.Command(args[0], append(args[1:])...) + err := cmd.Run(); + if err != nil { + log.Fatal(err) + } } |