From c449b34d54519cab2b899b657e8dabe7f0641d41 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 24 Mar 2022 16:13:22 +0100 Subject: Learning in progress --- src/c_player.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/c_player.go') 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) + } } -- cgit v1.2.3