From 3e5139ab049ad1d26b40f3402420b9d7e4a6a2cc Mon Sep 17 00:00:00 2001 From: axtloss Date: Sun, 24 Jul 2022 21:19:10 +0200 Subject: [PATCH] First batch of bug fixes --- src/classes/install_prefs.py | 63 ++++++++++++++++--------------- src/functions/partition_screen.py | 2 +- src/functions/user_screen.py | 12 ++++-- src/pages/partition_screen.blp | 1 + src/pages/user_screen.blp | 8 ++-- src/scripts/getDiskName.sh | 2 + src/scripts/getDiskType.sh | 2 + src/scripts/install.sh | 2 +- src/scripts/meson.build | 2 + src/utils/disks.py | 12 ++++++ src/widgets/desktop.py | 7 ++++ src/widgets/disk.blp | 13 ++++++- src/widgets/disk.py | 20 ++++++++-- src/window.py | 29 ++++++++++---- 14 files changed, 124 insertions(+), 51 deletions(-) create mode 100644 src/scripts/getDiskName.sh create mode 100644 src/scripts/getDiskType.sh diff --git a/src/classes/install_prefs.py b/src/classes/install_prefs.py index c3689e9..2b2fd4c 100644 --- a/src/classes/install_prefs.py +++ b/src/classes/install_prefs.py @@ -52,43 +52,46 @@ class InstallPrefs: def generate_json(self): prefs = { - "partition": { - "device": self.disk, - "mode": "Auto", - "efi": self.is_efi, - "partitions": "", + '"partition"': { + '"device"': '"'+self.disk+'"', + '"mode"': '"Auto"', + '"efi"': self.is_efi, + '"partitions"': [], }, - "bootloader": { - "type": self.bootloader_type, - "location": self.bootloader_location, + '"bootloader"': { + '"type"': '"'+self.bootloader_type+'"', + '"location"': '"'+self.bootloader_location+'"' }, - "locale": { - "locale": [ - self.timezone.locale + '"locale"': { + '"locale"': [ + '"'+ self.timezone.locale+'"' ], - "keymap": self.layout.country_shorthand, - "timezone": self.timezone.region+"/"+self.timezone.location, + '"keymap"': '"'+self.layout.country_shorthand+'"', + '"timezone"': '"'+self.timezone.region+"/"+self.timezone.location+'"' }, - "networking": { - "hostname": self.hostname, - "ipv6": self.ipv_enabled, + '"networking"': { + '"hostname"': '"'+self.hostname+'"', + '"ipv6"': self.ipv_enabled }, - "users": [ + '"users"': [ { - "name": self.username, - "password": self.password, - "hasroot": self.enable_sudo, - }, + '"name"': '"'+self.username+'"', + '"password"': '"'+self.password+'"', + '"hasroot"': self.enable_sudo + } ], - "rootpass": self.password, - "desktop": self.desktop.lower(), - "unakite": { - "enable": False, - "root": "/dev/null", - "oldroot": self.disk, - "efidir": "/dev/null", - "bootdev": "/dev/null", + '"rootpass"': '"'+self.password+'"', + '"desktop"': '"'+self.desktop.lower()+'"', + '"timeshift"': self.timeshift_enable, + '"extra_packages"': [], + '"flatpak"': True, + '"unakite"': { + '"enable"': False, + '"root"': '"/dev/null"', + '"oldroot"': '"'+self.disk+'"', + '"efidir"': '"/dev/null"', + '"bootdev"': '"/dev/null"' }, - "kernel": "linux" + '"kernel"': '"linux"' } return json.dumps(prefs) diff --git a/src/functions/partition_screen.py b/src/functions/partition_screen.py index d537d3d..c04db2f 100644 --- a/src/functions/partition_screen.py +++ b/src/functions/partition_screen.py @@ -45,7 +45,7 @@ class PartitionScreen(Adw.Bin): row.select_button.set_active(True) self.selected_partition = row else: - print("row is none!!") + print("ERROR: invalid row slected") def carousel_next(self, widget): self.window.summary_screen.initialize() diff --git a/src/functions/user_screen.py b/src/functions/user_screen.py index e1f0e13..aa8f2b2 100644 --- a/src/functions/user_screen.py +++ b/src/functions/user_screen.py @@ -20,7 +20,7 @@ from gi.repository import Gtk, Adw from gettext import gettext as _ -import re +import re, subprocess @Gtk.Template(resource_path='/al/getcryst/jadegui/pages/user_screen.ui') class UserScreen(Adw.Bin): @@ -95,11 +95,17 @@ class UserScreen(Adw.Bin): if self.password_entry.get_text() == self.password_confirmation.get_text(): self.next_page.set_sensitive(True) self.password_confirmation.remove_css_class('error') - self.password = self.password_entry.get_text() - elif self.password_entry.get_text() != self.password_confirmation.get_text(): + self.password = self.encrypt_password(self.password_entry.get_text()) + else: self.next_page.set_sensitive(False) self.password_confirmation.add_css_class('error') + def encrypt_password(self, password): + command=subprocess.run(["openssl", "passwd", "-6", password], capture_output=True) + password_encrypted=command.stdout.decode('utf-8').strip('\n') + return password_encrypted + + def carousel_next(self, widget): if self.move_to_summary: self.window.summary_screen.initialize() diff --git a/src/pages/partition_screen.blp b/src/pages/partition_screen.blp index 4b962c7..4923b13 100644 --- a/src/pages/partition_screen.blp +++ b/src/pages/partition_screen.blp @@ -16,6 +16,7 @@ template PartitionScreen : Adw.Bin { Adw.PreferencesPage { Adw.PreferencesGroup { Gtk.ListBox partition_list { + activate-on-single-click: true; styles ["boxed-list"] } // Gtk.ListBox { diff --git a/src/pages/user_screen.blp b/src/pages/user_screen.blp index fcaf16a..88866fa 100644 --- a/src/pages/user_screen.blp +++ b/src/pages/user_screen.blp @@ -19,11 +19,11 @@ template UserScreen : Adw.Bin { Adw.EntryRow username_entry { title: "Enter your username"; } - Adw.EntryRow password_entry { - title: "Enter your password"; + Adw.PasswordEntryRow password_entry { + title: "Enter your password"; } - Adw.EntryRow password_confirmation { - title: "Repeat your password"; + Adw.PasswordEntryRow password_confirmation { + title: "Repeat your password"; } Gtk.ListBox { // TODO: MOVE TO ADVANCED/MISC SECTION??? margin-top: 7; diff --git a/src/scripts/getDiskName.sh b/src/scripts/getDiskName.sh new file mode 100644 index 0000000..2848ee9 --- /dev/null +++ b/src/scripts/getDiskName.sh @@ -0,0 +1,2 @@ +#!/usr/bin/bash +flatpak-spawn --host lsblk -pdbo MODEL $1 | grep -v MODEL \ No newline at end of file diff --git a/src/scripts/getDiskType.sh b/src/scripts/getDiskType.sh new file mode 100644 index 0000000..ebe4e55 --- /dev/null +++ b/src/scripts/getDiskType.sh @@ -0,0 +1,2 @@ +#!/usr/bin/bash +flatpak-spawn --host lsblk -d -o rota $1 | grep -v ROTA \ No newline at end of file diff --git a/src/scripts/install.sh b/src/scripts/install.sh index d111006..4c660fe 100644 --- a/src/scripts/install.sh +++ b/src/scripts/install.sh @@ -1,4 +1,4 @@ #!/usr/bin/bash -flatpak-spawn --host pkexec jade /tmp/jade.json +flatpak-spawn --host pkexec jade config /tmp/jade.json #flatpak-spawn --host echo "hi" #flatpak-spawn --host pkexec whoami diff --git a/src/scripts/meson.build b/src/scripts/meson.build index 9cfc3b0..2e70d47 100644 --- a/src/scripts/meson.build +++ b/src/scripts/meson.build @@ -7,5 +7,7 @@ jade_gui_sources = [ 'checkEFI.sh', 'install.sh', 'savePrefs.sh', + 'getDiskType.sh', + 'getDiskName.sh', ] install_data(jade_gui_sources, install_dir: scriptsdir) \ No newline at end of file diff --git a/src/utils/disks.py b/src/utils/disks.py index a98a0c6..4eb626b 100644 --- a/src/utils/disks.py +++ b/src/utils/disks.py @@ -33,3 +33,15 @@ def get_uefi(): command=subprocess.run(["bash", "-c", "bash -- /app/share/jade_gui/jade_gui/scripts/checkEFI.sh"], capture_output=True) isEfi=True if command.stdout.decode('utf-8').strip('\n') == "UEFI" else False return isEfi + +def get_disk_type(disk: str): + command=subprocess.run(["bash", "-c", "bash -- /app/share/jade_gui/jade_gui/scripts/getDiskType.sh "+disk], capture_output=True) + disk_type=command.stdout.decode('utf-8').strip() + print(disk_type) + if disk_type == "0": + return "Solid-State Drive (SSD)" + elif disk_type == "1": + return "Hard Disk (HDD)" + else: + return "Drive type unknown" + diff --git a/src/widgets/desktop.py b/src/widgets/desktop.py index a6cc597..ad54580 100644 --- a/src/widgets/desktop.py +++ b/src/widgets/desktop.py @@ -31,4 +31,11 @@ class DesktopEntry(Adw.ActionRow): self.window = window self.set_title(desktop) self.select_button.set_group(button_group) + self.select_button.connect("toggled", self.toggled_cb) + + def toggled_cb(self, check_button): + if check_button.props.active: + row = check_button.get_ancestor(Gtk.ListBoxRow) + row.activate() + self.selected_partition = row.get_title() diff --git a/src/widgets/disk.blp b/src/widgets/disk.blp index 5e0d37f..d60f24a 100644 --- a/src/widgets/disk.blp +++ b/src/widgets/disk.blp @@ -3,8 +3,19 @@ using Adw 1; template DiskEntry : Adw.ActionRow { title: "Disk"; - subtitle: "disk size"; + subtitle: "Disk type"; + activatable-widget: select_button; Gtk.Box { + spacing: 6; + Gtk.Label size_label { + valign: center; + label: "Disk size"; + styles ["tag", "caption"] + } + Gtk.Separator { + margin-top: 12; + margin-bottom: 12; + } Gtk.CheckButton select_button { use-underline: true; } diff --git a/src/widgets/disk.py b/src/widgets/disk.py index dc76b84..51988c0 100644 --- a/src/widgets/disk.py +++ b/src/widgets/disk.py @@ -24,12 +24,24 @@ from gettext import gettext as _ class DiskEntry(Adw.ActionRow): __gtype_name__ = 'DiskEntry' + size_label = Gtk.Template.Child() select_button = Gtk.Template.Child() - def __init__(self, window, disk, disk_size, button_group, application, **kwargs): + def __init__(self, window, disk, disk_size, disk_type, button_group, application, **kwargs): super().__init__(**kwargs) + self.window = window self.disk = disk - self.disk_size = disk - self.set_title(disk) - self.set_subtitle(disk_size) + self.disk_size = disk_size + self.disk_type = disk_type + self.set_title(disk.strip('/dev/')) + self.set_subtitle(disk_type) + self.size_label.set_label("Disk Size: "+disk_size) self.select_button.set_group(button_group) + self.select_button.connect("toggled", self.toggled_cb) + + def toggled_cb(self, check_button): + if check_button.props.active: + row = check_button.get_ancestor(Gtk.ListBoxRow) + row.emit('activate') + self.selected_partition = row.get_title() + diff --git a/src/window.py b/src/window.py index c564994..608d97c 100644 --- a/src/window.py +++ b/src/window.py @@ -107,16 +107,31 @@ class JadeGuiWindow(Gtk.ApplicationWindow): ### Test partitions available_disks = disks.get_disks() - firstdisk = DiskEntry(window=self, disk=available_disks[0], disk_size=disks.get_disk_size(available_disks[0]), button_group=None, **kwargs) + firstdisk = DiskEntry( + window=self, + disk=available_disks[0], + disk_size=disks.get_disk_size(available_disks[0]), + disk_type=disks.get_disk_type(available_disks[0]), + #disk_model=disks.get_disk_model(available_disks[0]), + button_group=None, + **kwargs + ) self.partition_screen.partition_list.append(firstdisk) - self.partition_screen.selected_partition = self.partition_screen.partition_list.get_row_at_index(0) - self.partition_screen.partition_list.select_row(firstdisk) - #print(available_disks[0]) - #print(available_disks) + firstdisk.toggled_cb(firstdisk.select_button) for disk in available_disks: if disk != available_disks[0]: - #print(disk) - self.partition_screen.partition_list.append(DiskEntry(window=self, disk=disk, disk_size=disks.get_disk_size(disk), button_group=firstdisk.select_button, **kwargs)) + self.partition_screen.partition_list.append( + DiskEntry( + window=self, + disk=disk, + disk_size=disks.get_disk_size(disk), + disk_type=disks.get_disk_type(disk), + #disk_model=disks.get_disk_model(disk), + button_group=firstdisk.select_button, + **kwargs + ) + ) + ### --------- def nextPage(self, idk):