1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-07 19:59:14 -04:00

fix(windowrules): honor $XDG_CONFIG_HOME for config paths

- Window rule read/write/includes detection and setup hardcoded
`$HOME/.config` so rules weren't applied when `XDG_CONFIG_HOME` pointed
elsewhere.
- Fixes #2289
This commit is contained in:
purian23
2026-06-03 19:01:25 -04:00
parent 82d4364032
commit 6f387b0481
3 changed files with 10 additions and 30 deletions
+3 -12
View File
@@ -87,10 +87,7 @@ func runResolveInclude(cmd *cobra.Command, args []string) {
} }
func checkHyprlandInclude(filename string) (IncludeResult, error) { func checkHyprlandInclude(filename string) (IncludeResult, error) {
configDir, err := utils.ExpandPath("$HOME/.config/hypr") configDir := filepath.Join(utils.XDGConfigHome(), "hypr")
if err != nil {
return IncludeResult{}, err
}
targetPath := filepath.Join(configDir, "dms", filename) targetPath := filepath.Join(configDir, "dms", filename)
result := IncludeResult{} result := IncludeResult{}
@@ -191,10 +188,7 @@ func hyprlandFindIncludeHyprlang(filePath, target string, processed map[string]b
} }
func checkNiriInclude(filename string) (IncludeResult, error) { func checkNiriInclude(filename string) (IncludeResult, error) {
configDir, err := utils.ExpandPath("$HOME/.config/niri") configDir := filepath.Join(utils.XDGConfigHome(), "niri")
if err != nil {
return IncludeResult{}, err
}
targetPath := filepath.Join(configDir, "dms", filename) targetPath := filepath.Join(configDir, "dms", filename)
result := IncludeResult{} result := IncludeResult{}
@@ -270,10 +264,7 @@ func niriFindInclude(filePath, target string, processed map[string]bool) bool {
} }
func checkMangoWCInclude(filename string) (IncludeResult, error) { func checkMangoWCInclude(filename string) (IncludeResult, error) {
configDir, err := utils.ExpandPath("$HOME/.config/mango") configDir := filepath.Join(utils.XDGConfigHome(), "mango")
if err != nil {
return IncludeResult{}, err
}
targetPath := filepath.Join(configDir, "dms", filename) targetPath := filepath.Join(configDir, "dms", filename)
result := IncludeResult{} result := IncludeResult{}
+2 -2
View File
@@ -235,9 +235,9 @@ func runSetupDmsConfig(name string) error {
var dmsDir string var dmsDir string
switch compositor { switch compositor {
case "niri": case "niri":
dmsDir = filepath.Join(os.Getenv("HOME"), ".config", "niri", "dms") dmsDir = filepath.Join(utils.XDGConfigHome(), "niri", "dms")
case "hyprland": case "hyprland":
dmsDir = filepath.Join(os.Getenv("HOME"), ".config", "hypr", "dms") dmsDir = filepath.Join(utils.XDGConfigHome(), "hypr", "dms")
} }
if err := os.MkdirAll(dmsDir, 0o755); err != nil { if err := os.MkdirAll(dmsDir, 0o755); err != nil {
+5 -16
View File
@@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"os" "os"
"path/filepath"
"strings" "strings"
"time" "time"
@@ -146,10 +147,7 @@ func runWindowrulesList(cmd *cobra.Command, args []string) {
switch compositor { switch compositor {
case "niri": case "niri":
configDir, err := utils.ExpandPath("$HOME/.config/niri") configDir := filepath.Join(utils.XDGConfigHome(), "niri")
if err != nil {
log.Fatalf("Failed to expand niri config path: %v", err)
}
parseResult, err := providers.ParseNiriWindowRules(configDir) parseResult, err := providers.ParseNiriWindowRules(configDir)
if err != nil { if err != nil {
@@ -182,10 +180,7 @@ func runWindowrulesList(cmd *cobra.Command, args []string) {
result.DMSStatus = parseResult.DMSStatus result.DMSStatus = parseResult.DMSStatus
case "hyprland": case "hyprland":
configDir, err := utils.ExpandPath("$HOME/.config/hypr") configDir := filepath.Join(utils.XDGConfigHome(), "hypr")
if err != nil {
log.Fatalf("Failed to expand hyprland config path: %v", err)
}
parseResult, err := providers.ParseHyprlandWindowRules(configDir) parseResult, err := providers.ParseHyprlandWindowRules(configDir)
if err != nil { if err != nil {
@@ -315,16 +310,10 @@ func runWindowrulesReorder(cmd *cobra.Command, args []string) {
func getWindowRulesProvider(compositor string) windowrules.WritableProvider { func getWindowRulesProvider(compositor string) windowrules.WritableProvider {
switch compositor { switch compositor {
case "niri": case "niri":
configDir, err := utils.ExpandPath("$HOME/.config/niri") configDir := filepath.Join(utils.XDGConfigHome(), "niri")
if err != nil {
return nil
}
return providers.NewNiriWritableProvider(configDir) return providers.NewNiriWritableProvider(configDir)
case "hyprland": case "hyprland":
configDir, err := utils.ExpandPath("$HOME/.config/hypr") configDir := filepath.Join(utils.XDGConfigHome(), "hypr")
if err != nil {
return nil
}
return providers.NewHyprlandWritableProvider(configDir) return providers.NewHyprlandWritableProvider(configDir)
default: default:
return nil return nil