hyprland/fix: create backup before restructuring config

parent dafc0694
...@@ -30,9 +30,19 @@ func HyprlandFixConfigCommand(ctx context.Context, cmd *cli.Command) error { ...@@ -30,9 +30,19 @@ func HyprlandFixConfigCommand(ctx context.Context, cmd *cli.Command) error {
return err return err
} }
backupPath := manager.ConfPath + ".bak"
data, err := os.ReadFile(manager.ConfPath)
if err != nil {
return fmt.Errorf(locale.T("failed to read config: %s"), err)
}
if err := os.WriteFile(backupPath, data, 0644); err != nil {
return fmt.Errorf(locale.T("failed to create backup: %s"), err)
}
manager.FixConfig() manager.FixConfig()
color.Green(locale.T("Configuration fixed")) color.Green(locale.T("Configuration fixed"))
fmt.Printf(locale.T("Backup: %s")+"\n", backupPath)
return nil return nil
} }
......
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