From 1689a6208b825677446fc6b9380c3ac6d597eb8a Mon Sep 17 00:00:00 2001 From: raziman Date: Fri, 25 Sep 2020 17:41:58 +0800 Subject: [PATCH] make history path configurable instead of hard-coded --- playlist.go | 2 +- start.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/playlist.go b/playlist.go index 814e665..bd48ae5 100644 --- a/playlist.go +++ b/playlist.go @@ -626,7 +626,7 @@ func ytdl(url string, selPlaylist *tview.TreeNode) error { playlistPath := path.Join(expandTilde(dir), selPlaylistName) audioPath := extractFilePath(stdout.Bytes(), playlistPath) - err = appendFile(expandTilde("~/.local/share/gomu/urls"), url+"\n") + err = appendFile(expandTilde(viper.GetString("general.history_path")), url+"\n") if err != nil { return tracerr.Wrap(err) } diff --git a/start.go b/start.go index 35ca49d..f7ae1eb 100644 --- a/start.go +++ b/start.go @@ -29,8 +29,9 @@ type Panel interface { } const ( - CONFIG_PATH = ".config/gomu/config" - MUSIC_PATH = "~/music" + CONFIG_PATH = ".config/gomu/config" + HISTORY_PATH = "~/.local/share/gomu/urls" + MUSIC_PATH = "~/music" ) // Reads config file and sets the options @@ -44,6 +45,8 @@ general: load_prev_queue: true # change this to directory that contains mp3 files music_dir: ~/music + # url history of downloaded audio will be saved here + history_path: ~/.local/share/gomu/urls popup_timeout: 5s # initial volume when gomu starts up volume: 100 @@ -99,6 +102,7 @@ emoji: // General config viper.SetDefault("general.music_dir", MUSIC_PATH) + viper.SetDefault("general.history_path", HISTORY_PATH) viper.SetDefault("general.confirm_on_exit", true) viper.SetDefault("general.confirm_bulk_add", true) viper.SetDefault("general.popup_timeout", "5s")