[PATCH] Support macOS configuration directory

[PATCH] Support macOS configuration directory

From: Nicholas FitzRoy-Dale
---
 src/config.go | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/config.go b/src/config.go
index 8f931ae..c8eae28 100644
--- a/src/config.go
+++ b/src/config.go
@@ -69,6 +69,16 @@ func getConfigFilePath() (string, error) {
 		path = filepath.Join(appdata, "Termsonic")
 		os.MkdirAll(path, os.ModeDir.Perm())
 
+		path = filepath.Join(path, "termsonic.toml")
+	} else if runtime.GOOS == "darwin" {
+		home := os.Getenv("HOME")
+		if home == "" {
+			return "", fmt.Errorf("could not get home directory")
+		}
+
+		path = filepath.Join(home, "Library", "Application Support", "Termsonic")
+		os.MkdirAll(path, os.ModeDir.Perm() | 0700)
+
 		path = filepath.Join(path, "termsonic.toml")
 	} else {
 		return "", fmt.Errorf("unsupported operating system: %s", runtime.GOOS)
-- 
2.44.0

Re: [PATCH] Support macOS configuration directory

From: Simon Garrelou
Hi Nicholas!

Thanks a lot for the patch. I've merged it into main [1] :-)

Have you managed to test termsonic under macOS? Does building it require 
special dependencies?
I'd really like your feedback, as I don't really have access to a macOS 
machine to test at the moment.

Have a nice day,
Simon

[1]: 
https://git.sixfoisneuf.fr/termsonic/commit/?id=c44247ccc39c0ce42473abcc379fb33c2d1151f4

Re: [PATCH] Support macOS configuration directory

From: Nicholas FitzRoy-Dale
Hi Simon,

Great, thanks!

I built termsonic on an up-to-date Apple Silicon laptop. Very impressively it all builds fine with no special requirements beyond the config location patch. The F1…F4 keys aren’t recognised, but I suspect my terminal or keyboard setup is to blame there (as a workaround the mouse works). I enjoyed using it; very fast and responsive.

Unfortunately though a lot of my library is in AAC format, which Beep doesn’t support. Adding support in Beep seems like either wrapping libfdk-aac or writing a from-scratch Go implementation. Both seem troublesome, but I’ll try to make some time to have a look!

Have a good day / evening yourself,

Nicholas


> On 24 Apr 2024, at 20:36, Simon Garrelou <simon@sixfoisneuf.fr> wrote:
> 
> Hi Nicholas!
> 
> Thanks a lot for the patch. I've merged it into main [1] :-)
> 
> Have you managed to test termsonic under macOS? Does building it require special dependencies?
> I'd really like your feedback, as I don't really have access to a macOS machine to test at the moment.
> 
> Have a nice day,
> Simon
> 
> [1]: https://git.sixfoisneuf.fr/termsonic/commit/?id=c44247ccc39c0ce42473abcc379fb33c2d1151f4
>