make history path configurable instead of hard-coded

This commit is contained in:
raziman 2020-09-25 17:41:58 +08:00
parent db80ab25c7
commit 1689a6208b
2 changed files with 7 additions and 3 deletions

View File

@ -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)
}

View File

@ -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")