Files
purian23 39b0d40877 mango: bring up newly supported config dialects, systemd sessions & setups
- Auto detect the snake_case dialect of Mango master from the binary, write configs and respell existing fragments with:
 `dms config mango-migrate`
- Setup backs up and replaces config.conf, moves binds and rules into dms/
- Start DMS from mango-session.target with systemd or exec-once without
- fix cheatsheet run action and bind precedence, window-rule and display save updates
- Support urgent active tag, greeter loading  /etc/mango, per-screen overviews
2026-10-08 20:50:53 -04:00

54 lines
1.5 KiB
Go

package mangoconf
import (
"os"
"os/exec"
"path/filepath"
"strings"
)
// Dir is the only config directory Mango reads; it ignores XDG_CONFIG_HOME.
func Dir() string {
return filepath.Join(os.Getenv("HOME"), ".config", "mango")
}
const SessionTarget = "mango-session.target"
// Headers setup puts on a binds.conf that holds the user's binds; the keybind editor never rebuilds such a file.
const (
BindsMovedHeader = "# Moved from config.conf by dms setup"
BindsKeptHeader = "# Kept by dms setup"
)
func HasUserBindsHeader(content string) bool {
return strings.Contains(content, BindsMovedHeader) || strings.Contains(content, BindsKeptHeader)
}
var unitDirs = []string{
"/etc/systemd/user",
"/usr/local/lib/systemd/user",
"/usr/lib/systemd/user",
"/lib/systemd/user",
"/run/current-system/sw/lib/systemd/user",
}
// SessionTargetInstalled reports whether this Mango ships mango-session.target,
// which Mango >= 0.17.1 starts itself after importing its environment into systemd.
func SessionTargetInstalled() bool {
if _, err := exec.LookPath("systemctl"); err != nil {
return false
}
dirs := append([]string{filepath.Join(os.Getenv("HOME"), ".config", "systemd", "user")}, unitDirs...)
for _, dir := range dirs {
if _, err := os.Stat(filepath.Join(dir, SessionTarget)); err == nil {
return true
}
}
return false
}
// WantsLink is the add-wants symlink that starts dms.service with the Mango session.
func WantsLink() string {
return filepath.Join(os.Getenv("HOME"), ".config", "systemd", "user", SessionTarget+".wants", "dms.service")
}