fix config lookups for windows
make config.go sensitive to the windows environment.
This commit is contained in:
parent
ea29c29531
commit
8c0e3a896d
33
README-CONFIGS.md
Normal file
33
README-CONFIGS.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# FOR WINDOWS USERS
|
||||||
|
|
||||||
|
## MPV
|
||||||
|
MPV insists on opening a GUI (or "pseudo-gui" as they call it) window, whether you like it or not.
|
||||||
|
So, here is the best mpv.conf I could come up with, under those
|
||||||
|
circumstances:
|
||||||
|
```ini
|
||||||
|
[default]
|
||||||
|
terminal=yes
|
||||||
|
audio-display=no
|
||||||
|
video=no
|
||||||
|
force-window=no
|
||||||
|
window-minimized=yes
|
||||||
|
idle=yes
|
||||||
|
```
|
||||||
|
The window will still be created, but at least, it will be minimized to the taskbar.
|
||||||
|
|
||||||
|
You should put this file in: `%USERPROFILE%\AppData\Roaming\mpv.net\mpv.conf`
|
||||||
|
|
||||||
|
## RADIOSTATIONS.INI
|
||||||
|
Make sure your `gostations.exe` is somewhere in your searchable %PATH%. Then, you should
|
||||||
|
only need to change the player.command option:
|
||||||
|
```ini
|
||||||
|
[DEFAULT]
|
||||||
|
radio_browser.api=all.api.radio-browser.info
|
||||||
|
player.command=mpvnet.exe
|
||||||
|
player.options=--no-video
|
||||||
|
menu_items.max=9999
|
||||||
|
```
|
||||||
|
|
||||||
|
# FOR EVERYONE ELSE
|
||||||
|
|
||||||
|
Continue as you are. The sane people don't need to do anything different.
|
@ -16,3 +16,6 @@ go mod tidy
|
|||||||
go build -o "$buildpath" -ldflags "-X main.version=$VERSION_STRING"
|
go build -o "$buildpath" -ldflags "-X main.version=$VERSION_STRING"
|
||||||
|
|
||||||
& $buildpath -v
|
& $buildpath -v
|
||||||
|
|
||||||
|
Copy-Item $buildpath $HOME/.local/bin -Force
|
||||||
|
|
||||||
|
10
config.go
10
config.go
@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/alyu/configparser"
|
"github.com/alyu/configparser"
|
||||||
@ -21,9 +22,18 @@ func str2int(strnum string) int {
|
|||||||
func configStat(configFile string) string {
|
func configStat(configFile string) string {
|
||||||
xdgConfigPath := os.Getenv("XDG_CONFIG_HOME")
|
xdgConfigPath := os.Getenv("XDG_CONFIG_HOME")
|
||||||
if xdgConfigPath == "" {
|
if xdgConfigPath == "" {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
xdgConfigPath = os.Getenv("USERPROFILE") + "\\.config"
|
||||||
|
} else {
|
||||||
xdgConfigPath = os.Getenv("HOME") + "/.config"
|
xdgConfigPath = os.Getenv("HOME") + "/.config"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
configFile = xdgConfigPath + "\\gostations\\" + configFile
|
||||||
|
} else {
|
||||||
configFile = xdgConfigPath + "/gostations/" + configFile
|
configFile = xdgConfigPath + "/gostations/" + configFile
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(configFile); errors.Is(err, os.ErrNotExist) {
|
if _, err := os.Stat(configFile); errors.Is(err, os.ErrNotExist) {
|
||||||
log.Printf("Your stations config file seems to be missing. A default will be generated.")
|
log.Printf("Your stations config file seems to be missing. A default will be generated.")
|
||||||
|
Loading…
Reference in New Issue
Block a user