preset/hyprland profile: use HyprlandManager

parent a959dad7
......@@ -106,10 +106,10 @@ func handleReleaseReplace(src, dest, sysVer string, opts opOptions) string {
return fmt.Sprintf("Обновлён: %s (%s → %s)", dest, fileVer, sysVer)
}
func processHyprVars(prof config.PresetProfile, opts opOptions, res *config.PresetResult) {
func processHyprVars(manager *hyprland.HyprlandManager, prof config.PresetProfile, opts opOptions, res *config.PresetResult) {
for _, v := range prof.Hyprland.Vars {
if !v.Force {
if _, err := hyprland.HyprlandVarGet(v.Var); err == nil {
if V := manager.GetVar(v.Var); V != "" {
res.HyprVars = append(res.HyprVars,
fmt.Sprintf("Уже существует: '%s' — пропущено", v.Var))
continue
......@@ -122,7 +122,7 @@ func processHyprVars(prof config.PresetProfile, opts opOptions, res *config.Pres
continue
}
if _, err := hyprland.HyprlandVarSet(v.Var, v.Value); err != nil {
if _, err := manager.SetVar(v.Var, v.Value); err != nil {
res.HyprVars = append(res.HyprVars,
fmt.Sprintf("Ошибка установки %s: %v", v.Var, err))
} else {
......@@ -132,7 +132,7 @@ func processHyprVars(prof config.PresetProfile, opts opOptions, res *config.Pres
}
}
func processHyprModules(prof config.PresetProfile, opts opOptions, res *config.PresetResult) {
func processHyprModules(manager *hyprland.HyprlandManager, prof config.PresetProfile, opts opOptions, res *config.PresetResult) {
for _, m := range prof.Hyprland.Modules {
if m.Module == "" {
......@@ -174,7 +174,7 @@ func processHyprModules(prof config.PresetProfile, opts opOptions, res *config.P
}
if m.Init && m.User && m.Action == "enable" {
modulefile := hyprland.HyprlandGetModuleFile(m.Module, m.User)
modulefile := manager.GetModuleFile(m.Module, m.User)
if _, err := os.Stat(modulefile); os.IsNotExist(err) {
if opts.DryRun {
......@@ -203,7 +203,7 @@ func processHyprModules(prof config.PresetProfile, opts opOptions, res *config.P
continue
}
if _, err := hyprland.HyprlandSetModule(
if _, err := manager.SetModule(
m.Action,
m.Module,
m.User,
......@@ -226,7 +226,7 @@ func processHyprModules(prof config.PresetProfile, opts opOptions, res *config.P
}
}
func processHyprLayoutSync(prof config.PresetProfile, opts opOptions, res *config.PresetResult) {
func processHyprLayoutSync(manager *hyprland.HyprlandManager, prof config.PresetProfile, opts opOptions, res *config.PresetResult) {
if !prof.Hyprland.Option.SyncSystemLayouts {
return
}
......@@ -244,12 +244,7 @@ func processHyprLayoutSync(prof config.PresetProfile, opts opOptions, res *confi
return
}
hyprLayouts, err := hyprland.HyprlandVarGet("kb_layout")
if err != nil {
res.SyncSystemLayouts = append(res.SyncSystemLayouts,
"Не удалось получить раскладки Hyprland")
return
}
hyprLayouts := manager.GetVar("kb_layout")
if hyprLayouts == "" {
hyprLayouts = "<empty>"
......@@ -261,7 +256,7 @@ func processHyprLayoutSync(prof config.PresetProfile, opts opOptions, res *confi
fmt.Sprintf("Раскладка Hyprland: %s", hyprLayouts))
if hyprLayouts == "<empty>" {
if _, err := hyprland.HyprlandVarSet("kb_layout", sysLayouts); err != nil {
if _, err := manager.SetVar("kb_layout", sysLayouts); err != nil {
res.SyncSystemLayouts = append(res.SyncSystemLayouts,
"Не удалось обновить kb_layout")
return
......@@ -305,9 +300,13 @@ func processProfile(prof config.PresetProfile, dryRun bool, res *config.PresetRe
if config.Env.IsRoot {
processSystemGrub(prof, opts, res)
}
processHyprVars(prof, opts, res)
processHyprModules(prof, opts, res)
processHyprLayoutSync(prof, opts, res)
manager, err := hyprland.NewHyprlandManager()
if err != nil {
return
}
processHyprVars(manager, prof, opts, res)
processHyprModules(manager, prof, opts, res)
processHyprLayoutSync(manager, prof, opts, res)
}
func createProfile(profileName string, prof config.PresetProfile, dryRun bool, res *config.PresetResult) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment