From 6e2cb4444b06857937328a69bda4ac05900b6db8 Mon Sep 17 00:00:00 2001 From: plant_1312 Date: Tue, 21 Jan 2020 22:47:18 +0000 Subject: [PATCH] Fix SystemD, update ReadMe.md, Debian based support Support with Tolstoevsky --- README.md | 11 +++++++++++ main.vala | 36 +++++++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 853db73..aa22379 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,13 @@ # Yggtk +Now support Arch and Debian based Linux (OpenRC and SystemD). + +### Build and run + +``` +git clone https://git.macaw.me:3000/plant_1312/Yggtk.git +valac Yggtk/main.vala --pkg gtk+-3.0 --pkg json-glib-1.0 +cp Yggtk/main.ui . +rm -R Yggtk +./main +``` diff --git a/main.vala b/main.vala index ddb6422..eb21989 100644 --- a/main.vala +++ b/main.vala @@ -29,7 +29,7 @@ int main (string[] args) { browse.clicked.connect (() => { - browse.label = "clicked"; + browse.label = "Soon"; }); @@ -43,7 +43,7 @@ int main (string[] args) { var status = builder.get_object ("status") as Switch; - check_status(status); + check_status (status); status.notify["active"].connect (() => { @@ -88,10 +88,14 @@ int download () { try { - string yggconf; - Process.spawn_command_line_sync ("pkexec pacman -S yggdrasil --noconfirm"); - Process.spawn_command_line_sync ("yggdrasil -genconf -json", out yggconf); - parse (yggconf); + string pm = Process.spawn_command_line_sync ("pkexec pacman -S yggdrasil --noconfirm"); + + if (pm = "bash: pacman: command not found\n") { + + Process.spawn_command_line_sync ("wget https://2375-115685026-gh.circle-artifacts.com/0/yggdrasil-0.3.12-amd64.deb"); + Process.spawn_command_line_sync ("dpkg -i yggdrasil-0.3.12-amd64.deb"); + + } } catch (Error e) { @@ -134,7 +138,7 @@ int stop () { try { Process.spawn_command_line_sync ("pkexec rc-service yggdrasil stop"); - Process.spawn_command_line_sync ("pkexec systemctl stop yggdrasil"); + Process.spawn_command_line_sync ("systemctl stop yggdrasil"); } catch (Error e) { @@ -153,7 +157,7 @@ int start () { try { Process.spawn_command_line_sync ("pkexec rc-service yggdrasil start"); - Process.spawn_command_line_sync ("pkexec systemctl start yggdrasil"); + Process.spawn_command_line_sync ("systemctl start yggdrasil"); } catch (Error e) { @@ -185,17 +189,27 @@ int check_status (Switch status) { if (yggstatus == "bash: rc-service: command not found\n") { - print ("systemd\n"); + Process.spawn_command_line_sync ("systemctl status yggdrasil | grep running -c", out yggstatus); + + if (yggstatus == "0") { + + status.state_set (false); + + } else { + + status.state_set (true); + + } } else { if (yggstatus == " * status: stopped\n") { - status.state_set(false); + status.state_set (false); } else { - status.state_set(true); + status.state_set (true); }