@@ 6,6 6,7 @@ import (
"io/ioutil"
"os"
"os/exec"
+ "path/filepath"
"strconv"
"strings"
@@ 57,13 58,30 @@ var runCommand = &cli.Command{
},
},
Action: func(ctx *cli.Context) error {
- args := append(ctx.Args().Slice(),
- fmt.Sprintf("--input-ipc-server=%s", ctx.String("socket")),
- "--idle",
- )
+ var args []string
+ // use anything after -- as mpv args
+ // putting it here means anything we set overwrites
+ args = ctx.Args().Slice()
+ // try loading args from a file
+ xdgdir, err := os.UserConfigDir()
+ if err == nil {
+ data, err := ioutil.ReadFile(filepath.Join(xdgdir, "xap", "default-mpv-flags"))
+ if err == nil {
+ content := string(data)
+ // trim away the final newline
+ content = strings.TrimRight(content, "\n")
+ args = append(args, strings.Split(content, "\n")...)
+ }
+ }
+ // some nice defaults
if !ctx.Bool("no-defaults") {
args = append(args, defaultMpvFlags...)
}
+ // mandatory args for xap to work
+ args = append(args,
+ fmt.Sprintf("--input-ipc-server=%s", ctx.String("socket")),
+ "--idle",
+ )
pid, err := ioutil.ReadFile(pidFile)
if err == nil {