diff --git a/src/functions/misc_screen.py b/src/functions/misc_screen.py index eaac763..df6680b 100644 --- a/src/functions/misc_screen.py +++ b/src/functions/misc_screen.py @@ -30,6 +30,11 @@ class MiscScreen(Adw.Bin): theme_switch = Gtk.Template.Child() next_page_button = Gtk.Template.Child() + hostname = "crystal" + ipv_enabled = False + crystal_theming_enabled = False + timeshift_enabled = True + def __init__(self, window, main_carousel, next_page, application, **kwargs): super().__init__(**kwargs) self.window = window @@ -38,4 +43,8 @@ class MiscScreen(Adw.Bin): self.next_page_button.connect("clicked", self.carousel_next) def carousel_next(self, widget): + self.hostname = self.hostname_entry.get_text() + self.ipv_enabled = self.ipv_switch.get_state() + self.crystal_theming_enabled = self.theme_switch.get_state() + self.timeshift_enabled = self.timeshift_switch.get_state() self.carousel.scroll_to(self.next_page, True) diff --git a/src/meson.build b/src/meson.build index 2d9d062..00156aa 100644 --- a/src/meson.build +++ b/src/meson.build @@ -63,6 +63,8 @@ subdir('widgets') subdir('functions') subdir('classes') subdir('locales') +subdir('utils') +subdir('scripts') jade_gui_sources = [ '__init__.py', diff --git a/src/scripts/getDiskSize.sh b/src/scripts/getDiskSize.sh new file mode 100644 index 0000000..074372b --- /dev/null +++ b/src/scripts/getDiskSize.sh @@ -0,0 +1,2 @@ +#!/usr/bin/bash +flatpak-spawn --host lsblk -pdo SIZE $1 | grep -v SIZE \ No newline at end of file diff --git a/src/scripts/getDisks.sh b/src/scripts/getDisks.sh new file mode 100644 index 0000000..7888fdb --- /dev/null +++ b/src/scripts/getDisks.sh @@ -0,0 +1,2 @@ +#!/usr/bin/bash +flatpak-spawn --host lsblk -pdo name | grep -v zram | grep -v NAME | grep -v loop | grep -v sr \ No newline at end of file diff --git a/src/scripts/meson.build b/src/scripts/meson.build new file mode 100644 index 0000000..e6ad6ca --- /dev/null +++ b/src/scripts/meson.build @@ -0,0 +1,8 @@ +pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) +scriptsdir = join_paths(pkgdatadir, 'jade_gui/scripts') + +jade_gui_sources = [ + 'getDisks.sh', + 'getDiskSize.sh', +] +install_data(jade_gui_sources, install_dir: scriptsdir) \ No newline at end of file diff --git a/src/utils/__init__.py b/src/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/disks.py b/src/utils/disks.py new file mode 100644 index 0000000..1025ba1 --- /dev/null +++ b/src/utils/disks.py @@ -0,0 +1,30 @@ +# exec.py +# +# Copyright 2022 axtlos +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# SPDX-License-Identifier: GPL-3.0-only + +import subprocess +def get_disks(): + command=subprocess.run(["bash", "-c", "bash -- /app/share/jade_gui/jade_gui/scripts/getDisks.sh"], capture_output=True) + disks=command.stdout.decode('utf-8')[:-1].split('\n') + return disks + +def get_disk_size(disk: str): + command=subprocess.run(["bash", "-c", "bash -- /app/share/jade_gui/jade_gui/scripts/getDiskSize.sh "+disk], capture_output=True) + size=command.stdout.decode('utf-8').strip('\n') + print(disk+":"+size) + return size+"iB" diff --git a/src/utils/meson.build b/src/utils/meson.build new file mode 100644 index 0000000..e816d8f --- /dev/null +++ b/src/utils/meson.build @@ -0,0 +1,8 @@ +pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) +utilsdir = join_paths(pkgdatadir, 'jade_gui/utils') + +jade_gui_sources = [ + '__init__.py', + 'disks.py', +] +install_data(jade_gui_sources, install_dir: utilsdir) \ No newline at end of file diff --git a/src/window.py b/src/window.py index 0c624fc..db4f5da 100644 --- a/src/window.py +++ b/src/window.py @@ -36,6 +36,7 @@ from .functions.finished_screen import FinishedScreen from .locales.locales_list import locations from .keymaps import keymaps from .desktops import desktops +from .utils import disks @Gtk.Template(resource_path='/al/getcryst/jadegui/window.ui') class JadeGuiWindow(Gtk.ApplicationWindow): @@ -92,26 +93,25 @@ class JadeGuiWindow(Gtk.ApplicationWindow): self.keyboard_screen.list_keyboard_layouts.append(KeyboardLayout(window=self, country=keymap.layout, country_shorthand=keymap.backend_layout, variants=keymap.variant, **kwargs)) ### --------- - ### Test variants - - ### --------- - ### Test desktops onyx = DesktopEntry(window=self, desktop="Onyx", button_group=None, **kwargs) # Manually specifying onyx since the other entries need a button group to attach to self.desktop_screen.list_desktops.append(onyx) for desktop in desktops: - if desktop is not "Onyx": + if desktop != "Onyx": print(desktop) self.desktop_screen.list_desktops.append(DesktopEntry(window=self, desktop=desktop, button_group=onyx.select_button, **kwargs)) ### --------- ### Test partitions - partition_test = DiskEntry(window=self, disk="/dev/sda", disk_size="2000gb", button_group=None, **kwargs) - partition_test_two = DiskEntry(window=self, disk="/dev/nvme0n1", disk_size="100mb (morbillion bytes)", button_group=partition_test.select_button, **kwargs) - partition_test_three = DiskEntry(window=self, disk="/dev/whatotherdisklabelsarethere", disk_size="no", button_group=partition_test.select_button, **kwargs) - self.partition_screen.partition_list.append(partition_test) - self.partition_screen.partition_list.append(partition_test_two) - self.partition_screen.partition_list.append(partition_test_three) + 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) + self.partition_screen.partition_list.append(firstdisk) + print(available_disks[0]) + print(available_disks) + 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)) ### --------- def nextPage(self, idk):