From 6dcfbfa47a3476997b96e80ddf954cc2065167e8 Mon Sep 17 00:00:00 2001 From: axtlos Date: Thu, 31 Mar 2022 21:07:01 +0200 Subject: [PATCH] does it work? I certainly hope it does --- lib/functions/install.dart | 68 +++++++++++++++++++++---- lib/main.dart | 46 +++++++++-------- scripts/jadeTest.sh | 2 + scripts/jadeemu.sh | 102 +++++++++++++++++++++++++++++++++++++ 4 files changed, 189 insertions(+), 29 deletions(-) create mode 100755 scripts/jadeTest.sh diff --git a/lib/functions/install.dart b/lib/functions/install.dart index b602996..d7d66f7 100644 --- a/lib/functions/install.dart +++ b/lib/functions/install.dart @@ -5,9 +5,15 @@ import 'package:jade_gui/classes/location.dart'; import 'dart:convert'; import 'dart:io'; -test(setOutput) async { - var process = await Process.start('./scripts/jadeemu.sh', []); - process.stdout.transform(utf8.decoder).forEach(setOutput); +test(setOutput, running, setRunning, config) async { + if (!running) { + const filename = "/tmp/jade.json"; + var file = await File(filename).writeAsString(config); + var process = + await Process.start('pkexec', ['jade', 'config', '/tmp/jade.json']); + process.stdout.transform(utf8.decoder).forEach(setOutput); + setRunning(true); + } } Widget install( @@ -27,8 +33,9 @@ Widget install( bool enableTimeshift, setOutput, output, + running, + setRunning, ) { - test(setOutput); installPrefs prefs = installPrefs( locale: locale, keymap: keymap, @@ -46,7 +53,8 @@ Widget install( enableTimeshift: enableTimeshift, ); String jsonPrefs = jsonEncode(prefs.toJson()); - print(jsonPrefs); + //writeConfig(jsonPrefs); + test(setOutput, running, setRunning, jsonPrefs); return Column( children: [ const Text( @@ -59,11 +67,53 @@ Widget install( const SizedBox( height: 20, ), - SingleChildScrollView( - child: Text(output, + const SizedBox(width: 40), + Container( + width: 1000, + height: 500, + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + border: Border.all(color: Colors.black), + color: Color.fromARGB(255, 15, 15, 15), + //color: Colors.black, + /*boxShadow: const [ + BoxShadow( + color: Colors.black, + blurRadius: 2, + offset: Offset(-2, 3), + ), + ]*/ + ), + child: SingleChildScrollView( + reverse: true, + child: Text( + output, style: const TextStyle( - color: Color.fromARGB(255, 169, 0, 255), - )), + color: Colors.white, + fontSize: 15, + fontFamily: 'Monospace', + fontWeight: FontWeight.w100, + ), + ), + ), + ), + const SizedBox(height: 20), + Text( + "This may take a while...", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Color.fromARGB(255, 169, 0, 255), + ), + ), + Text( + "Please do not close this window until the installation is finished.", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Color.fromARGB(255, 169, 0, 255), + ), ), ], ); diff --git a/lib/main.dart b/lib/main.dart index 9e7bd2b..d4abe9c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -50,6 +50,7 @@ class _JadeguiState extends State { bool isEfi = false; bool ipv6 = false; bool enableTimeshift = true; + bool running = false; String password = ""; String confirmPassword = ""; String username = ""; @@ -463,27 +464,32 @@ class _JadeguiState extends State { break; case 8: widget = install( - getSelectedLocPack(), - getChosenLayout(), - getChosenVariant(), - username, - password, - enableSudo, - rootPass, - currDesktop, - selectedDisk, - isEfi, - isEfi ? "grub-efi" : "grub-legacy", - hostname, - ipv6, - enableTimeshift, - (value) { - setState(() { - output = output + "\n" + value; + getSelectedLocPack(), + getChosenLayout(), + getChosenVariant(), + username, + password, + enableSudo, + rootPass, + currDesktop, + selectedDisk, + isEfi, + isEfi ? "grub-efi" : "grub-legacy", + hostname, + ipv6, + enableTimeshift, + (value) { + setState(() { + output = output + "\n" + value; + }); + }, + output, + running, + (value) { + setState(() { + running = value; + }); }); - }, - output, - ); break; default: widget = const Text( diff --git a/scripts/jadeTest.sh b/scripts/jadeTest.sh new file mode 100755 index 0000000..cfb7e36 --- /dev/null +++ b/scripts/jadeTest.sh @@ -0,0 +1,2 @@ +#!/usr/bin/bash +echo $(cat $1) \ No newline at end of file diff --git a/scripts/jadeemu.sh b/scripts/jadeemu.sh index 08a0ce9..13e45b2 100755 --- a/scripts/jadeemu.sh +++ b/scripts/jadeemu.sh @@ -1,4 +1,6 @@ #!/usr/bin/bash +whoami +sleep 0.1 echo "[LOG] doing thing" sleep 0.1 echo "[ERROR] failed doing thing" @@ -7,3 +9,103 @@ echo "[LOG]" sleep 0.1 echo "[ERROR]" sleep 1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1 +echo "[LOG]" +sleep 0.1