ref: 66dd5b18259ccfcbb1a3f77d843f575c217fa76b
parent: eeb17798b4624cdc32de8003ac1f937d7fc865c5
author: penny <penny@limitedideas.org>
date: Wed Oct 8 17:22:36 EDT 2025
cross compatible config location :)
--- a/config.go
+++ b/config.go
@@ -19,6 +19,7 @@
ImageViewer string `toml:"image_viewer" comment:"System image viewer command."`
MediaImport string `toml:"media_importer" comment:"Alternative media command used with /import"`
FilePicker string `toml:"file_picker" comment:"Graphical file picker (or otherwise)"`
+ MediaTag string `toml:"media_tag" comment:"text displayed to indicate a media attachment"`
}
type account_array struct {@@ -69,6 +70,11 @@
prefs.FilePicker = defaultprefs.FilePicker
fixed = true
}
+
+ if prefs.MediaTag == "" {+ prefs.MediaTag = defaultprefs.MediaTag
+ fixed = true
+ }
return prefs, fixed
}
@@ -80,6 +86,7 @@
ImageViewer: "xdg-open '%s'",
MediaImport: "xdg-open '%s'",
FilePicker: "zenity --file-selection",
+ MediaTag: "🖼️",
}
return *prefs
}
@@ -87,10 +94,10 @@
func loadConfig() (*mastodon_account, string, error) { config := &account_array{} first_account := &mastodon_account{}- homedir, err := os.UserHomeDir()
+ configdir, err := os.UserConfigDir()
var configpath string
if err == nil {- configpath = homedir + "/" + configFileName
+ configpath = configdir + "/" + configFileName
} else {//If go can't find us a home dir just use the current dir
//Probably not a normal multiuser system
@@ -161,6 +168,12 @@
}
func expandDir(dir string) string {- dir = strings.ReplaceAll(dir, "~", "$HOME")
+ homedir, err := os.UserHomeDir()
+ if err != nil {+ dir = strings.ReplaceAll(dir, "~", homedir)
+ } else {+ //We're not gonna bail but what is wrong with this install?
+ dir = strings.ReplaceAll(dir, "~", ".")
+ }
return os.ExpandEnv(dir)
}
--- a/renderer.go
+++ b/renderer.go
@@ -40,15 +40,16 @@
func (st *StatusFormatter) mediaDescriptions(reblog bool) string {var sb strings.Builder
status := st.status
+ mediaTag := st.hc.preferences.MediaTag
if reblog {status = status.Reblog
}
for _, item := range status.MediaAttachments { if item.Description != "" {- sb.WriteString(fmt.Sprintf("\n🖼️ [%s]", item.Description))+ sb.WriteString(fmt.Sprintf("\n%s [%s]", mediaTag, item.Description))continue
}
- sb.WriteString("🖼️")+ sb.WriteString(mediaTag)
}
return sb.String()
}
--
⑨