diff --git a/src/app-window.vala b/src/app-window.vala index 07933ca..2e1574c 100644 --- a/src/app-window.vala +++ b/src/app-window.vala @@ -53,15 +53,21 @@ namespace Yggtk { save_config_button.clicked.connect (() => { if (peer_ip_entry.text != yggconfout) { - Parser.to_json (peer_ip_entry); + if (yggconfout == "") { + string yggconf; + Process.spawn_command_line_sync ("yggdrasil -genconf -json", out yggconf); + Parser.to_json (peer_ip_entry, yggconf); + + } else { + FileUtils.get_contents ("/etc/yggdrasil.conf", out yggconfout); + Parser.to_json (peer_ip_entry, yggconfout); + } } }); } public class Parser : Object { - public void to_json (Entry ip) { - string yggconf; - Process.spawn_command_line_sync ("yggdrasil -genconf -json", out yggconf); + public void to_json (Entry ip, string yggconf) { var node = Json.from_string (yggconf); var obj = node.get_object (); obj.set_string_member ("Peers", ip.text);