diff --git a/colors.go b/colors.go index f531e77..04871ae 100644 --- a/colors.go +++ b/colors.go @@ -17,12 +17,12 @@ type Colors struct { func newColor() *Colors { defaultColors := map[string]string{ - "color_accent": "#008B8B", - "color_foreground": "#FFFFFF", - "color_background": "none", - "color_popup": "#0A0F14", - "color_now_playing_title": "#017702", - "color_playlist": "#008B8B", + "Color.accent": "#008B8B", + "Color.foreground": "#FFFFFF", + "Color.background": "none", + "Color.popup": "#0A0F14", + "Color.now_playing_title": "#017702", + "Color.playlist": "#008B8B", } anko := gomu.anko @@ -42,7 +42,7 @@ func newColor() *Colors { // handle none background color var bgColor tcell.Color - bg := anko.GetString("color_background") + bg := anko.GetString("Color.background") if bg == "none" { bgColor = tcell.ColorDefault @@ -50,11 +50,11 @@ func newColor() *Colors { bgColor = tcell.GetColor(bg) } - accent := anko.GetString("color_accent") - foreground := anko.GetString("color_foreground") - popup := anko.GetString("color_popup") - title := anko.GetString("color_now_playing_title") - playlist := anko.GetString("color_playlist") + accent := anko.GetString("Color.accent") + foreground := anko.GetString("Color.foreground") + popup := anko.GetString("Color.popup") + title := anko.GetString("Color.now_playing_title") + playlist := anko.GetString("Color.playlist") color := &Colors{ accent: tcell.GetColor(accent), diff --git a/command.go b/command.go index 73123f6..f8e1140 100644 --- a/command.go +++ b/command.go @@ -205,7 +205,7 @@ func (c Command) defineCommands() { c.define("bulk_add", func() { currNode := gomu.playlist.GetCurrentNode() - bulkAdd := anko.GetBool("confirm_bulk_add") + bulkAdd := anko.GetBool("General.confirm_bulk_add") if !bulkAdd { gomu.playlist.addAllToQueue(currNode) @@ -331,7 +331,7 @@ func (c Command) defineCommands() { /* Global */ c.define("quit", func() { - confirmOnExit := anko.GetBool("confirm_on_exit") + confirmOnExit := anko.GetBool("General.confirm_on_exit") if !confirmOnExit { err := gomu.quit(gomu.args) diff --git a/player.go b/player.go index 11a4860..16fdff0 100644 --- a/player.go +++ b/player.go @@ -37,7 +37,7 @@ type Player struct { func newPlayer() *Player { - volume := gomu.anko.GetInt("volume") + volume := gomu.anko.GetInt("General.volume") // Read initial volume from config initVol := absVolume(volume) diff --git a/playlist.go b/playlist.go index 2643621..9b87ab9 100644 --- a/playlist.go +++ b/playlist.go @@ -74,7 +74,7 @@ func newPlaylist(args Args) *Playlist { anko := gomu.anko - m := anko.GetString("music_dir") + m := anko.GetString("General.music_dir") rootDir, err := filepath.Abs(expandTilde(m)) if err != nil { err = tracerr.Errorf("unable to find music directory: %e", err) @@ -88,11 +88,11 @@ func newPlaylist(args Args) *Playlist { var rootTextView string - useEmoji := anko.GetBool("use_emoji") + useEmoji := anko.GetBool("General.use_emoji") if useEmoji { - emojiPlaylist := anko.GetString("emoji_playlist") + emojiPlaylist := anko.GetString("Emoji.playlist") rootTextView = fmt.Sprintf("%s %s", emojiPlaylist, path.Base(rootDir)) } else { @@ -581,7 +581,7 @@ func ytdl(url string, selPlaylist *tview.TreeNode) error { playlistPath := dir audioPath := extractFilePath(stdout.Bytes(), playlistPath) - historyPath := gomu.anko.GetString("history_path") + historyPath := gomu.anko.GetString("General.history_path") err = appendFile(expandTilde(historyPath), url+"\n") if err != nil { @@ -738,12 +738,12 @@ func (p *Playlist) paste() error { } func setDisplayText(songName string) string { - useEmoji := gomu.anko.GetBool("use_emoji") + useEmoji := gomu.anko.GetBool("General.use_emoji") if !useEmoji { return songName } - emojiFile := gomu.anko.GetString("emoji_file") + emojiFile := gomu.anko.GetString("Emoji.file") return fmt.Sprintf(" %s %s", emojiFile, songName) } diff --git a/popup.go b/popup.go index 9a0d2a3..d8bb351 100644 --- a/popup.go +++ b/popup.go @@ -67,7 +67,7 @@ func (s *Stack) pop() tview.Primitive { // Gets popup timeout from config file func getPopupTimeout() time.Duration { - dur := gomu.anko.GetString("popup_timeout") + dur := gomu.anko.GetString("General.popup_timeout") m, err := time.ParseDuration(dur) if err != nil { diff --git a/queue.go b/queue.go index 54b6b78..5a995f4 100644 --- a/queue.go +++ b/queue.go @@ -97,17 +97,17 @@ func (q *Queue) updateTitle() string { var loop string - isEmoji := gomu.anko.GetBool("use_emoji") + isEmoji := gomu.anko.GetBool("General.use_emoji") if q.isLoop { if isEmoji { - loop = gomu.anko.GetString("emoji_loop") + loop = gomu.anko.GetString("Emoji.loop") } else { loop = "Loop" } } else { if isEmoji { - loop = gomu.anko.GetString("emoji_noloop") + loop = gomu.anko.GetString("Emoji.noloop") } else { loop = "No loop" } diff --git a/search.go b/search.go index 888a4f6..a190531 100644 --- a/search.go +++ b/search.go @@ -86,7 +86,7 @@ func getRequest(url string, v interface{}) error { func getSearchResult(query string) ([]YoutubeVideo, error) { query = url.QueryEscape(query) - domain := gomu.anko.GetString("invidious_instance") + domain := gomu.anko.GetString("General.invidious_instance") targetUrl := domain + `/api/v1/search?q=` + query yt := []YoutubeVideo{} diff --git a/start.go b/start.go index 6e09d9d..b06d848 100644 --- a/start.go +++ b/start.go @@ -68,43 +68,51 @@ func execConfig(config string) error { const defaultConfig = ` -// confirmation popup to add the whole playlist to the queue -confirm_bulk_add = true -confirm_on_exit = true -queue_loop = false -load_prev_queue = true -popup_timeout = "5s" -// 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" -// some of the terminal supports unicode character -// you can set this to true to enable emojis -use_emoji = true -// initial volume when gomu starts up -volume = 80 -// if you experiencing error using this invidious instance, you can change it -// to another instance from this list: -// https://github.com/iv-org/documentation/blob/master/Invidious-Instances.md -invidious_instance = "https://vid.puffyan.us" +module General { + # confirmation popup to add the whole playlist to the queue + confirm_bulk_add = true + confirm_on_exit = true + queue_loop = false + load_prev_queue = true + popup_timeout = "5s" + # 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" + # some of the terminal supports unicode character + # you can set this to true to enable emojis + use_emoji = true + # initial volume when gomu starts up + volume = 80 + # if you experiencing error using this invidious instance, you can change it + # to another instance from this list: + # https://github.com/iv-org/documentation/blob/master/Invidious-Instances.md + invidious_instance = "https://vid.puffyan.us" +} -// default emoji here is using awesome-terminal-fonts -// you can change these to your liking -emoji_playlist = "" -emoji_file = "" -emoji_loop = "ﯩ" -emoji_noloop = "" +module Emoji { + # default emoji here is using awesome-terminal-fonts + # you can change these to your liking + playlist = "" + file = "" + loop = "ﯩ" + noloop = "" +} -// not all colors can be reproducible in terminal -// changing hex colors may or may not produce expected result -color_accent = "#008B8B" -color_background = "none" -color_foreground = "#FFFFFF" -color_now_playing_title = "#017702" -color_playlist = "#008B8B" -color_popup = "#0A0F14" +module Color { + # not all colors can be reproducible in terminal + # changing hex colors may or may not produce expected result + accent = "#008B8B" + background = "none" + foreground = "#FFFFFF" + now_playing_title = "#017702" + playlist = "#008B8B" + popup = "#0A0F14" +} -// vim: syntax=go +# you can get the syntax highlighting for this language here: +# https://github.com/mattn/anko/tree/master/misc/vim +# vim: ft=anko ` cfg := expandTilde(config) @@ -190,12 +198,12 @@ func start(application *tview.Application, args Args) { gomu.playingBar.setDefault() - isQueueLoop := gomu.anko.GetBool("queue_loop") + isQueueLoop := gomu.anko.GetBool("General.queue_loop") gomu.player.isLoop = isQueueLoop gomu.queue.isLoop = gomu.player.isLoop - loadQueue := gomu.anko.GetBool("load_prev_queue") + loadQueue := gomu.anko.GetBool("General.load_prev_queue") if !*args.empty && loadQueue { // load saved queue from previous session