From ad38fbcd7fa92560e2e539067a13c9f6db9c5061 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 21 Jul 2021 14:44:34 -0400 Subject: [PATCH 01/39] More launch-time run conditions If system-installer launches at boot time, do not launch drauger-welcome's UI --- DEBIAN/control | 2 +- etc/xdg/autostart/drauger-welcome.desktop | 2 +- usr/share/drauger-welcome/tut.py | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 2a59a51..47f22ef 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: drauger-welcome -Version: 4.8 +Version: 4.9 Maintainer: Thomas Castleman Section: misc Homepage: https://github.com/drauger-os-development/drauger-welcome diff --git a/etc/xdg/autostart/drauger-welcome.desktop b/etc/xdg/autostart/drauger-welcome.desktop index b2c6c51..00eafd7 100644 --- a/etc/xdg/autostart/drauger-welcome.desktop +++ b/etc/xdg/autostart/drauger-welcome.desktop @@ -1,6 +1,6 @@ [Desktop Entry] Name=Drauger Welcome -Version=4.6 +Version=4.9 Exec=/usr/share/drauger-welcome/tut.py Comment=Welcome Screen for Drauger OS Type=Application diff --git a/usr/share/drauger-welcome/tut.py b/usr/share/drauger-welcome/tut.py index 9d74a86..4ec179c 100755 --- a/usr/share/drauger-welcome/tut.py +++ b/usr/share/drauger-welcome/tut.py @@ -3,7 +3,7 @@ # # tut.py # -# Copyright 2020 Thomas Castleman +# Copyright 2021 Thomas Castleman # # 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 @@ -32,7 +32,13 @@ def eprint(*args, **kwargs): print(*args, file=stderr, **kwargs) HOME = getenv("HOME") -if (not path.exists(HOME + "/.drauger-tut")): +# check if system-installer will be running, if it is, do not show the welcome screen +with open("/proc/cmdline", "r") as cmdline_file: + cmdline = cmdline_file.read()[:-1].split(" ") +if "system-installer" in cmdline: + # Not wanted to be running ootb + sys.exit(0) +if not path.exists(HOME + "/.drauger-tut"): try: main_ui.welcome_show() except Exception as e: From 0a4e9de49106309cc347ad6861570545bac5acf1 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 23 Jul 2021 01:32:18 -0400 Subject: [PATCH 02/39] OEM post-install awareness --- usr/share/drauger-welcome/tut.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/share/drauger-welcome/tut.py b/usr/share/drauger-welcome/tut.py index 4ec179c..61c90f8 100755 --- a/usr/share/drauger-welcome/tut.py +++ b/usr/share/drauger-welcome/tut.py @@ -38,7 +38,7 @@ def eprint(*args, **kwargs): if "system-installer" in cmdline: # Not wanted to be running ootb sys.exit(0) -if not path.exists(HOME + "/.drauger-tut"): +if ((not path.exists(HOME + "/.drauger-tut")) and (not path.exists("/etc/system-installer/oem-post-install.flag"))): try: main_ui.welcome_show() except Exception as e: From 0022ac07d8915dac2f2d6ee34daf8f1b84badd50 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 23 Jul 2021 16:15:05 -0400 Subject: [PATCH 03/39] fix minor import error --- DEBIAN/control | 2 +- usr/share/drauger-welcome/tut.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 47f22ef..3c5fd85 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: drauger-welcome -Version: 4.9 +Version: 4.9.1 Maintainer: Thomas Castleman Section: misc Homepage: https://github.com/drauger-os-development/drauger-welcome diff --git a/usr/share/drauger-welcome/tut.py b/usr/share/drauger-welcome/tut.py index 61c90f8..fc15ffd 100755 --- a/usr/share/drauger-welcome/tut.py +++ b/usr/share/drauger-welcome/tut.py @@ -22,19 +22,19 @@ # # from __future__ import print_function -from sys import stderr +import sys from os import path, getenv from subprocess import Popen import main_ui # Make it easier for us to print to stderr def eprint(*args, **kwargs): - print(*args, file=stderr, **kwargs) + print(*args, file=sys.stderr, **kwargs) HOME = getenv("HOME") # check if system-installer will be running, if it is, do not show the welcome screen with open("/proc/cmdline", "r") as cmdline_file: - cmdline = cmdline_file.read()[:-1].split(" ") + cmdline = cmdline_file.read() if "system-installer" in cmdline: # Not wanted to be running ootb sys.exit(0) From 514642a2f84da5544e7fbcfc83dcfcf24f1802ae Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Tue, 7 Sep 2021 22:42:52 -0400 Subject: [PATCH 04/39] check to see if apps are installed before launching them Install apps if they are not installed when needed. --- DEBIAN/control | 4 +- usr/share/drauger-welcome/main_ui.py | 89 +++++++++++++++++++--------- 2 files changed, 62 insertions(+), 31 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 3c5fd85..594c25f 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,11 +1,11 @@ Package: drauger-welcome -Version: 4.9.1 +Version: 4.9.2 Maintainer: Thomas Castleman Section: misc Homepage: https://github.com/drauger-os-development/drauger-welcome Architecture: amd64 Priority: optional -Depends: python3 (>=3.5.1-3), gir1.2-gtk-3.0 (>=3.24.12-1ubuntu1), drauger-icons (>=0.0.2), bash, procps, xfconf +Depends: python3 (>=3.5.1-3), gir1.2-gtk-3.0 (>=3.24.12-1ubuntu1), drauger-icons (>=0.0.2), bash, procps, xfconf, pythone3-apt Replaces: drauger-tutorial (>=1.0) Breaks: drauger-tutorial (>=1.0) Description: Welcome screen and tutorial All-in-One for Drauger OS diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index 5c01ed2..f508412 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -3,7 +3,7 @@ # # main_ui.py # -# Copyright 2020 Thomas Castleman +# Copyright 2021 Thomas Castleman # Additional contributors: Logan L Johnson # # This program is free software; you can redistribute it and/or modify @@ -26,8 +26,9 @@ gi.require_version('Gtk', '3.0') from gi.repository import Gtk from os import system, path, getenv, remove -from subprocess import Popen, check_output, check_call, CalledProcessError +import subprocess import json +import apt LANG = getenv("LANG").split(".") LANG = LANG[0] @@ -208,7 +209,7 @@ def __init__(self): Gtk.Window.__init__(self, title="Welcome to Drauger OS") self.grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL,) self.add(self.grid) - self.set_icon_from_file("/usr/share/icons/Drauger/scalable/menus/drauger_os-logo.svg") + # self.set_icon_from_file("/usr/share/icons/Drauger/scalable/menus/drauger_os-logo.svg") self.reset("clicked") @@ -317,7 +318,7 @@ def reset(self, button): self.grid.attach(self.label10, 4, 3, 1, 1) self.button10 = Gtk.Button.new_from_icon_name("preferences-desktop-locale", 3) - self.button10.connect("clicked", self.onCYGOclicked) + self.button10.connect("clicked", self.onlangsupportclicked) self.grid.attach(self.button10, 4, 4, 1, 1) self.start_up = Gtk.CheckButton.new_with_label(start_up_label) @@ -361,7 +362,7 @@ def reset(self, button): self.show_all() def show_readme(self, widget): - Popen(["xdg-open", "https://download.draugeros.org/docs/README.pdf"]) + subprocess.Popen(["xdg-open", "https://download.draugeros.org/docs/README.pdf"]) def start_up_toggle(self, widget): global show_at_start_up @@ -403,7 +404,7 @@ def show_accessibility_settings(self, button): self.font_button = Gtk.FontButton() # get system font and font size - system_font = check_output(["xfconf-query", "--channel", "xsettings", + system_font = subprocess.check_output(["xfconf-query", "--channel", "xsettings", "--property", "/Gtk/FontName"]) system_font = list(str(system_font)) del(system_font[1]) @@ -458,13 +459,13 @@ def show_accessibility_settings(self, button): self.show_all() def goto_accessibility(self, button): - Popen("xfce4-accessibility-settings") + subprocess.Popen("xfce4-accessibility-settings") def set_font(self, widget): - Popen(["xfconf-query", "--channel", "xsettings", "--property", + subprocess.Popen(["xfconf-query", "--channel", "xsettings", "--property", "/Gtk/FontName", "--set", self.font_button.get_font()]) - def onCYGOclicked(self, button): + def onlangsupportclicked(self, button): self.clear_window() self.label = Gtk.Label() @@ -525,12 +526,12 @@ def install_locale_packages(self, button): lang = lang.split("_") lang = "-".join(lang).lower() if lang[0:2] == "en": - check_call(["notify-send", "--app-name='Drauger Welcome'", + subprocess.check_call(["notify-send", "--app-name='Drauger Welcome'", "--icon=/usr/share/icons/Drauger/scalable/menus/drauger_os-logo.svg", "Locale packages do not need to be installed."]) else: package_name = "drauger-locale-" + lang - packages = check_output(["apt", "search", + packages = subprocess.check_output(["apt", "search", "drauger-locale"]).decode() packages = packages.split("\n") for each in range(len(packages) - 1, -1, -1): @@ -540,13 +541,13 @@ def install_locale_packages(self, button): packages[each] = packages[each].split("/")[0] if package_name in packages: try: - check_call(["pkexec", "apt", "--force-yes", "install", + subprocess.check_call(["pkexec", "apt", "--force-yes", "install", package_name]) - check_call(["notify-send", "--app-name='Drauger Welcome'", + subprocess.check_call(["notify-send", "--app-name='Drauger Welcome'", "--icon=/usr/share/icons/Drauger/scalable/menus/drauger_os-logo.svg", "%s installed." % (package_name)]) - except CalledProcessError: - check_call(["notify-send", "--app-name='Drauger Welcome'", + except subprocess.CalledProcessError: + subprocess.check_call(["notify-send", "--app-name='Drauger Welcome'", "--icon=/usr/share/icons/Drauger/scalable/menus/drauger_os-logo.svg", "Locale package could not be installed."]) @@ -558,7 +559,7 @@ def onnextclicked(self, button): elif self.check == 2: self.removal_conf("clicked") else: - check_call(["/usr/share/drauger-welcome/log-out", "2", + subprocess.check_call(["/usr/share/drauger-welcome/log-out", "2", "/usr/share/drauger-welcome/multi_desktop.py", "Unknown error. Variable self.check in function onnextclicked in class notify outside expected range", "drauger-welcome", "UNKNOWN", "UNKNOWN"]) @@ -566,7 +567,7 @@ def onnextclicked(self, button): self.check = self.check + 1 def onwebclicked(self, button): - Popen(["/usr/bin/xdg-open", "https://draugeros.org/go"]) + subprocess.Popen(["/usr/bin/xdg-open", "https://draugeros.org/go"]) def onhelpclicked(self, button): @@ -637,32 +638,62 @@ def onhelpclicked(self, button): self.button1.set_margin_end(width) self.button1.set_margin_top(width) self.button1.set_margin_bottom(width) - print(self.button1.get_size_request()) # self.button1.set_margin_top(int(width / 2)) # self.button1.set_margin_bottom(int(width / 2)) self.show_all() def open_discord(self, button): - Popen(["xdg-open", "https://discord.gg/JW8FGrc"]) + cache = apt.cache.Cache() + cache.open() + installed = False + with cache.actiongroup(): + for each in cache: + if "discord" == each.name: + installed = each.is_installed + break + if not installed: + check = subprocess.check_output("snap list | awk '{print $1}' | grep 'discord'", + shell=True).decode()[:-1] + if check == "discord": + installed = True + if not installed: + subprocess.check_call(["snap", "install", "discord"]) + subprocess.Popen(["discord", "https://discord.gg/JW8FGrc"]) def open_mydrauger(self, button): - Popen(["xdg-open", "https://draugeros.org/go/my"]) + subprocess.Popen(["xdg-open", "https://draugeros.org/go/my"]) def open_telegram(self, button): - Popen(["xdg-open", "https://t.me/draugeros"]) + cache = apt.cache.Cache() + cache.open() + installed = False + with cache.actiongroup(): + for each in cache: + if "telegram-desktop" == each.name: + installed = each.is_installed + break + if not installed: + check = subprocess.check_output("snap list | awk '{print $1}' | grep 'telegram-desktop'", + shell=True).decode()[:-1] + if check == "telegram-desktop": + installed = True + if not installed: + subprocess.check_call(["snap", "install", "telegram-desktop"]) + subprocess.Popen(["telegram-desktop", "https://t.me/draugeros"]) def open_wiki(self, button): - Popen(["xdg-open", "https://draugeros.org/go/wiki"]) + subprocess.Popen(["xdg-open", "https://draugeros.org/go/wiki"]) def ondriveclicked(self, button): - Popen(["/usr/bin/software-properties-gtk", "--open-tab=4"]) + subprocess.Popen(["/usr/bin/software-properties-gtk", "--open-tab=4"]) def onlanguageclicked(self, button): - Popen(["gnome-language-selector"]) + subprocess.Popen(["gnome-language-selector"]) def ondonateclicked(self, button): - Popen(["/usr/bin/xdg-open", "https://paypal.me/pools/c/89GtByYaTT"]) + subprocess.Popen(["/usr/bin/xdg-open", + "https://liberapay.com/Drauger_OS_Development/donate"]) def onshortcutclicked(self, button): self.clear_window() @@ -760,9 +791,9 @@ def onuninstallclicked(self, button): # have an uninstall comfirmation dialoge then uninstall based on # the answer try: - check_call("/usr/share/drauger-welcome/u.sh") - except CalledProcessError: - check_call(["/usr/share/drauger-welcome/log-out", + subprocess.check_call("/usr/share/drauger-welcome/u.sh") + except subprocess.CalledProcessError: + subprocess.check_call(["/usr/share/drauger-welcome/log-out", "2", "/usr/share/drauger-welcome/main.py", "/etc/drauger-welcome/u.sh has failed. See error log entry for u.sh for more info.", "drauger-welcome", "UNKNOWN", "UNKNOWN"]) @@ -890,7 +921,7 @@ def welcome_show(): try: welcome_show() except: - check_call(["/usr/share/drauger-welcome/log-out", + subprocess.check_call(["/usr/share/drauger-welcome/log-out", "2 /usr/share/drauger-welcome/main_ui.py", "Unknown error. Function welcome_show has failed.", "drauger-welcome", "UNKNOWN", "UNKNOWN"]) From 9da38b88861a9607c08840c245e0a0f3acc4e085 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 4 Feb 2022 00:06:19 -0500 Subject: [PATCH 05/39] allow for different readmes for each Drauger OS version --- DEBIAN/control | 2 +- usr/share/drauger-welcome/main_ui.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 3c5fd85..c8b5c0e 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: drauger-welcome -Version: 4.9.1 +Version: 4.9.2 Maintainer: Thomas Castleman Section: misc Homepage: https://github.com/drauger-os-development/drauger-welcome diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index 5c01ed2..57af728 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -361,7 +361,9 @@ def reset(self, button): self.show_all() def show_readme(self, widget): - Popen(["xdg-open", "https://download.draugeros.org/docs/README.pdf"]) + version = check_output(["lsb_release", "-rs"]).decode() + Popen(["xdg-open", + f"https://download.draugeros.org/docs/{version}/README.pdf"]) def start_up_toggle(self, widget): global show_at_start_up From fc7ddce06899c1ca776c94f2803d774a14ea6a38 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 4 Feb 2022 00:06:35 -0500 Subject: [PATCH 06/39] update copyright date --- usr/share/drauger-welcome/log-out.cxx | 3 +-- usr/share/drauger-welcome/main_ui.py | 2 +- usr/share/drauger-welcome/tut.py | 2 +- usr/share/drauger-welcome/u.sh | 12 ++++++------ 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/usr/share/drauger-welcome/log-out.cxx b/usr/share/drauger-welcome/log-out.cxx index 66e788e..051eb53 100644 --- a/usr/share/drauger-welcome/log-out.cxx +++ b/usr/share/drauger-welcome/log-out.cxx @@ -1,7 +1,7 @@ /* * log-out.cxx * - * Copyright 2020 Thomas Castleman + * Copyright 2022 Thomas Castleman * * 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 @@ -94,4 +94,3 @@ int main(int argc, char* argv[]) log.close(); } } - diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index 57af728..8899e7f 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -3,7 +3,7 @@ # # main_ui.py # -# Copyright 2020 Thomas Castleman +# Copyright 2022 Thomas Castleman # Additional contributors: Logan L Johnson # # This program is free software; you can redistribute it and/or modify diff --git a/usr/share/drauger-welcome/tut.py b/usr/share/drauger-welcome/tut.py index fc15ffd..bd117fd 100755 --- a/usr/share/drauger-welcome/tut.py +++ b/usr/share/drauger-welcome/tut.py @@ -3,7 +3,7 @@ # # tut.py # -# Copyright 2021 Thomas Castleman +# Copyright 2022 Thomas Castleman # # 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 diff --git a/usr/share/drauger-welcome/u.sh b/usr/share/drauger-welcome/u.sh index aa5a9e7..f40a9a6 100755 --- a/usr/share/drauger-welcome/u.sh +++ b/usr/share/drauger-welcome/u.sh @@ -2,19 +2,19 @@ # -*- coding: utf-8 -*- # # u.sh -# -# Copyright 2020 Thomas Castleman -# +# +# Copyright 2022 Thomas Castleman +# # 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 2 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, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, @@ -51,7 +51,7 @@ function translate () error_uninst=$(echo "$FILE" | grep "^error_uninst" | awk -F '"' '{print $2}' | sed "s/\$error/$CONCAT_1/") return "$error_uninst" fi - + } { /usr/bin/pkexec /usr/bin/apt -y purge drauger-welcome | /usr/bin/zenity --progress --pulsate --auto-close --no-cancel --text=$(translate "remove") From 9f8da2a31bdd84f75cc37a97e07107e2bfa72ed4 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 4 Feb 2022 00:06:45 -0500 Subject: [PATCH 07/39] update build process --- build.sh | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/build.sh b/build.sh index 5fffbe0..1759bfd 100755 --- a/build.sh +++ b/build.sh @@ -44,30 +44,9 @@ fi if [ -d libx32 ]; then cp -R libx32 ../"$FOLDER"/libx32 fi -if [ -d dev ]; then - cp -R dev ../"$FOLDER"/dev -fi -if [ -d home ]; then - cp -R home ../"$FOLDER"/home -fi -if [ -d proc ]; then - cp -R proc ../"$FOLDER"/proc -fi -if [ -d root ]; then - cp -R root ../"$FOLDER"/root -fi -if [ -d run ]; then - cp -R run ../"$FOLDER"/run -fi if [ -d sbin ]; then cp -R sbin ../"$FOLDER"/sbin fi -if [ -d sys ]; then - cp -R sys ../"$FOLDER"/sys -fi -if [ -d tmp ]; then - cp -R tmp ../"$FOLDER"/tmp -fi if [ -d var ]; then cp -R var ../"$FOLDER"/var fi From b79a13bdf71f0dbaa77bf9f244ba1dbe54157ce2 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 4 Feb 2022 01:21:05 -0500 Subject: [PATCH 08/39] fix NameError --- DEBIAN/control | 2 +- usr/share/drauger-welcome/main_ui.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 60a8efa..7f0ebe2 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: drauger-welcome -Version: 4.9.2 +Version: 4.9.3 Maintainer: Thomas Castleman Section: misc Homepage: https://github.com/drauger-os-development/drauger-welcome diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index 142f67b..4319361 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -362,7 +362,7 @@ def reset(self, button): self.show_all() def show_readme(self, widget): - version = check_output(["lsb_release", "-rs"]).decode() + version = subprocess.check_output(["lsb_release", "-rs"]).decode() subprocess.Popen(["xdg-open", f"https://download.draugeros.org/docs/{version}/README.pdf"]) From dc7add14a06d540b84c50f7c3cdd4ef6b5d0a786 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 16 Feb 2022 17:51:30 -0500 Subject: [PATCH 09/39] initial work making custom driver window --- DEBIAN/control | 2 +- usr/share/drauger-welcome/main_ui.py | 44 +++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 7f0ebe2..d251c6d 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: drauger-welcome -Version: 4.9.3 +Version: 4.9.4 Maintainer: Thomas Castleman Section: misc Homepage: https://github.com/drauger-os-development/drauger-welcome diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index 4319361..a1364e8 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -28,6 +28,7 @@ from os import system, path, getenv, remove import subprocess import json +import shlex import apt LANG = getenv("LANG").split(".") @@ -688,7 +689,48 @@ def open_wiki(self, button): subprocess.Popen(["xdg-open", "https://draugeros.org/go/wiki"]) def ondriveclicked(self, button): - subprocess.Popen(["/usr/bin/software-properties-gtk", "--open-tab=4"]) + self.clear_window() + + # we need to make a window here to manage drivers + # start off by getting all our PCI devices + devices = subprocess.check_output(["lspci", "-qmm"]).decode() + # we need to parse this so that we can check for devices in need of drivers + # this will do most of that for us + devices = devices.split("\n") + for each in range(len(data) - 1, -1, -1): + data[each] = shlex.split(data[each]) + + # now we need to get rid of anything that we don't need + for each in range(len(data) - 1, -1, -1): + if len(data[each]) < 2: + del data[each] + continue + if "VGA" in data[each][1]: + continue + elif data[each][1].lower() == "network controller": + continue + elif data[each][1].lower() == "ethernet controller": # these don't always need drivers. But sometimes they do. + continue + del data[each] + + # now we have a list of all devices that MIGHT need drivers: GPUs, Wifi cards, Ethernet cards + # check if they have chips that need drivers or not + for each in range(len(data) - 1, -1, -1): + if "VGA" in data[each][1]: # GPUs + if "nvidia" not in data[each][2].lower(): + del data[each] + elif data[each][1].lower() in ("network controller", + "ethernet controller"): # Networking controllers (Wifi & Ethernet) + if "broadcom" in data[each][2].lower(): + continue + elif "realtek" in data[each][2].lower(): + continue + del data[each] + + # now we have a list of JUST devices that need drivers + # now we need to figure out what drivers are suited to what generation of card and handle that accordingly. + + self.show_all() def onlanguageclicked(self, button): subprocess.Popen(["gnome-language-selector"]) From 6c4cc0f6b4a40dab0495c93085c15d3b060ae88a Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Thu, 17 Feb 2022 00:06:41 -0500 Subject: [PATCH 10/39] more work figuring out what drivers to allow We can't allow just any driver. We need to narrow things down to what drivers we recommend most. --- .../broadcom_driver_guide.json | 51 +++++++++++++++ etc/drauger-welcome/nvidia_driver_guide.json | 12 ++++ etc/drauger-welcome/realtek_driver_guide.json | 28 +++++++++ usr/bin/drauger-welcome | 1 + usr/share/drauger-welcome/main_ui.py | 63 +++++++++++++++++-- 5 files changed, 150 insertions(+), 5 deletions(-) create mode 100644 etc/drauger-welcome/broadcom_driver_guide.json create mode 100644 etc/drauger-welcome/nvidia_driver_guide.json create mode 100644 etc/drauger-welcome/realtek_driver_guide.json create mode 120000 usr/bin/drauger-welcome diff --git a/etc/drauger-welcome/broadcom_driver_guide.json b/etc/drauger-welcome/broadcom_driver_guide.json new file mode 100644 index 0000000..74ce1f3 --- /dev/null +++ b/etc/drauger-welcome/broadcom_driver_guide.json @@ -0,0 +1,51 @@ +{ + "firmware-b43-installer": [ + "1713", + "4301", + "4306", + "4307", + "4311", + "4312", + "4313", + "4315", + "4318", + "4319", + "4320", + "4321", + "4324", + "4325", + "4328", + "4331", + "4335", + "4350", + "4359", + "4360", + "4365", + "43a3", + "43ba", + "a962" + ], + "bcmwl-kernel-source": [ + "4329", + "432a", + "432b", + "432c", + "432d", + "4358", + "43a0", + "43b1", + "4727", + "4328 (rev 03)", + "4365 (rev 01)" + ], + "1": [ + "0576", + "4353", + "4357", + "4353 (rev 01)", + "4727 (rev 01)" + ], + "2": [ + "43c3 (rev 04)" + ] +} diff --git a/etc/drauger-welcome/nvidia_driver_guide.json b/etc/drauger-welcome/nvidia_driver_guide.json new file mode 100644 index 0000000..c037034 --- /dev/null +++ b/etc/drauger-welcome/nvidia_driver_guide.json @@ -0,0 +1,12 @@ +{ + "30": "latest", + "20": "latest", + "16": "latest", + "10": "", + "9": "", + "8": "470", + "7": "470", + "6": "470", + "5": "390", + "4": "390" +} diff --git a/etc/drauger-welcome/realtek_driver_guide.json b/etc/drauger-welcome/realtek_driver_guide.json new file mode 100644 index 0000000..3f2f96e --- /dev/null +++ b/etc/drauger-welcome/realtek_driver_guide.json @@ -0,0 +1,28 @@ +{ + "r8125-dkms": [ + "r8125" + ], + "r8168-dkms": [ + "rtl8111b", + "rtl8111c", + "rtl8111d", + "rtl8111e", + "rtl8111f", + "rtl8111g(s)", + "rtl8111h(s)", + "rtl8118(a)(s)", + "rtl8119i", + "rtl8111l", + "rtl8168b", + "rtl8168e", + "rtl8168h", + "rtl8111dp", + "rtl8111ep", + "rtl8111fp", + "rtl8411", + "rtl8411b", + ], + "rtl8821ce-dkms": [ + "rtl8821ce" + ] +} diff --git a/usr/bin/drauger-welcome b/usr/bin/drauger-welcome new file mode 120000 index 0000000..70ecbb4 --- /dev/null +++ b/usr/bin/drauger-welcome @@ -0,0 +1 @@ +../share/drauger-welcome/main_ui.py \ No newline at end of file diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index a1364e8..91e5985 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -689,14 +689,14 @@ def open_wiki(self, button): subprocess.Popen(["xdg-open", "https://draugeros.org/go/wiki"]) def ondriveclicked(self, button): - self.clear_window() + # self.clear_window() # we need to make a window here to manage drivers # start off by getting all our PCI devices - devices = subprocess.check_output(["lspci", "-qmm"]).decode() + devices = subprocess.check_output(["lspci", "-qmmnn"]).decode() # we need to parse this so that we can check for devices in need of drivers # this will do most of that for us - devices = devices.split("\n") + data = devices.split("\n") for each in range(len(data) - 1, -1, -1): data[each] = shlex.split(data[each]) @@ -729,8 +729,61 @@ def ondriveclicked(self, button): # now we have a list of JUST devices that need drivers # now we need to figure out what drivers are suited to what generation of card and handle that accordingly. - - self.show_all() + drivers = {} + for each in data: + if "nvidia" in each[2].lower(): + if "nvidia" not in drivers: + drivers["nvidia"] = [] + device = each[3].split(" ") + for each1 in device: + if each1.isdigit(): + if len(each1) >= 4: + device = each1[:2] + else: + device = each1[0] + break + if device not in drivers["nvidia"]: + drivers["nvidia"] = device + break + elif "broadcom" in each[2].lower(): + if "broadcom" not in drivers: + drivers["broadcom"] = [] + device = each[3].split(" ")[-1][1:-1] + if device not in drivers["broadcom"]: + drivers["broadcom"].append(device) + break + elif "realtek" in each[2].lower(): + if "realtek" not in drivers: + drivers["realtek"] = [] + device = each[3].split(" ")[0].lower() + if device not in drivers["realtek"]: + drivers["realtek"].append(device) + break + + guide = {} + if "nvidia" in drivers: + with open("../../../etc/drauger-welcome/nvidia_driver_guide.json", + "r") as file: + guide.update({"nvidia": json.load(file)}) + if "broadcom" in drivers: + with open("../../../etc/drauger-welcome/broadcom_driver_guide.json", + "r") as file: + guide.update({"broadcom": json.load(file)}) + if "realtek" in drivers: + with open("../../../etc/drauger-welcome/realtek_driver_guide.json", + "r") as file: + guide.update({"realtek": json.load(file)}) + + # we now have all the data and correlations to figure out what driver we need where + # just need to actually follow the correlations + to_install = [] + if "nvidia" in drivers: + to_install.append(f"nvidia-driver-{guide['nvidia'][drivers['nvidia']]}") + print(json.dumps(drivers, indent=2)) + print(json.dumps(guide, indent=2)) + print(to_install) + + # self.show_all() def onlanguageclicked(self, button): subprocess.Popen(["gnome-language-selector"]) From b9555f365f425841adff88131ef5d580456f58a4 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 18 Feb 2022 00:04:24 -0500 Subject: [PATCH 11/39] UI improvements --- DEBIAN/control | 2 +- usr/share/drauger-welcome/main_ui.py | 121 ++++++++++++++------------- 2 files changed, 62 insertions(+), 61 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index d251c6d..b5034f8 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: drauger-welcome -Version: 4.9.4 +Version: 4.9.5 Maintainer: Thomas Castleman Section: misc Homepage: https://github.com/drauger-os-development/drauger-welcome diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index 91e5985..702830e 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -576,73 +576,66 @@ def onhelpclicked(self, button): self.clear_window() - self.label = Gtk.Label() - self.label.set_markup(HELP) - self.label.set_justify(Gtk.Justification.CENTER) - self.grid.attach(self.label, 1, 3, 3, 1) - - self.label2 = Gtk.Label() - self.label2.set_markup(""" + label = Gtk.Label() + label.set_markup(HELP) + label.set_justify(Gtk.Justification.CENTER) + label = self._set_default_margins(label) + self.grid.attach(label, 1, 3, 3, 1) + + label2 = Gtk.Label() + label2.set_markup(""" Telegram """) - self.label2.set_justify(Gtk.Justification.CENTER) - self.grid.attach(self.label2, 1, 4, 1, 1) + label2.set_justify(Gtk.Justification.CENTER) + label2 = self._set_default_margins(label2) + self.grid.attach(label2, 1, 4, 1, 1) - self.label3 = Gtk.Label() - self.label3.set_markup(""" + label3 = Gtk.Label() + label3.set_markup(""" Discord """) - self.label3.set_justify(Gtk.Justification.CENTER) - self.grid.attach(self.label3, 3, 4, 1, 1) - - self.label5 = Gtk.Label() - self.label5.set_markup(help_yourself) - self.label5.set_justify(Gtk.Justification.CENTER) - self.grid.attach(self.label5, 1, 1, 3, 1) - - self.label6 = Gtk.Label() - self.label6.set_markup(""" + label3.set_justify(Gtk.Justification.CENTER) + label3 = self._set_default_margins(label3) + self.grid.attach(label3, 3, 4, 1, 1) + + label5 = Gtk.Label() + label5.set_markup(help_yourself) + label5.set_justify(Gtk.Justification.CENTER) + label5 = self._set_default_margins(label5) + self.grid.attach(label5, 1, 1, 3, 1) + + label6 = Gtk.Label() + label6.set_markup(""" myDrauger Support System """) - self.label6.set_justify(Gtk.Justification.CENTER) - self.grid.attach(self.label6, 2, 4, 1, 1) - - self.button2 = Gtk.Button.new_with_label(label="%s Telegram" % (Open)) - self.button2.connect("clicked", self.open_telegram) - self.grid.attach(self.button2, 1, 5, 1, 1) - - self.button3 = Gtk.Button.new_with_label(label="%s Discord" % (Open)) - self.button3.connect("clicked", self.open_discord) - self.grid.attach(self.button3, 3, 5, 1, 1) - - self.button5 = Gtk.Button.new_with_label(label="%s Drauger OS Wiki" % (Open)) - self.button5.connect("clicked", self.open_wiki) - self.grid.attach(self.button5, 1, 2, 3, 1) - - self.button6 = Gtk.Button.new_with_label(label="%s myDrauger" % (Open)) - self.button6.connect("clicked", self.open_mydrauger) - self.grid.attach(self.button6, 2, 5, 1, 1) - - self.button1 = Gtk.Button.new_with_label(label=Back) - self.button1.connect("clicked", self.reset) - self.grid.attach(self.button1, 1, 20, 1, 1) - - width = self.get_size()[0] - width = int(width * 0.025) - self.button5.set_margin_start(width) - self.button5.set_margin_end(width) - self.button2.set_margin_start(width) - self.button2.set_margin_end(width) - self.button3.set_margin_start(width) - self.button3.set_margin_end(width) - self.button6.set_margin_end(width) - self.button6.set_margin_start(width) - self.button1.set_margin_start(width) - self.button1.set_margin_end(width) - self.button1.set_margin_top(width) - self.button1.set_margin_bottom(width) - # self.button1.set_margin_top(int(width / 2)) - # self.button1.set_margin_bottom(int(width / 2)) + label6.set_justify(Gtk.Justification.CENTER) + label6 = self._set_default_margins(label6) + self.grid.attach(label6, 2, 4, 1, 1) + + button2 = Gtk.Button.new_with_label(label="%s Telegram" % (Open)) + button2.connect("clicked", self.open_telegram) + button2 = self._set_default_margins(button2) + self.grid.attach(button2, 1, 5, 1, 1) + + button3 = Gtk.Button.new_with_label(label="%s Discord" % (Open)) + button3.connect("clicked", self.open_discord) + button3 = self._set_default_margins(button3) + self.grid.attach(button3, 3, 5, 1, 1) + + button5 = Gtk.Button.new_with_label(label="%s Drauger OS Wiki" % (Open)) + button5.connect("clicked", self.open_wiki) + button5 = self._set_default_margins(button5) + self.grid.attach(button5, 1, 2, 3, 1) + + button6 = Gtk.Button.new_with_label(label="%s myDrauger" % (Open)) + button6.connect("clicked", self.open_mydrauger) + button6 = self._set_default_margins(button6) + self.grid.attach(button6, 2, 5, 1, 1) + + button1 = Gtk.Button.new_with_label(label=Back) + button1.connect("clicked", self.reset) + button1 = self._set_default_margins(button1) + self.grid.attach(button1, 1, 20, 1, 1) self.show_all() @@ -664,6 +657,14 @@ def open_discord(self, button): subprocess.check_call(["snap", "install", "discord"]) subprocess.Popen(["discord", "https://discord.gg/JW8FGrc"]) + def _set_default_margins(self, widget): + """Set default margin size""" + widget.set_margin_start(10) + widget.set_margin_end(10) + widget.set_margin_top(10) + widget.set_margin_bottom(10) + return widget + def open_mydrauger(self, button): subprocess.Popen(["xdg-open", "https://draugeros.org/go/my"]) From 13ba74a0b631fda03fc2f0f1d8957f928c7807cc Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 18 Feb 2022 00:04:50 -0500 Subject: [PATCH 12/39] begin work to make actual UI for driver window --- usr/share/drauger-welcome/main_ui.py | 54 +++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index 702830e..aa2b019 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -690,7 +690,7 @@ def open_wiki(self, button): subprocess.Popen(["xdg-open", "https://draugeros.org/go/wiki"]) def ondriveclicked(self, button): - # self.clear_window() + self.clear_window() # we need to make a window here to manage drivers # start off by getting all our PCI devices @@ -777,14 +777,58 @@ def ondriveclicked(self, button): # we now have all the data and correlations to figure out what driver we need where # just need to actually follow the correlations - to_install = [] + to_install = {} if "nvidia" in drivers: - to_install.append(f"nvidia-driver-{guide['nvidia'][drivers['nvidia']]}") + to_install[f"nvidia-driver-{guide['nvidia'][drivers['nvidia']]}"] = {"installed": None, "desc": ""} + + # check and see if the package is already installed. If it is, then the user is good to go + # so delete the package from the list + cache = apt.cache.Cache() + cache.open() + installed = False + with cache.actiongroup(): + for pkg in to_install: + for each in cache: + if pkg == each.name: + to_install[pkg]["installed"] = each.is_installed + to_install[pkg]["desc"] = each.versions[0].description print(json.dumps(drivers, indent=2)) print(json.dumps(guide, indent=2)) - print(to_install) + print(json.dumps(to_install, indent=2)) + + label = Gtk.Label() + label.set_markup("Below are all the drivers we suggest for your system") + label.set_justify(Gtk.Justification.CENTER) + label = self._set_default_margins(label) + self.grid.attach(label, 1, 1, 3, 1) + + label1 = Gtk.Label() + label1.set_markup("Alternatively, you may use Synaptic Package Manager to install drivers yourself.") + label1.set_justify(Gtk.Justification.CENTER) + label1 = self._set_default_margins(label1) + self.grid.attach(label1, 1, 2, 3, 1) + + # labels detailing all drivers + + button1 = Gtk.Button.new_with_label(label=Back) + button1.connect("clicked", self.reset) + button1 = self._set_default_margins(button1) + self.grid.attach(button1, 1, 20, 1, 1) + + button2 = Gtk.Button.new_with_label(label="Install Drivers") + button2.connect("clicked", self.reset) + button2 = self._set_default_margins(button2) + self.grid.attach(button2, 2, 20, 1, 1) + + button3 = Gtk.Button.new_with_label(label="Open Synaptic") + button3.connect("clicked", self.open_synaptic) + button3 = self._set_default_margins(button3) + self.grid.attach(button3, 3, 20, 1, 1) + + self.show_all() - # self.show_all() + def open_synaptic(self, button): + subprocess.Popen(["synaptic-pkexec"]) def onlanguageclicked(self, button): subprocess.Popen(["gnome-language-selector"]) From 96f6700f0d132e7f6a63014827703d3011eb83a3 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 23 Feb 2022 22:50:32 -0500 Subject: [PATCH 13/39] complete driver window --- usr/share/drauger-welcome/main_ui.py | 154 +++++++++++++++++++++++++-- 1 file changed, 143 insertions(+), 11 deletions(-) diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index aa2b019..bdb1b01 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -208,12 +208,16 @@ class welcome(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="Welcome to Drauger OS") - self.grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL,) + self.grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL) self.add(self.grid) - # self.set_icon_from_file("/usr/share/icons/Drauger/scalable/menus/drauger_os-logo.svg") + self.icon = "/usr/share/icons/Drauger/scalable/menus/drauger_os-logo.svg" + self.set_icon_from_file(self.icon) + self.drivers = [] self.reset("clicked") + + def reset(self, button): global show_at_start_up @@ -792,41 +796,168 @@ def ondriveclicked(self, button): if pkg == each.name: to_install[pkg]["installed"] = each.is_installed to_install[pkg]["desc"] = each.versions[0].description - print(json.dumps(drivers, indent=2)) - print(json.dumps(guide, indent=2)) - print(json.dumps(to_install, indent=2)) + + # this makes an if-statement later on easier to write + all_installed = True + for each in to_install: + if not to_install[each]["installed"]: + all_installed = False + break + + self.drivers = to_install label = Gtk.Label() label.set_markup("Below are all the drivers we suggest for your system") label.set_justify(Gtk.Justification.CENTER) label = self._set_default_margins(label) - self.grid.attach(label, 1, 1, 3, 1) + self.grid.attach(label, 1, 1, 5, 1) label1 = Gtk.Label() label1.set_markup("Alternatively, you may use Synaptic Package Manager to install drivers yourself.") label1.set_justify(Gtk.Justification.CENTER) label1 = self._set_default_margins(label1) - self.grid.attach(label1, 1, 2, 3, 1) + self.grid.attach(label1, 1, 2, 5, 1) + + label2 = Gtk.Label() + label2.set_markup("Package Name") + label2.set_justify(Gtk.Justification.CENTER) + label2 = self._set_default_margins(label2) + self.grid.attach(label2, 1, 4, 1, 1) + + label3 = Gtk.Label() + label3.set_markup("Description") + label3.set_justify(Gtk.Justification.CENTER) + label3 = self._set_default_margins(label3) + self.grid.attach(label3, 3, 4, 1, 1) + + label4 = Gtk.Label() + label4.set_markup("Installation Status") + label4.set_justify(Gtk.Justification.CENTER) + label4 = self._set_default_margins(label4) + self.grid.attach(label4, 5, 4, 1, 1) + + sep = Gtk.Separator.new(Gtk.Orientation.HORIZONTAL) + sep = self._set_default_margins(sep) + self.grid.attach(sep, 1, 5, 5, 1) # labels detailing all drivers + x = 1 + y = 6 + for each in to_install: + label = Gtk.Label() + label.set_markup(f"{each}") + label.set_justify(Gtk.Justification.CENTER) + label = self._set_default_margins(label) + self.grid.attach(label, x, y, 1, 1) + + label = Gtk.Label() + label.set_markup(f"{to_install[each]['desc']}") + label.set_justify(Gtk.Justification.CENTER) + label = self._set_default_margins(label) + self.grid.attach(label, x + 2, y, 1, 1) + + label = Gtk.Label() + if to_install[each]["installed"]: + label.set_markup("Installed") + else: + label.set_markup("Installed") + label.set_justify(Gtk.Justification.CENTER) + label = self._set_default_margins(label) + self.grid.attach(label, x + 4, y, 1, 1) + + y += 1 + + sep = Gtk.Separator.new(Gtk.Orientation.VERTICAL) + sep = self._set_default_margins(sep) + self.grid.attach(sep, 2, 4, 1, y) + + sep = Gtk.Separator.new(Gtk.Orientation.VERTICAL) + sep = self._set_default_margins(sep) + self.grid.attach(sep, 4, 4, 1, y) button1 = Gtk.Button.new_with_label(label=Back) button1.connect("clicked", self.reset) button1 = self._set_default_margins(button1) self.grid.attach(button1, 1, 20, 1, 1) - button2 = Gtk.Button.new_with_label(label="Install Drivers") - button2.connect("clicked", self.reset) + if not all_installed: + button2 = Gtk.Button.new_with_label(label="Install Missing Drivers") + button2.connect("clicked", self.install_missing_drivers) + else: + button2 = Gtk.Label() + button2.set_markup("All Drivers Already Installed") button2 = self._set_default_margins(button2) - self.grid.attach(button2, 2, 20, 1, 1) + self.grid.attach(button2, 3, 20, 1, 1) + button3 = Gtk.Button.new_with_label(label="Open Synaptic") button3.connect("clicked", self.open_synaptic) button3 = self._set_default_margins(button3) - self.grid.attach(button3, 3, 20, 1, 1) + self.grid.attach(button3, 5, 20, 1, 1) self.show_all() + def install_missing_drivers(self, button): + # setup + cmd = ["pkexec", "apt-get", "-y", "-o", + "Dpkg::Options::='--force-confold'", "--force-yes", "install"] + # filter down to just uninstalled drivers + to_install = [] + for each in self.drivers: + if self.drivers[each]["installed"]: + continue + to_install.append(each) + if len(to_install) <= 0: + return + cmd = cmd + to_install + # this is arguably the easiest way to do this + pid = os.fork() + if pid == 0: + # this will run as a seperate thread. It's safe to call exit() + try: + subprocess.check_call(cmd) + except subprocess.CalledProcessError: + subprocess.check_call(["notify-send", "-i", self.icon, "-a", + "Drauger OS Welcome Screen", + "Driver Installation Error", + "Installing Drivers Encountered An Error. Please contact support."]) + exit(2) + subprocess.check_call(["notify-send", "-i", self.icon, "-a", + "Drauger OS Welcome Screen", + "Driver Installation Success", + "Drivers Successfully Installed. Please Reboot for changes to take effect."]) + exit(0) + self.post_install_window() + + def post_install_window(self): + self.clear_window() + + label1 = Gtk.Label() + label1.set_markup("Installing Drivers") + label1.set_justify(Gtk.Justification.CENTER) + label1 = self._set_default_margins(label1) + self.grid.attach(label1, 1, 1, 4, 1) + + label2 = Gtk.Label() + label2.set_markup("Please give the background process about 10 minutes max in order to install your drivers for you.") + label2.set_justify(Gtk.Justification.CENTER) + label2 = self._set_default_margins(label2) + self.grid.attach(label2, 1, 2, 4, 1) + + label3 = Gtk.Label() + label3.set_markup("If you do not receive a notification about how installation went, please check System Monitor to see if installation is still ongoing.") + label3.set_justify(Gtk.Justification.CENTER) + label3 = self._set_default_margins(label3) + self.grid.attach(label3, 1, 3, 4, 1) + + button1 = Gtk.Button.new_with_label(label=Back) + button1.connect("clicked", self.reset) + button1 = self._set_default_margins(button1) + self.grid.attach(button1, 1, 20, 1, 1) + + self.show_all() + + def open_synaptic(self, button): subprocess.Popen(["synaptic-pkexec"]) @@ -1050,6 +1181,7 @@ def clear_window(self): for each in children: self.grid.remove(each) + def welcome_show(): window = welcome() window.set_decorated(True) From 220e97e2f381e9b84859023976206aab0423d6e3 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 23 Feb 2022 22:50:50 -0500 Subject: [PATCH 14/39] import all of `os` module --- usr/share/drauger-welcome/main_ui.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index bdb1b01..9f98a7f 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -25,13 +25,13 @@ import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk -from os import system, path, getenv, remove +import os import subprocess import json import shlex import apt -LANG = getenv("LANG").split(".") +LANG = os.getenv("LANG").split(".") LANG = LANG[0] try: @@ -192,8 +192,8 @@ Open = "Open" -HOME = getenv("HOME") -if (not path.exists("%s/.drauger-tut" % (HOME))): +HOME = os.getenv("HOME") +if (not os.path.exists("%s/.drauger-tut" % (HOME))): show_at_start_up = True else: show_at_start_up = False @@ -528,7 +528,7 @@ def onlangsupportclicked(self, button): self.show_all() def install_locale_packages(self, button): - lang = getenv("LANG").split(".") + lang = os.getenv("LANG").split(".") lang = lang[0] lang = lang.split("_") lang = "-".join(lang).lower() @@ -1171,8 +1171,8 @@ def exit(self, button): flagfile.write("") flagfile.close() else: - if (path.exists("%s/.drauger-tut" % (HOME))): - remove("%s/.drauger-tut" % (HOME)) + if (os.path.exists("%s/.drauger-tut" % (HOME))): + os.remove("%s/.drauger-tut" % (HOME)) print(1) exit(1) From 73c715fb7bbdbf85262c90cd44d61ca847696618 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 25 Feb 2022 20:48:18 -0500 Subject: [PATCH 15/39] add driver installation confirmation window --- usr/share/drauger-welcome/main_ui.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index 9f98a7f..886d160 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -882,7 +882,7 @@ def ondriveclicked(self, button): if not all_installed: button2 = Gtk.Button.new_with_label(label="Install Missing Drivers") - button2.connect("clicked", self.install_missing_drivers) + button2.connect("clicked", self.driver_install_confirmation) else: button2 = Gtk.Label() button2.set_markup("All Drivers Already Installed") @@ -897,6 +897,31 @@ def ondriveclicked(self, button): self.show_all() + def driver_install_confirmation(self, button): + self.clear_window() + + label = Gtk.Label() + label.set_markup("Are you sure you want to install the following packages?") + label = self._set_default_margins(label) + self.grid.attach(label, 1, 1, 3, 1) + + label2 = Gtk.Label() + label2.set_markup(", ".join(self.drivers)) + label2 = self._set_default_margins(label2) + self.grid.attach(label2, 1, 2, 3, 1) + + button = Gtk.Button.new_with_label(label="Cancel") + button.connect("clicked", self.reset) + button = self._set_default_margins(button) + self.grid.attach(button, 1, 3, 1, 1) + + button2 = Gtk.Button.new_with_label(label="Install Missing Drivers") + button2.connect("clicked", self.install_missing_drivers) + button2 = self._set_default_margins(button2) + self.grid.attach(button2, 3, 3, 1, 1) + + self.show_all() + def install_missing_drivers(self, button): # setup cmd = ["pkexec", "apt-get", "-y", "-o", From 546c2cbe84cdacfa1aac25146a39b5605b306303 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 25 Feb 2022 21:03:10 -0500 Subject: [PATCH 16/39] minor bug fix for tutorial --- usr/share/drauger-welcome/main_ui.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index 886d160..fa813fd 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -1149,6 +1149,8 @@ def onclicked(self, button): self.label.set_markup(tut_6) elif self.check == 7: self.multi_desktop("clicked") + elif self.check < -1: + self.reset("clicked") def multi_desktop(self, button): From 66c87f15154eeed53e67f54952236a03f4e8957c Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 25 Feb 2022 21:57:56 -0500 Subject: [PATCH 17/39] revamp text in tutorial --- usr/share/drauger-welcome/main_ui.py | 52 +++++++++++++++++----------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index fa813fd..fbaff88 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -136,8 +136,6 @@ tut_4 = each[1] elif (each[0] == "tut_5"): tut_5 = each[1] - elif (each[0] == "tut_6"): - tut_6 = each[1] elif (each[0] == "multi_ask"): multi_ask = each[1] elif (each[0] == "lang_sup3"): @@ -147,7 +145,11 @@ except FileNotFoundError: message_show_remove = "\n\tThank you again for using Drauger OS. Would you like to uninstall drauger-welcome?\t\n" - message_show_tutorial = "\n\tThank you for downloading and installing Drauger OS, the free Linux gaming OS.\t\n" + message_show_tutorial = """ +\tThank you for downloading and installing Drauger OS, the free Linux gaming OS.\t + +\tIn this tutorial, you will recive a quick introduction regarding how to work Drauger OS.\t +""" message_show_multi_desktop = "Having multiple desktops is the ability to switch back and forth between two 'desktops'.\n\tThis ability enables you to hide windows and tabs for apps on one desktop while you work in another.\t\n" welcome_label = "Welcome! Thank you for choosing Drauger OS.\n\tWe hope you'll enjoy gaming on it as much as we enjoyed developing it.\n\tPlease make yourself familiar with the new features, layout, and documentation.\n\tPlease, don't hesitate to send us your feedback, it's greatly appreciated!\n\n\tThe default admin password is 'toor'." website = "\n\tDrauger OS website\t\n" @@ -179,13 +181,27 @@ sc_5 = "\n\tLock Screen\t\n" Next = "Next -->" Exit = "Exit" - tut_0 = "\n\tIn this tutorial, you will recive a quick introduction regarding how to work Drauger OS. \n" - tut_1 = "\n\tThe bars on the top, left, and bottom of your screen are your desktop panels.\t\n\tThe left contains quick access to some the most commonly used apps and widgets.\t\n\tThe top one contains the the main menu, on the far left when you click on the Drauger OS logo,\t\n\tand the log out menu on the far right under your username.\t\n\tThe bottom pannel gives you a quick view of what's on each desktop, but more on that later.\t\n" - tut_2 = "\n\tIn order to see any apps in the left desktop panel that are not\t\n\tcurrently on display, simply click on the drop down arrow underneath\t\n\tthe icon\t\n" - tut_3 = "\n\tIn order to see any apps not on the left desktop panel, click the Drauger OS Logo\t\n\ton the far left of the top panel.\t\n" - tut_4 = "\n\tDrauger OS also has support for not only keyboards and mice,\t\n\tas well as touchpads and touchscreens,\t\n\tit also has support for most Xbox and Xbox 360 controllers,\t\n\tas well as some Playstation controllers.\t\n" - tut_5 = "\n\tFinally, the four rectangles on the bottom of your screen are the four current desktops.\t\n\tYou may not be able to see them very well considering they blend into the default wallpaper.\t\n" - tut_6 = "\n\tIf you wish to learn more about how to use the Drauger OS desktop, please visit:\n\t https://draugeros.org/go/wiki/basics-of-the-drauger-os-desktop/ \n\t" + tut_1 = """ +\tThe bars on the top, left, and bottom of your screen are your desktop panels.\t +""" + tut_2 = """ +\tThis top bar provides the applications menu (the Drauger OS logo), clock, and power menu (accessed by clicking your username)\t +""" + tut_3 = """ +\tThis left bar contains links, or launchers, for Steam, Firefox, and the Software Center.\t +\tAlso, under the launchers for Steam and the Software Center, the arrows pointing to your right open sub-menus.\t +\tThese allow you quicker access to other, related, apps.\t +""" + tut_4 = """ +\tFinally, this bottom panel provides you with a quick view of what is on each virtual desktop,\t +\tas well as the ability to switch between them using your mouse.\t + +\tMore on virtual desktops later.\t +""" + tut_5 = """ +\tIf you wish to learn more about how to use the Drauger OS desktop, please visit: +\t https://draugeros.org/go/wiki/basics-of-the-drauger-os-desktop/ +\t""" multi_ask = "\n\tWould you like to learn more about multiple desktops?\t\n" lang_sup3 = "\n\tInstall locale packages.\t\n" lang_sup4 = "\n\tMulti-lingual support settings.\t\n" @@ -1132,22 +1148,18 @@ def onclicked(self, button): elif (button.get_label() == Back): self.check = self.check - 1 if self.check == -1: - self.label.set_text(message_show_tutorial) + self.label.set_markup(message_show_tutorial) elif self.check == 0: - self.label.set_text(tut_0) + self.label.set_markup(tut_1) elif self.check == 1: - self.label.set_text(tut_1) + self.label.set_markup(tut_2) elif self.check == 2: - self.label.set_text(tut_2) + self.label.set_markup(tut_3) elif self.check == 3: - self.label.set_text(tut_3) + self.label.set_markup(tut_4) elif self.check == 4: - self.label.set_text(tut_4) + self.label.set_markup(tut_5) elif self.check == 5: - self.label.set_text(tut_5) - elif self.check == 6: - self.label.set_markup(tut_6) - elif self.check == 7: self.multi_desktop("clicked") elif self.check < -1: self.reset("clicked") From 4dc408dc2fcbde10bf78bd650f367f317715309b Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 25 Feb 2022 21:59:18 -0500 Subject: [PATCH 18/39] improve overall look and feel of UI use margins everywhere to create appropriate amount of negative space --- usr/share/drauger-welcome/main_ui.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index fbaff88..01abb49 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -399,14 +399,17 @@ def removal_conf(self, button): self.label = Gtk.Label() self.label.set_markup(message_show_remove) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 1, 3, 1) self.button1 = Gtk.Button.new_with_label(label=YES) self.button1.connect("clicked", self.onuninstallclicked) + self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 1, 2, 1, 1) self.button2 = Gtk.Button.new_with_label(label=NO) self.button2.connect("clicked", self.reset) + self.button2 = self._set_default_margins(self.button2) self.grid.attach(self.button2, 3, 2, 1, 1) self.show_all() @@ -576,9 +579,9 @@ def install_locale_packages(self, button): def onnextclicked(self, button): if self.check == 0: - self.label.set_text(multi_0) + self.label.set_markup(multi_0) elif self.check == 1: - self.label.set_text(multi_1) + self.label.set_markup(multi_1) elif self.check == 2: self.removal_conf("clicked") else: @@ -1126,18 +1129,22 @@ def tutorial(self, button): self.label = Gtk.Label() self.label.set_markup(message_show_tutorial) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 1, 3, 1) self.button1 = Gtk.Button.new_with_label(label=Next) self.button1.connect("clicked", self.onclicked) + self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 3, 2, 1, 1) self.button2 = Gtk.Button.new_with_label(label=Back) self.button2.connect("clicked", self.onclicked) + self.button2 = self._set_default_margins(self.button2) self.grid.attach(self.button2, 1, 2, 1, 1) self.button3 = Gtk.Button.new_with_label(label=Exit) self.button3.connect("clicked", self.reset) + self.button3 = self._set_default_margins(self.button3) self.grid.attach(self.button3, 2, 2, 1, 1) self.show_all() @@ -1171,14 +1178,17 @@ def multi_desktop(self, button): self.label = Gtk.Label() self.label.set_markup(multi_ask) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 1, 3, 1) self.button1 = Gtk.Button.new_with_label(label=YES) self.button1.connect("clicked", self.onmultiyesclicked) + self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 1, 2, 1, 1) self.button2 = Gtk.Button.new_with_label(label=NO) self.button2.connect("clicked", self.onmultinoclicked) + self.button2 = self._set_default_margins(self.button2) self.grid.attach(self.button2, 3, 2, 1, 1) self.show_all() @@ -1190,10 +1200,12 @@ def onmultiyesclicked(self, button): self.label = Gtk.Label() self.label.set_markup(message_show_multi_desktop) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 1, 3, 1) self.button1 = Gtk.Button.new_with_label(label=Next) self.button1.connect("clicked", self.onnextclicked) + self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 3, 2, 1, 1) self.show_all() From a0ba0bd4d62e20c8e2c5a40c9ce8fde894250cc3 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 25 Feb 2022 21:59:40 -0500 Subject: [PATCH 19/39] Remove unncessary function --- usr/share/drauger-welcome/main_ui.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index 01abb49..f1c4824 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -1187,7 +1187,7 @@ def multi_desktop(self, button): self.grid.attach(self.button1, 1, 2, 1, 1) self.button2 = Gtk.Button.new_with_label(label=NO) - self.button2.connect("clicked", self.onmultinoclicked) + self.button2.connect("clicked", self.removal_conf) self.button2 = self._set_default_margins(self.button2) self.grid.attach(self.button2, 3, 2, 1, 1) @@ -1210,9 +1210,6 @@ def onmultiyesclicked(self, button): self.show_all() - def onmultinoclicked(self, button): - self.removal_conf("clicked") - def exit(self, button): global show_at_start_up global HOME From ced75a693d6ca4cb5ef199a7aa2525ee738f7dbc Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 25 Feb 2022 21:59:54 -0500 Subject: [PATCH 20/39] very minor PEP8 improvements --- usr/share/drauger-welcome/main_ui.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index f1c4824..5d6b6f8 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -393,7 +393,6 @@ def start_up_toggle(self, widget): print(show_at_start_up) def removal_conf(self, button): - self.clear_window() self.label = Gtk.Label() @@ -596,7 +595,6 @@ def onwebclicked(self, button): subprocess.Popen(["/usr/bin/xdg-open", "https://draugeros.org/go"]) def onhelpclicked(self, button): - self.clear_window() label = Gtk.Label() @@ -1172,7 +1170,6 @@ def onclicked(self, button): self.reset("clicked") def multi_desktop(self, button): - self.clear_window() self.label = Gtk.Label() From bdd1a858ca3afbfd0a7ebaf2b58b9085164991bd Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 25 Feb 2022 23:21:59 -0500 Subject: [PATCH 21/39] have tutorial window move around This is supposed to help draw a user's eye to the things being discussed. --- usr/share/drauger-welcome/main_ui.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index 5d6b6f8..2937e99 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -34,6 +34,11 @@ LANG = os.getenv("LANG").split(".") LANG = LANG[0] +results = subprocess.Popen(['xrandr'], stdout=subprocess.PIPE).communicate()[0] +results = results.decode().split("current")[1].split(",")[0] +width = int(results.split("x")[0].strip()) +height = int(results.split("x")[1].strip()) + try: try: with open("/etc/drauger-locales/%s/drauger-installer.conf" % (LANG), @@ -1120,7 +1125,6 @@ def onnoclicked(self, button): self.reset("clicked") def tutorial(self, button): - self.clear_window() self.check = -1 @@ -1157,18 +1161,26 @@ def onclicked(self, button): elif self.check == 0: self.label.set_markup(tut_1) elif self.check == 1: + self.move((width / 2) - (self.get_size()[0] / 2), 65) self.label.set_markup(tut_2) elif self.check == 2: + self.move(95, (height / 2) - (self.get_size()[1] / 2)) self.label.set_markup(tut_3) elif self.check == 3: + self.move((width / 2) - (self.get_size()[0] / 2), + (height - 65) - self.get_size()[1]) self.label.set_markup(tut_4) elif self.check == 4: + self.move((width / 2) - (self.get_size()[0] / 2), + (height / 2) - (self.get_size()[1] / 2)) self.label.set_markup(tut_5) elif self.check == 5: self.multi_desktop("clicked") elif self.check < -1: self.reset("clicked") + self.show_all() + def multi_desktop(self, button): self.clear_window() From 1980ffd3174dee6a59d93419581ef7ab81c1d634 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 25 Feb 2022 23:27:06 -0500 Subject: [PATCH 22/39] adjust offset --- usr/share/drauger-welcome/main_ui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/share/drauger-welcome/main_ui.py index 2937e99..ec2ad16 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/share/drauger-welcome/main_ui.py @@ -1168,7 +1168,7 @@ def onclicked(self, button): self.label.set_markup(tut_3) elif self.check == 3: self.move((width / 2) - (self.get_size()[0] / 2), - (height - 65) - self.get_size()[1]) + (height - 155) - self.get_size()[1]) self.label.set_markup(tut_4) elif self.check == 4: self.move((width / 2) - (self.get_size()[0] / 2), From baf14206e60a70cf35d96afe92c305892ab952ba Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sat, 26 Feb 2022 22:30:05 -0500 Subject: [PATCH 23/39] drop support for difficult Broadcom cards These cards either require two drivers, or a binary firmware file that must be downloaded from elsewhere in order to run. I don't wanna screw with these edge cases. --- etc/drauger-welcome/broadcom_driver_guide.json | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/etc/drauger-welcome/broadcom_driver_guide.json b/etc/drauger-welcome/broadcom_driver_guide.json index 74ce1f3..71865c9 100644 --- a/etc/drauger-welcome/broadcom_driver_guide.json +++ b/etc/drauger-welcome/broadcom_driver_guide.json @@ -37,15 +37,5 @@ "4727", "4328 (rev 03)", "4365 (rev 01)" - ], - "1": [ - "0576", - "4353", - "4357", - "4353 (rev 01)", - "4727 (rev 01)" - ], - "2": [ - "43c3 (rev 04)" ] } From 6e09644f92303c7f89aa06adfc49b902c57f6171 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sat, 26 Feb 2022 23:25:58 -0500 Subject: [PATCH 24/39] Move main_ui.py to Python system library location This helps main_ui.py follow Python conventions better. --- .../dist-packages/drauger_welcome/__init__.py | 25 ++++++++ .../dist-packages/drauger_welcome}/main_ui.py | 57 +++++++++++-------- usr/share/drauger-welcome/tut.py | 2 +- 3 files changed, 59 insertions(+), 25 deletions(-) create mode 100755 usr/lib/python3/dist-packages/drauger_welcome/__init__.py rename usr/{share/drauger-welcome => lib/python3/dist-packages/drauger_welcome}/main_ui.py (96%) diff --git a/usr/lib/python3/dist-packages/drauger_welcome/__init__.py b/usr/lib/python3/dist-packages/drauger_welcome/__init__.py new file mode 100755 index 0000000..28a719a --- /dev/null +++ b/usr/lib/python3/dist-packages/drauger_welcome/__init__.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# __init__.py +# +# Copyright 2022 Thomas Castleman +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +# +# +"""__init__ for drauger-welcome""" +from drauger_welcome import main_ui as main_ui diff --git a/usr/share/drauger-welcome/main_ui.py b/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py similarity index 96% rename from usr/share/drauger-welcome/main_ui.py rename to usr/lib/python3/dist-packages/drauger_welcome/main_ui.py index ec2ad16..9ffec4e 100755 --- a/usr/share/drauger-welcome/main_ui.py +++ b/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py @@ -789,15 +789,16 @@ def ondriveclicked(self, button): guide = {} if "nvidia" in drivers: - with open("../../../etc/drauger-welcome/nvidia_driver_guide.json", + path = "/etc/drauger-welcome" + with open(f"{path}/nvidia_driver_guide.json", "r") as file: guide.update({"nvidia": json.load(file)}) if "broadcom" in drivers: - with open("../../../etc/drauger-welcome/broadcom_driver_guide.json", + with open(f"{path}/broadcom_driver_guide.json", "r") as file: guide.update({"broadcom": json.load(file)}) if "realtek" in drivers: - with open("../../../etc/drauger-welcome/realtek_driver_guide.json", + with open(f"{path}e/realtek_driver_guide.json", "r") as file: guide.update({"realtek": json.load(file)}) @@ -945,9 +946,6 @@ def driver_install_confirmation(self, button): self.show_all() def install_missing_drivers(self, button): - # setup - cmd = ["pkexec", "apt-get", "-y", "-o", - "Dpkg::Options::='--force-confold'", "--force-yes", "install"] # filter down to just uninstalled drivers to_install = [] for each in self.drivers: @@ -956,24 +954,35 @@ def install_missing_drivers(self, button): to_install.append(each) if len(to_install) <= 0: return - cmd = cmd + to_install - # this is arguably the easiest way to do this - pid = os.fork() - if pid == 0: - # this will run as a seperate thread. It's safe to call exit() - try: - subprocess.check_call(cmd) - except subprocess.CalledProcessError: - subprocess.check_call(["notify-send", "-i", self.icon, "-a", - "Drauger OS Welcome Screen", - "Driver Installation Error", - "Installing Drivers Encountered An Error. Please contact support."]) - exit(2) - subprocess.check_call(["notify-send", "-i", self.icon, "-a", - "Drauger OS Welcome Screen", - "Driver Installation Success", - "Drivers Successfully Installed. Please Reboot for changes to take effect."]) - exit(0) + subprocess.Popen(["pkexec", + "/usr/share/drauger-welcome/install_drivers.sh", + " ".join(to_install), + self.icon]) + # cmd = cmd + to_install + # # this is arguably the easiest way to do this + # pid = os.fork() + # if pid == 0: + # # this will run as a seperate thread. It's safe to call exit() + # for each in self.drivers: + # if "nvidia-driver-" in each: + # if each != "nvidia-driver-latest": + # with open("/etc/modprobe.d/blacklist-nvidia-nouveau.conf", + # "w") as file: + # file.write("blacklist nouveau\noptions nouveau modeset=0") + # break + # try: + # subprocess.check_call(cmd) + # except subprocess.CalledProcessError: + # subprocess.check_call(["notify-send", "-i", self.icon, "-a", + # "Drauger OS Welcome Screen", + # "Driver Installation Error", + # "Installing Drivers Encountered An Error. Please contact support."]) + # exit(2) + # subprocess.check_call(["notify-send", "-i", self.icon, "-a", + # "Drauger OS Welcome Screen", + # "Driver Installation Success", + # "Drivers Successfully Installed. Please Reboot for changes to take effect."]) + # exit(0) self.post_install_window() def post_install_window(self): diff --git a/usr/share/drauger-welcome/tut.py b/usr/share/drauger-welcome/tut.py index bd117fd..72cee6a 100755 --- a/usr/share/drauger-welcome/tut.py +++ b/usr/share/drauger-welcome/tut.py @@ -25,7 +25,7 @@ import sys from os import path, getenv from subprocess import Popen -import main_ui +import drauger_welcome.main_ui as main_ui # Make it easier for us to print to stderr def eprint(*args, **kwargs): From e5a70b8da11879af41cdc2bd376fe0a9a3d4cd1e Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sat, 26 Feb 2022 23:27:40 -0500 Subject: [PATCH 25/39] Create separate file to handle driver installations We need to do multiple things as root. It's better to put all that into one file, then call that file when needed, than it is to request root access multiple times. --- usr/share/drauger-welcome/install_drivers.sh | 51 ++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 usr/share/drauger-welcome/install_drivers.sh diff --git a/usr/share/drauger-welcome/install_drivers.sh b/usr/share/drauger-welcome/install_drivers.sh new file mode 100755 index 0000000..b947c96 --- /dev/null +++ b/usr/share/drauger-welcome/install_drivers.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# -*- coding: utf-8 -*- +# +# install_drivers.sh +# +# Copyright 2022 Thomas Castleman +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +# +# + +# This is here to install drivers as root for the welcome screen +driver_list="$1" +icon="$2" +cmd="apt-get -y -o Dpkg::Options::='--force-confold' --force-yes install" +for each in $driver_list; do + if "nvidia-driver-" == "${each:0:14}"; then + if "nvidia-driver-latest" != "$each"; then + echo -e "blacklist nouveau\noptions nouveau modeset=0" | tee /etc/modprobe.d/blacklist-nvidia-nouveau.conf + fi + break + fi +done +{ + $cmd $driver_list +} || { + notify-send -i "$icon" \ + -a "Drauger OS Welcome Screen" \ + "Driver Installation Error" \ + "Installing Drivers Encountered An Error. Please contact support." + exit 2 +} + +notify-send -i "$icon" \ + -a "Drauger OS Welcome Screen" \ + "Driver Installation Success" \ + "Drivers Successfully Installed. Please Reboot for changes to take effect." +exit 0 From 4160eb7c6dd241766e3ae2ab737e7fc8abf3b6d6 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sat, 26 Feb 2022 23:29:21 -0500 Subject: [PATCH 26/39] Create proper $PATH binary --- DEBIAN/control | 2 +- usr/bin/drauger-welcome | 68 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 2 deletions(-) mode change 120000 => 100755 usr/bin/drauger-welcome diff --git a/DEBIAN/control b/DEBIAN/control index b5034f8..a44a593 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: drauger-welcome -Version: 4.9.5 +Version: 4.9.6 Maintainer: Thomas Castleman Section: misc Homepage: https://github.com/drauger-os-development/drauger-welcome diff --git a/usr/bin/drauger-welcome b/usr/bin/drauger-welcome deleted file mode 120000 index 70ecbb4..0000000 --- a/usr/bin/drauger-welcome +++ /dev/null @@ -1 +0,0 @@ -../share/drauger-welcome/main_ui.py \ No newline at end of file diff --git a/usr/bin/drauger-welcome b/usr/bin/drauger-welcome new file mode 100755 index 0000000..34b93ff --- /dev/null +++ b/usr/bin/drauger-welcome @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# drauger-welcome +# +# Copyright 2022 Thomas Castleman +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +# +# +"""Explain what this program does here!!!""" +from __future__ import print_function +import sys +import drauger_welcome +VERSION = "4.9.6" +HELP = """ +drauger-welcome, Version %s +\t-h, --help print this help dialoge. +\t-v, --version print current version. +Pass nothing to show welcome screen. +""" +R = "\033[0;31m" +G = "\033[0;32m" +Y = "\033[1;33m" +NC = "\033[0m" + +def eprint(args, *kwargs, color=R): + """Print to stderr easier""" + print(color, file=sys.stderr, end="") + print(args, file=sys.stderr, *kwargs, end="") + print(NC, file=sys.stderr) + + +if sys.version_info[0] == 2: + eprint("Please run with Python 3 as Python 2 is End-of-Life.") + exit(2) + +# get length of argv +ARGC = len(sys.argv) + +def launch(): + drauger_welcome.main_ui.welcome_show() + + +if ARGC > 1: + if (sys.argv[1] == "-v" or sys.argv[1] == "--version"): + print("\n%s\n" % (VERSION)) + elif (sys.argv[1] == "-h" or sys.argv[1] == "--help"): + print(HELP % (VERSION)) + else: + eprint("Option %s not recognized." % (sys.argv[1])) + eprint(HELP % (VERSION), color=NC) +else: + launch() From 07d9e16a750b01c02a357c23254a3e784ac67d14 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Thu, 10 Mar 2022 18:21:28 -0500 Subject: [PATCH 27/39] initial support for GTK 4.0 --- DEBIAN/control | 4 +- .../dist-packages/drauger_welcome/main_ui.py | 251 +++++++++--------- 2 files changed, 128 insertions(+), 127 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index a44a593..11e166b 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,11 +1,11 @@ Package: drauger-welcome -Version: 4.9.6 +Version: 4.9.7 Maintainer: Thomas Castleman Section: misc Homepage: https://github.com/drauger-os-development/drauger-welcome Architecture: amd64 Priority: optional -Depends: python3 (>=3.5.1-3), gir1.2-gtk-3.0 (>=3.24.12-1ubuntu1), drauger-icons (>=0.0.2), bash, procps, xfconf, python3-apt +Depends: python3 (>=3.5.1-3), gir1.2-gtk-4.0 (>=4.6.1+ds-1ubuntu2), gir1.2-adw-1 (1.1~rc-1), drauger-icons (>=0.0.2), bash, procps, xfconf, python3-apt Replaces: drauger-tutorial (>=1.0) Breaks: drauger-tutorial (>=1.0) Description: Welcome screen and tutorial All-in-One for Drauger OS diff --git a/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py b/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py index 9ffec4e..3d15755 100755 --- a/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py +++ b/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py @@ -22,23 +22,29 @@ # MA 02110-1301, USA. # # +"""UI for drauger-welcome""" import gi -gi.require_version('Gtk', '3.0') -from gi.repository import Gtk +gi.require_version('Gtk', '4.0') +gi.require_version('Adw', '1') +from gi.repository import Gtk, Adw import os import subprocess import json import shlex import apt +# intitial multi-lingual support LANG = os.getenv("LANG").split(".") LANG = LANG[0] +# get screen resolution results = subprocess.Popen(['xrandr'], stdout=subprocess.PIPE).communicate()[0] results = results.decode().split("current")[1].split(",")[0] width = int(results.split("x")[0].strip()) height = int(results.split("x")[1].strip()) +# this is where we expand upon the multi-lingual support more. This relies upon +# the community, and as such will likely throw a FileNotFoundError fairly often try: try: with open("/etc/drauger-locales/%s/drauger-installer.conf" % (LANG), @@ -213,34 +219,50 @@ Open = "Open" +# Get the user's home directory, so we know where to look for the auto-start blocking flag file HOME = os.getenv("HOME") if (not os.path.exists("%s/.drauger-tut" % (HOME))): show_at_start_up = True else: show_at_start_up = False +# get current Drauger OS version +# this will likely get replaced with a call to lsb_release at some point try: with open("/usr/drauger/os-info.txt") as f: s = f.read() except Exception: s = "TEST" -class welcome(Gtk.Window): - def __init__(self): - Gtk.Window.__init__(self, title="Welcome to Drauger OS") +class MainWindow(Gtk.ApplicationWindow): + """The GUI itself""" + def __init__(self, *args, **kwargs): + super().__init__(title="Welcome to Drauger OS", *args, **kwargs) + self.set_resizable(False) self.grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL) - self.add(self.grid) + self.set_child(self.grid) self.icon = "/usr/share/icons/Drauger/scalable/menus/drauger_os-logo.svg" - self.set_icon_from_file(self.icon) + # not sure if this is the best way to handle this + print("ICON CHECK") + print("-" * 20) + for each in dir(Gtk.ApplicationWindow): + if "icon" in each: + print(each) + print("-" * 20) + print("REMOVE CHECK") + print("-" * 20) + for each in dir(self.grid): + if "clear" in each: + print(each) + self.set_icon_name("drauger_os-logo") + # self.set_icon_from_file(self.icon) self.drivers = [] + self.present() self.reset("clicked") - - def reset(self, button): - global show_at_start_up self.clear_window() @@ -250,142 +272,132 @@ def reset(self, button): Drauger OS %s """ % (s) + "") self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 1, 8, 1) self.label = Gtk.Label() self.label.set_markup(welcome_label) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 2, 8, 1) self.label1 = Gtk.Label() self.label1.set_markup(website) self.label1.set_justify(Gtk.Justification.CENTER) + self.label1 = self._set_default_margins(self.label1) self.grid.attach(self.label1, 1, 3, 1, 1) - self.button1 = Gtk.Button.new_from_icon_name("cs-network", 3) + self.button1 = Gtk.Button.new_from_icon_name("cs-network") self.button1.connect("clicked", self.onwebclicked) + self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 1, 4, 1, 1) self.label2 = Gtk.Label() self.label2.set_markup(README) self.label2.set_justify(Gtk.Justification.CENTER) + self.label2 = self._set_default_margins(self.label2) self.grid.attach(self.label2, 6, 3, 1, 1) - self.button2 = Gtk.Button.new_from_icon_name("document", 3) + self.button2 = Gtk.Button.new_from_icon_name("document") self.button2.connect("clicked", self.show_readme) + self.button2 = self._set_default_margins(self.button2) self.grid.attach(self.button2, 6, 4, 1, 1) self.label3 = Gtk.Label() self.label3.set_markup(tutorial_label) self.label3.set_justify(Gtk.Justification.CENTER) + self.label3 = self._set_default_margins(self.label3) self.grid.attach(self.label3, 1, 5, 1, 1) - self.button3 = Gtk.Button.new_from_icon_name("dictionary", 3) + self.button3 = Gtk.Button.new_from_icon_name("dictionary") self.button3.connect("clicked", self.tutorial) + self.button3 = self._set_default_margins(self.button3) self.grid.attach(self.button3, 1, 6, 1, 1) self.label4 = Gtk.Label() self.label4.set_markup(help_button) self.label4.set_justify(Gtk.Justification.CENTER) + self.label4 = self._set_default_margins(self.label4) self.grid.attach(self.label4, 1, 7, 1, 1) - self.button4 = Gtk.Button.new_from_icon_name("help", 3) + self.button4 = Gtk.Button.new_from_icon_name("help") self.button4.connect("clicked", self.onhelpclicked) + self.button4 = self._set_default_margins(self.button4) self.grid.attach(self.button4, 1, 8, 1, 1) self.label5 = Gtk.Label() self.label5.set_markup(drivers) self.label5.set_justify(Gtk.Justification.CENTER) + self.label5 = self._set_default_margins(self.label5) self.grid.attach(self.label5, 6, 7, 1, 1) - self.button5 = Gtk.Button.new_from_icon_name("jockey", 3) + self.button5 = Gtk.Button.new_from_icon_name("jockey") self.button5.connect("clicked", self.ondriveclicked) + self.button5 = self._set_default_margins(self.button5) self.grid.attach(self.button5, 6, 8, 1, 1) self.label6 = Gtk.Label() self.label6.set_markup(lang_sup) self.label6.set_justify(Gtk.Justification.CENTER) + self.label6 = self._set_default_margins(self.label6) self.grid.attach(self.label6, 4, 5, 1, 1) - self.button6 = Gtk.Button.new_from_icon_name("accessibility", 3) + self.button6 = Gtk.Button.new_from_icon_name("accessibility") self.button6.connect("clicked", self.show_accessibility_settings) + self.button6 = self._set_default_margins(self.button6) self.grid.attach(self.button6, 4, 6, 1, 1) self.label7 = Gtk.Label() self.label7.set_markup(donate) - self.label.set_justify(Gtk.Justification.CENTER) + self.label7.set_justify(Gtk.Justification.CENTER) + self.label7 = self._set_default_margins(self.label7) self.grid.attach(self.label7, 4, 7, 1, 1) - self.button7 = Gtk.Button.new_from_icon_name("money-manager-ex", 3) + self.button7 = Gtk.Button.new_from_icon_name("money-manager-ex") self.button7.connect("clicked", self.ondonateclicked) + self.button7 = self._set_default_margins(self.button7) self.grid.attach(self.button7, 4, 8, 1, 1) self.label8 = Gtk.Label() self.label8.set_markup(shortcuts) self.label8.set_justify(Gtk.Justification.CENTER) + self.label8 = self._set_default_margins(self.label8) self.grid.attach(self.label8, 6, 5, 1, 1) - self.button8 = Gtk.Button.new_from_icon_name("keyboard", 3) + self.button8 = Gtk.Button.new_from_icon_name("keyboard") self.button8.connect("clicked", self.onshortcutclicked) + self.button8 = self._set_default_margins(self.button8) self.grid.attach(self.button8, 6, 6, 1, 1) self.label9 = Gtk.Label() self.label9.set_markup(uninstall) self.label9.set_justify(Gtk.Justification.CENTER) + self.label9 = self._set_default_margins(self.label9) self.grid.attach(self.label9, 4, 9, 1, 1) - self.button9 = Gtk.Button.new_from_icon_name("delete", 3) + self.button9 = Gtk.Button.new_from_icon_name("delete") self.button9.connect("clicked", self.removal_conf) + self.button9 = self._set_default_margins(self.button9) self.grid.attach(self.button9, 4, 10, 1, 1) self.label10 = Gtk.Label() self.label10.set_markup(lang_sup2) self.label10.set_justify(Gtk.Justification.CENTER) + self.label10 = self._set_default_margins(self.label10) self.grid.attach(self.label10, 4, 3, 1, 1) - self.button10 = Gtk.Button.new_from_icon_name("preferences-desktop-locale", 3) + self.button10 = Gtk.Button.new_from_icon_name("preferences-desktop-locale") self.button10.connect("clicked", self.onlangsupportclicked) + self.button10 = self._set_default_margins(self.button10) self.grid.attach(self.button10, 4, 4, 1, 1) self.start_up = Gtk.CheckButton.new_with_label(start_up_label) self.start_up.set_active(show_at_start_up) self.start_up.connect("toggled", self.start_up_toggle) + self.start_up = self._set_default_margins(self.start_up) self.grid.attach(self.start_up, 1, 13, 2, 1) - width = self.get_size()[0] - width = int(width * 0.125) - self.button10.set_margin_start(width) - self.button10.set_margin_end(width) - self.button6.set_margin_start(width) - self.button6.set_margin_end(width) - self.button4.set_margin_start(width) - self.button2.set_margin_end(width) - self.button3.set_margin_start(width) - self.button1.set_margin_start(width) - self.button9.set_margin_end(width) - self.button9.set_margin_start(width) - self.button8.set_margin_end(width) - self.button7.set_margin_end(width) - self.button7.set_margin_start(width) - self.button5.set_margin_end(width) - self.label2.set_margin_end(width) - self.label8.set_margin_end(width) - self.label5.set_margin_end(width) - self.label7.set_margin_end(width) - self.label7.set_margin_start(width) - self.label4.set_margin_start(width) - self.label10.set_margin_start(width) - self.label9.set_margin_start(width) - self.label10.set_margin_end(width) - self.label9.set_margin_end(width) - self.label9.set_margin_start(width) - self.label6.set_margin_end(width) - self.label6.set_margin_start(width) - self.label1.set_margin_start(width) - self.start_up.set_margin_start(int(width / 2)) - self.start_up.set_margin_bottom(int(width / 2)) - - self.show_all() + self.show() def show_readme(self, widget): version = subprocess.check_output(["lsb_release", "-rs"]).decode() @@ -416,7 +428,7 @@ def removal_conf(self, button): self.button2 = self._set_default_margins(self.button2) self.grid.attach(self.button2, 3, 2, 1, 1) - self.show_all() + self.show() def show_accessibility_settings(self, button): self.clear_window() @@ -426,10 +438,12 @@ def show_accessibility_settings(self, button): \t\t%s\t\t\t """ % (lang_sup)) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 1, 2, 1) self.label3 = Gtk.Label() self.label3.set_markup(font) + self.label3 = self._set_default_margins(self.label3) self.grid.attach(self.label3, 1, 3, 1, 1) self.font_button = Gtk.FontButton() @@ -448,45 +462,26 @@ def show_accessibility_settings(self, button): # set font and size for button self.font_button.set_font(system_font) self.font_button.connect("font-set", self.set_font) + self.font_button = self._set_default_margins(self.font_button) self.grid.attach(self.font_button, 2, 3, 1, 1) self.label4 = Gtk.Label() self.label4.set_markup("%s" % (access_label)) self.label4.set_justify(Gtk.Justification.CENTER) + self.label4 = self._set_default_margins(self.label4) self.grid.attach(self.label4, 1, 4, 1, 1) - self.button6 = Gtk.Button.new_from_icon_name("accessibility", 3) + self.button6 = Gtk.Button.new_from_icon_name("accessibility") self.button6.connect("clicked", self.goto_accessibility) + self.button6 = self._set_default_margins(self.button6) self.grid.attach(self.button6, 2, 4, 1, 1) self.button1 = Gtk.Button.new_with_label(label=Back) self.button1.connect("clicked", self.reset) + self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 1, 20, 1, 1) - width = self.get_size()[0] - height = int(width * 0.025) - width = int(width * 0.05) - # self.label4.set_margin_top(height) - self.label4.set_margin_bottom(height) - self.label4.set_margin_start(width) - # self.label4.set_margin_end(width) - # self.label3.set_margin_end(width) - self.label3.set_margin_start(width) - # self.label3.set_margin_top(height) - self.label3.set_margin_bottom(height) - self.button6.set_margin_top(height) - self.button6.set_margin_bottom(height) - self.button6.set_margin_start(width) - self.button6.set_margin_end(width) - self.button1.set_margin_bottom(height) - self.button1.set_margin_start(width) - self.button1.set_margin_end(width) - self.font_button.set_margin_end(width) - self.font_button.set_margin_start(width) - self.font_button.set_margin_top(height) - self.font_button.set_margin_bottom(height) - - self.show_all() + self.show() def goto_accessibility(self, button): subprocess.Popen("xfce4-accessibility-settings") @@ -503,52 +498,43 @@ def onlangsupportclicked(self, button): \t\t%s\t\t\t """ % (lang_sup2)) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 1, 2, 1) self.label1 = Gtk.Label() self.label1.set_markup(lang_sup3) self.label1.set_justify(Gtk.Justification.CENTER) + self.label1 = self._set_default_margins(self.label1) self.grid.attach(self.label1, 1, 2, 2, 1) - self.button0 = Gtk.Button.new_from_icon_name("system-software-install", - 3) + self.button0 = Gtk.Button.new_from_icon_name("system-software-install") self.button0.connect("clicked", self.install_locale_packages) + self.button0 = self._set_default_margins(self.button0) self.grid.attach(self.button0, 1, 3, 2, 1) self.label2 = Gtk.Label() self.label2.set_markup(lang_sup4) self.label2.set_justify(Gtk.Justification.CENTER) + self.label2 = self._set_default_margins(self.label2) self.grid.attach(self.label2, 1, 4, 2, 1) - self.button2 = Gtk.Button.new_from_icon_name("preferences-desktop-locale", - 3) + self.button2 = Gtk.Button.new_from_icon_name("preferences-desktop-locale") self.button2.connect("clicked", self.onlanguageclicked) + self.button2 = self._set_default_margins(self.button2) self.grid.attach(self.button2, 1, 5, 2, 1) self.label3 = Gtk.Label() self.label3.set_markup("\n") self.label3.set_justify(Gtk.Justification.CENTER) + self.label3 = self._set_default_margins(self.label3) self.grid.attach(self.label3, 1, 6, 2, 1) self.button1 = Gtk.Button.new_with_label(label=Back) self.button1.connect("clicked", self.reset) + self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 1, 20, 1, 1) - width1 = self.get_size()[0] - width = int(width1 * 0.125) - self.button0.set_margin_start(width) - self.label1.set_margin_start(width) - self.label2.set_margin_start(width) - self.label2.set_margin_end(width) - self.label1.set_margin_end(width) - self.button0.set_margin_end(width) - self.button2.set_margin_start(width) - self.button2.set_margin_end(width) - self.button1.set_margin_end(width) - self.button1.set_margin_start(int(width1 * 0.025)) - self.button1.set_margin_bottom(int(width1 * 0.025)) - - self.show_all() + self.show() def install_locale_packages(self, button): lang = os.getenv("LANG").split(".") @@ -663,7 +649,7 @@ def onhelpclicked(self, button): button1 = self._set_default_margins(button1) self.grid.attach(button1, 1, 20, 1, 1) - self.show_all() + self.show() def open_discord(self, button): cache = apt.cache.Cache() @@ -918,7 +904,7 @@ def ondriveclicked(self, button): button3 = self._set_default_margins(button3) self.grid.attach(button3, 5, 20, 1, 1) - self.show_all() + self.show() def driver_install_confirmation(self, button): self.clear_window() @@ -943,7 +929,7 @@ def driver_install_confirmation(self, button): button2 = self._set_default_margins(button2) self.grid.attach(button2, 3, 3, 1, 1) - self.show_all() + self.show() def install_missing_drivers(self, button): # filter down to just uninstalled drivers @@ -1011,7 +997,7 @@ def post_install_window(self): button1 = self._set_default_margins(button1) self.grid.attach(button1, 1, 20, 1, 1) - self.show_all() + self.show() def open_synaptic(self, button): @@ -1030,6 +1016,7 @@ def onshortcutclicked(self, button): self.label = Gtk.Label() self.label.set_markup("" + TITLE_sc + "") self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 1, 3, 1) self.label = Gtk.Label() @@ -1037,11 +1024,13 @@ def onshortcutclicked(self, button): Ctrl+Alt+T """) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 2, 1, 1) self.label = Gtk.Label() self.label.set_markup(sc_0) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 3, 2, 1, 1) self.label = Gtk.Label() @@ -1049,11 +1038,13 @@ def onshortcutclicked(self, button): Ctrl+Alt+F """) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 3, 1, 1) self.label = Gtk.Label() self.label.set_markup(sc_1) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 3, 3, 1, 1) self.label = Gtk.Label() @@ -1061,11 +1052,13 @@ def onshortcutclicked(self, button): Ctrl+Alt+M """) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 4, 1, 1) self.label = Gtk.Label() self.label.set_markup(sc_2) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 3, 4, 1, 1) self.label = Gtk.Label() @@ -1073,11 +1066,13 @@ def onshortcutclicked(self, button): Alt+F """) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 5, 1, 1) self.label = Gtk.Label() self.label.set_markup(sc_3) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 3, 5, 1, 1) self.label = Gtk.Label() @@ -1085,11 +1080,13 @@ def onshortcutclicked(self, button): Left Super """) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 6, 1, 1) self.label = Gtk.Label() self.label.set_markup(sc_4) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 3, 6, 1, 1) self.label = Gtk.Label() @@ -1097,24 +1094,21 @@ def onshortcutclicked(self, button): Ctrl+Alt+L """) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 7, 1, 1) self.label = Gtk.Label() self.label.set_markup(sc_5) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 3, 7, 1, 1) self.button1 = Gtk.Button.new_with_label(label=Back) self.button1.connect("clicked", self.reset) + self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 1, 20, 3, 1) - width = self.get_size()[0] - width = int(width * 0.25) - self.button1.set_margin_start(width) - self.button1.set_margin_end(width) - self.button1.set_margin_bottom(int(width / 10)) - - self.show_all() + self.show() def onuninstallclicked(self, button): # have an uninstall comfirmation dialoge then uninstall based on @@ -1158,7 +1152,7 @@ def tutorial(self, button): self.button3 = self._set_default_margins(self.button3) self.grid.attach(self.button3, 2, 2, 1, 1) - self.show_all() + self.show() def onclicked(self, button): if (button.get_label() == Next): @@ -1188,7 +1182,7 @@ def onclicked(self, button): elif self.check < -1: self.reset("clicked") - self.show_all() + self.show() def multi_desktop(self, button): self.clear_window() @@ -1209,7 +1203,7 @@ def multi_desktop(self, button): self.button2 = self._set_default_margins(self.button2) self.grid.attach(self.button2, 3, 2, 1, 1) - self.show_all() + self.show() def onmultiyesclicked(self, button): self.clear_window() @@ -1226,7 +1220,7 @@ def onmultiyesclicked(self, button): self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 3, 2, 1, 1) - self.show_all() + self.show() def exit(self, button): global show_at_start_up @@ -1243,19 +1237,26 @@ def exit(self, button): exit(1) def clear_window(self): - children = self.grid.get_children() - for each in children: - self.grid.remove(each) + width = self.grid.get_width() + height = self.grid.get_height() + for each in range(height, -1, -1): + self.grid.remove_row(each) + + +class welcome(Adw.Application): + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.connect('activate', self.on_activate) + + def on_activate(self, app): + self.win = MainWindow(application=app) + self.win.present() def welcome_show(): - window = welcome() - window.set_decorated(True) - window.set_resizable(False) - window.set_position(Gtk.WindowPosition.CENTER) - window.connect("delete-event", welcome.exit) - window.show_all() - Gtk.main() + app = welcome(application_id="org.draugeros.welcome") + app.run() + if __name__ == '__main__': try: From 786058f4a5ebdf1d1f995520ecd3ccbe22b8bd04 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 12 Jun 2022 11:19:08 -0400 Subject: [PATCH 28/39] Work to add EOL warning next time this occurs We want to let ALL Drauger OS users know when their installation is about to reach EOL. Not all of them are in our Telegram or Discord, or follow us on Twitter, or are part of our subreddit. As such we need a foolproof way to ensure ALL Drauger OS users get notified when their version is going to expire. This means not network connectivity requirement. We have to do all that processing locally. This is the start of the work to implement that. --- usr/share/drauger-welcome/tut.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/usr/share/drauger-welcome/tut.py b/usr/share/drauger-welcome/tut.py index 72cee6a..5f323cc 100755 --- a/usr/share/drauger-welcome/tut.py +++ b/usr/share/drauger-welcome/tut.py @@ -24,13 +24,24 @@ from __future__ import print_function import sys from os import path, getenv -from subprocess import Popen +import subprocess +import csv +import datetime import drauger_welcome.main_ui as main_ui # Make it easier for us to print to stderr def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) + +def make_ints(string_list): + """make a list of strings into a list of ints""" + new_list = [] + for each in string_list: + new_list.append(int(each)) + return new_list + + HOME = getenv("HOME") # check if system-installer will be running, if it is, do not show the welcome screen with open("/proc/cmdline", "r") as cmdline_file: @@ -38,10 +49,27 @@ def eprint(*args, **kwargs): if "system-installer" in cmdline: # Not wanted to be running ootb sys.exit(0) +# check to see if we are going to be EOL soon +file = open("/usr/share/distro-info/Draugeros.csv", "r") +csv_reader = list(csv.reader(file)) +version = subprocess.check_output(["lsb_release", "-rs"]).decode()[:-1] + +# we want to iterate BACKWARDS because the version number is likely to be either the +# last line, or the next-to-last line. This means our big-O stays the same, but our +# true execution time is SIGNIFICANTLY reduced. +for each in range(len(csv_reader) - 1, -1, -1): + if csv_reader[each][0] == version: + current_time = time.strftime("%Y-%m-%d", time.gmtime()) + current_time = current_time.split("-") + current_time = make_ints(current_time) + eol_time = csv_reader[each][-1].split("-") + eol_time = make_ints(eol_time) + # find dismantle time (eol_time + 14 days) + # find alert time (eol_time - 14 days) if ((not path.exists(HOME + "/.drauger-tut")) and (not path.exists("/etc/system-installer/oem-post-install.flag"))): try: main_ui.welcome_show() except Exception as e: - Popen("/usr/share/drauger-welcome/log-out 2 /usr/share/drauger-welcome/tut.py \"Error: %s . main_ui.py has failed.\"" % (e)) + subprocess.Popen("/usr/share/drauger-welcome/log-out 2 /usr/share/drauger-welcome/tut.py \"Error: %s . main_ui.py has failed.\"" % (e)) else: exit(2) From 2b26db593b96a39d4ccc1d948f418b27bf549314 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Mon, 13 Jun 2022 00:11:43 -0400 Subject: [PATCH 29/39] further work for alert window --- .../dist-packages/drauger_welcome/main_ui.py | 11 ---- usr/share/drauger-welcome/tut.py | 51 ++++++++++++++++++- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py b/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py index 3d15755..494717e 100755 --- a/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py +++ b/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py @@ -244,17 +244,6 @@ def __init__(self, *args, **kwargs): self.set_child(self.grid) self.icon = "/usr/share/icons/Drauger/scalable/menus/drauger_os-logo.svg" # not sure if this is the best way to handle this - print("ICON CHECK") - print("-" * 20) - for each in dir(Gtk.ApplicationWindow): - if "icon" in each: - print(each) - print("-" * 20) - print("REMOVE CHECK") - print("-" * 20) - for each in dir(self.grid): - if "clear" in each: - print(each) self.set_icon_name("drauger_os-logo") # self.set_icon_from_file(self.icon) diff --git a/usr/share/drauger-welcome/tut.py b/usr/share/drauger-welcome/tut.py index 5f323cc..75543e9 100755 --- a/usr/share/drauger-welcome/tut.py +++ b/usr/share/drauger-welcome/tut.py @@ -26,7 +26,7 @@ from os import path, getenv import subprocess import csv -import datetime +import time import drauger_welcome.main_ui as main_ui # Make it easier for us to print to stderr @@ -34,13 +34,37 @@ def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) -def make_ints(string_list): +def make_ints(string_list: str): """make a list of strings into a list of ints""" new_list = [] for each in string_list: new_list.append(int(each)) return new_list +def is_before(before: list, after: list): + """Check if a given date list comes before another one + + Return True if `before` comes before `after`. + Return None if they are the same date. + Return False if `after` comes before `before`. + """ + if before[0] < after[0]: # check year first + return True + if before[0] > after[0]: + return False + # if we get to here we KNOW `before[0]` == `after[0]` + if before[1] < after[1]: # check month second + return True + if before[1] > after[1]: + return False + # finally, if we get here, we know `before` and `after` are in the same month of the same year + if before[2] < after[2]: # check day last + return True + if before[2] > after[2]: + return False + # if we get here, `before` == `after`. Return None. + return None + HOME = getenv("HOME") # check if system-installer will be running, if it is, do not show the welcome screen @@ -64,8 +88,31 @@ def make_ints(string_list): current_time = make_ints(current_time) eol_time = csv_reader[each][-1].split("-") eol_time = make_ints(eol_time) + add_time = 1209600 # number of seconds in 14 days # find dismantle time (eol_time + 14 days) + dismantle_time = time.strftime("%Y-%m-%d", time.gmtime(time.time() + dismantle_time)) + dismantle_time = dismantle_time.split("-") + dismantle_time = make_ints(dismantle_time) # find alert time (eol_time - 14 days) + alert_time = time.strftime("%Y-%m-%d", time.gmtime(time.time() - dismantle_time)) + alert_time = alert_time.split("-") + alert_time = make_ints(alert_time) + # check for alerts in this order: + # alert_time -> eol_time -> dismantle_time + alert = not is_before(current_time, alert_time) + if alert: # not None evaluates to True + eol = not is_before(current_time, eol_time) + if eol: + dismantle = not is_before(current_time, dismantle_time) + if dismantle: + # display dismantled dialog - Let the user know that this version of Drauger OS can no longer update without + # modifications to /etc/apt/sources.list + break + # if we get here then this version of Drauger OS is EOL but not yet dismantled, alert user they can still upgrade to + # the next version of Drauger OS + break + # if we get here then this version of Drauger OS is within 2 weeks of being EOL. Alert the user. + break if ((not path.exists(HOME + "/.drauger-tut")) and (not path.exists("/etc/system-installer/oem-post-install.flag"))): try: main_ui.welcome_show() From 107a701aec9134eaa1062dfa3911e03deb511805 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Tue, 21 Mar 2023 14:12:24 -0400 Subject: [PATCH 30/39] Revert "further work for alert window" This reverts commit 2b26db593b96a39d4ccc1d948f418b27bf549314. --- .../dist-packages/drauger_welcome/main_ui.py | 11 ++++ usr/share/drauger-welcome/tut.py | 51 +------------------ 2 files changed, 13 insertions(+), 49 deletions(-) diff --git a/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py b/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py index 494717e..3d15755 100755 --- a/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py +++ b/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py @@ -244,6 +244,17 @@ def __init__(self, *args, **kwargs): self.set_child(self.grid) self.icon = "/usr/share/icons/Drauger/scalable/menus/drauger_os-logo.svg" # not sure if this is the best way to handle this + print("ICON CHECK") + print("-" * 20) + for each in dir(Gtk.ApplicationWindow): + if "icon" in each: + print(each) + print("-" * 20) + print("REMOVE CHECK") + print("-" * 20) + for each in dir(self.grid): + if "clear" in each: + print(each) self.set_icon_name("drauger_os-logo") # self.set_icon_from_file(self.icon) diff --git a/usr/share/drauger-welcome/tut.py b/usr/share/drauger-welcome/tut.py index 75543e9..5f323cc 100755 --- a/usr/share/drauger-welcome/tut.py +++ b/usr/share/drauger-welcome/tut.py @@ -26,7 +26,7 @@ from os import path, getenv import subprocess import csv -import time +import datetime import drauger_welcome.main_ui as main_ui # Make it easier for us to print to stderr @@ -34,37 +34,13 @@ def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) -def make_ints(string_list: str): +def make_ints(string_list): """make a list of strings into a list of ints""" new_list = [] for each in string_list: new_list.append(int(each)) return new_list -def is_before(before: list, after: list): - """Check if a given date list comes before another one - - Return True if `before` comes before `after`. - Return None if they are the same date. - Return False if `after` comes before `before`. - """ - if before[0] < after[0]: # check year first - return True - if before[0] > after[0]: - return False - # if we get to here we KNOW `before[0]` == `after[0]` - if before[1] < after[1]: # check month second - return True - if before[1] > after[1]: - return False - # finally, if we get here, we know `before` and `after` are in the same month of the same year - if before[2] < after[2]: # check day last - return True - if before[2] > after[2]: - return False - # if we get here, `before` == `after`. Return None. - return None - HOME = getenv("HOME") # check if system-installer will be running, if it is, do not show the welcome screen @@ -88,31 +64,8 @@ def is_before(before: list, after: list): current_time = make_ints(current_time) eol_time = csv_reader[each][-1].split("-") eol_time = make_ints(eol_time) - add_time = 1209600 # number of seconds in 14 days # find dismantle time (eol_time + 14 days) - dismantle_time = time.strftime("%Y-%m-%d", time.gmtime(time.time() + dismantle_time)) - dismantle_time = dismantle_time.split("-") - dismantle_time = make_ints(dismantle_time) # find alert time (eol_time - 14 days) - alert_time = time.strftime("%Y-%m-%d", time.gmtime(time.time() - dismantle_time)) - alert_time = alert_time.split("-") - alert_time = make_ints(alert_time) - # check for alerts in this order: - # alert_time -> eol_time -> dismantle_time - alert = not is_before(current_time, alert_time) - if alert: # not None evaluates to True - eol = not is_before(current_time, eol_time) - if eol: - dismantle = not is_before(current_time, dismantle_time) - if dismantle: - # display dismantled dialog - Let the user know that this version of Drauger OS can no longer update without - # modifications to /etc/apt/sources.list - break - # if we get here then this version of Drauger OS is EOL but not yet dismantled, alert user they can still upgrade to - # the next version of Drauger OS - break - # if we get here then this version of Drauger OS is within 2 weeks of being EOL. Alert the user. - break if ((not path.exists(HOME + "/.drauger-tut")) and (not path.exists("/etc/system-installer/oem-post-install.flag"))): try: main_ui.welcome_show() From a96319a760eabc7bc25dd1bd22f29af3db238328 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Tue, 21 Mar 2023 14:12:43 -0400 Subject: [PATCH 31/39] Revert "Work to add EOL warning next time this occurs" This reverts commit 786058f4a5ebdf1d1f995520ecd3ccbe22b8bd04. --- usr/share/drauger-welcome/tut.py | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/usr/share/drauger-welcome/tut.py b/usr/share/drauger-welcome/tut.py index 5f323cc..72cee6a 100755 --- a/usr/share/drauger-welcome/tut.py +++ b/usr/share/drauger-welcome/tut.py @@ -24,24 +24,13 @@ from __future__ import print_function import sys from os import path, getenv -import subprocess -import csv -import datetime +from subprocess import Popen import drauger_welcome.main_ui as main_ui # Make it easier for us to print to stderr def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) - -def make_ints(string_list): - """make a list of strings into a list of ints""" - new_list = [] - for each in string_list: - new_list.append(int(each)) - return new_list - - HOME = getenv("HOME") # check if system-installer will be running, if it is, do not show the welcome screen with open("/proc/cmdline", "r") as cmdline_file: @@ -49,27 +38,10 @@ def make_ints(string_list): if "system-installer" in cmdline: # Not wanted to be running ootb sys.exit(0) -# check to see if we are going to be EOL soon -file = open("/usr/share/distro-info/Draugeros.csv", "r") -csv_reader = list(csv.reader(file)) -version = subprocess.check_output(["lsb_release", "-rs"]).decode()[:-1] - -# we want to iterate BACKWARDS because the version number is likely to be either the -# last line, or the next-to-last line. This means our big-O stays the same, but our -# true execution time is SIGNIFICANTLY reduced. -for each in range(len(csv_reader) - 1, -1, -1): - if csv_reader[each][0] == version: - current_time = time.strftime("%Y-%m-%d", time.gmtime()) - current_time = current_time.split("-") - current_time = make_ints(current_time) - eol_time = csv_reader[each][-1].split("-") - eol_time = make_ints(eol_time) - # find dismantle time (eol_time + 14 days) - # find alert time (eol_time - 14 days) if ((not path.exists(HOME + "/.drauger-tut")) and (not path.exists("/etc/system-installer/oem-post-install.flag"))): try: main_ui.welcome_show() except Exception as e: - subprocess.Popen("/usr/share/drauger-welcome/log-out 2 /usr/share/drauger-welcome/tut.py \"Error: %s . main_ui.py has failed.\"" % (e)) + Popen("/usr/share/drauger-welcome/log-out 2 /usr/share/drauger-welcome/tut.py \"Error: %s . main_ui.py has failed.\"" % (e)) else: exit(2) From 2e27736719b262619c47c59f3bc94a43d336930b Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Tue, 21 Mar 2023 14:13:02 -0400 Subject: [PATCH 32/39] Revert "initial support for GTK 4.0" This reverts commit 07d9e16a750b01c02a357c23254a3e784ac67d14. --- DEBIAN/control | 4 +- .../dist-packages/drauger_welcome/main_ui.py | 251 +++++++++--------- 2 files changed, 127 insertions(+), 128 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 11e166b..a44a593 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,11 +1,11 @@ Package: drauger-welcome -Version: 4.9.7 +Version: 4.9.6 Maintainer: Thomas Castleman Section: misc Homepage: https://github.com/drauger-os-development/drauger-welcome Architecture: amd64 Priority: optional -Depends: python3 (>=3.5.1-3), gir1.2-gtk-4.0 (>=4.6.1+ds-1ubuntu2), gir1.2-adw-1 (1.1~rc-1), drauger-icons (>=0.0.2), bash, procps, xfconf, python3-apt +Depends: python3 (>=3.5.1-3), gir1.2-gtk-3.0 (>=3.24.12-1ubuntu1), drauger-icons (>=0.0.2), bash, procps, xfconf, python3-apt Replaces: drauger-tutorial (>=1.0) Breaks: drauger-tutorial (>=1.0) Description: Welcome screen and tutorial All-in-One for Drauger OS diff --git a/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py b/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py index 3d15755..9ffec4e 100755 --- a/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py +++ b/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py @@ -22,29 +22,23 @@ # MA 02110-1301, USA. # # -"""UI for drauger-welcome""" import gi -gi.require_version('Gtk', '4.0') -gi.require_version('Adw', '1') -from gi.repository import Gtk, Adw +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk import os import subprocess import json import shlex import apt -# intitial multi-lingual support LANG = os.getenv("LANG").split(".") LANG = LANG[0] -# get screen resolution results = subprocess.Popen(['xrandr'], stdout=subprocess.PIPE).communicate()[0] results = results.decode().split("current")[1].split(",")[0] width = int(results.split("x")[0].strip()) height = int(results.split("x")[1].strip()) -# this is where we expand upon the multi-lingual support more. This relies upon -# the community, and as such will likely throw a FileNotFoundError fairly often try: try: with open("/etc/drauger-locales/%s/drauger-installer.conf" % (LANG), @@ -219,50 +213,34 @@ Open = "Open" -# Get the user's home directory, so we know where to look for the auto-start blocking flag file HOME = os.getenv("HOME") if (not os.path.exists("%s/.drauger-tut" % (HOME))): show_at_start_up = True else: show_at_start_up = False -# get current Drauger OS version -# this will likely get replaced with a call to lsb_release at some point try: with open("/usr/drauger/os-info.txt") as f: s = f.read() except Exception: s = "TEST" +class welcome(Gtk.Window): -class MainWindow(Gtk.ApplicationWindow): - """The GUI itself""" - def __init__(self, *args, **kwargs): - super().__init__(title="Welcome to Drauger OS", *args, **kwargs) - self.set_resizable(False) + def __init__(self): + Gtk.Window.__init__(self, title="Welcome to Drauger OS") self.grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL) - self.set_child(self.grid) + self.add(self.grid) self.icon = "/usr/share/icons/Drauger/scalable/menus/drauger_os-logo.svg" - # not sure if this is the best way to handle this - print("ICON CHECK") - print("-" * 20) - for each in dir(Gtk.ApplicationWindow): - if "icon" in each: - print(each) - print("-" * 20) - print("REMOVE CHECK") - print("-" * 20) - for each in dir(self.grid): - if "clear" in each: - print(each) - self.set_icon_name("drauger_os-logo") - # self.set_icon_from_file(self.icon) + self.set_icon_from_file(self.icon) self.drivers = [] - self.present() self.reset("clicked") + + def reset(self, button): + global show_at_start_up self.clear_window() @@ -272,132 +250,142 @@ def reset(self, button): Drauger OS %s """ % (s) + "") self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 1, 8, 1) self.label = Gtk.Label() self.label.set_markup(welcome_label) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 2, 8, 1) self.label1 = Gtk.Label() self.label1.set_markup(website) self.label1.set_justify(Gtk.Justification.CENTER) - self.label1 = self._set_default_margins(self.label1) self.grid.attach(self.label1, 1, 3, 1, 1) - self.button1 = Gtk.Button.new_from_icon_name("cs-network") + self.button1 = Gtk.Button.new_from_icon_name("cs-network", 3) self.button1.connect("clicked", self.onwebclicked) - self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 1, 4, 1, 1) self.label2 = Gtk.Label() self.label2.set_markup(README) self.label2.set_justify(Gtk.Justification.CENTER) - self.label2 = self._set_default_margins(self.label2) self.grid.attach(self.label2, 6, 3, 1, 1) - self.button2 = Gtk.Button.new_from_icon_name("document") + self.button2 = Gtk.Button.new_from_icon_name("document", 3) self.button2.connect("clicked", self.show_readme) - self.button2 = self._set_default_margins(self.button2) self.grid.attach(self.button2, 6, 4, 1, 1) self.label3 = Gtk.Label() self.label3.set_markup(tutorial_label) self.label3.set_justify(Gtk.Justification.CENTER) - self.label3 = self._set_default_margins(self.label3) self.grid.attach(self.label3, 1, 5, 1, 1) - self.button3 = Gtk.Button.new_from_icon_name("dictionary") + self.button3 = Gtk.Button.new_from_icon_name("dictionary", 3) self.button3.connect("clicked", self.tutorial) - self.button3 = self._set_default_margins(self.button3) self.grid.attach(self.button3, 1, 6, 1, 1) self.label4 = Gtk.Label() self.label4.set_markup(help_button) self.label4.set_justify(Gtk.Justification.CENTER) - self.label4 = self._set_default_margins(self.label4) self.grid.attach(self.label4, 1, 7, 1, 1) - self.button4 = Gtk.Button.new_from_icon_name("help") + self.button4 = Gtk.Button.new_from_icon_name("help", 3) self.button4.connect("clicked", self.onhelpclicked) - self.button4 = self._set_default_margins(self.button4) self.grid.attach(self.button4, 1, 8, 1, 1) self.label5 = Gtk.Label() self.label5.set_markup(drivers) self.label5.set_justify(Gtk.Justification.CENTER) - self.label5 = self._set_default_margins(self.label5) self.grid.attach(self.label5, 6, 7, 1, 1) - self.button5 = Gtk.Button.new_from_icon_name("jockey") + self.button5 = Gtk.Button.new_from_icon_name("jockey", 3) self.button5.connect("clicked", self.ondriveclicked) - self.button5 = self._set_default_margins(self.button5) self.grid.attach(self.button5, 6, 8, 1, 1) self.label6 = Gtk.Label() self.label6.set_markup(lang_sup) self.label6.set_justify(Gtk.Justification.CENTER) - self.label6 = self._set_default_margins(self.label6) self.grid.attach(self.label6, 4, 5, 1, 1) - self.button6 = Gtk.Button.new_from_icon_name("accessibility") + self.button6 = Gtk.Button.new_from_icon_name("accessibility", 3) self.button6.connect("clicked", self.show_accessibility_settings) - self.button6 = self._set_default_margins(self.button6) self.grid.attach(self.button6, 4, 6, 1, 1) self.label7 = Gtk.Label() self.label7.set_markup(donate) - self.label7.set_justify(Gtk.Justification.CENTER) - self.label7 = self._set_default_margins(self.label7) + self.label.set_justify(Gtk.Justification.CENTER) self.grid.attach(self.label7, 4, 7, 1, 1) - self.button7 = Gtk.Button.new_from_icon_name("money-manager-ex") + self.button7 = Gtk.Button.new_from_icon_name("money-manager-ex", 3) self.button7.connect("clicked", self.ondonateclicked) - self.button7 = self._set_default_margins(self.button7) self.grid.attach(self.button7, 4, 8, 1, 1) self.label8 = Gtk.Label() self.label8.set_markup(shortcuts) self.label8.set_justify(Gtk.Justification.CENTER) - self.label8 = self._set_default_margins(self.label8) self.grid.attach(self.label8, 6, 5, 1, 1) - self.button8 = Gtk.Button.new_from_icon_name("keyboard") + self.button8 = Gtk.Button.new_from_icon_name("keyboard", 3) self.button8.connect("clicked", self.onshortcutclicked) - self.button8 = self._set_default_margins(self.button8) self.grid.attach(self.button8, 6, 6, 1, 1) self.label9 = Gtk.Label() self.label9.set_markup(uninstall) self.label9.set_justify(Gtk.Justification.CENTER) - self.label9 = self._set_default_margins(self.label9) self.grid.attach(self.label9, 4, 9, 1, 1) - self.button9 = Gtk.Button.new_from_icon_name("delete") + self.button9 = Gtk.Button.new_from_icon_name("delete", 3) self.button9.connect("clicked", self.removal_conf) - self.button9 = self._set_default_margins(self.button9) self.grid.attach(self.button9, 4, 10, 1, 1) self.label10 = Gtk.Label() self.label10.set_markup(lang_sup2) self.label10.set_justify(Gtk.Justification.CENTER) - self.label10 = self._set_default_margins(self.label10) self.grid.attach(self.label10, 4, 3, 1, 1) - self.button10 = Gtk.Button.new_from_icon_name("preferences-desktop-locale") + self.button10 = Gtk.Button.new_from_icon_name("preferences-desktop-locale", 3) self.button10.connect("clicked", self.onlangsupportclicked) - self.button10 = self._set_default_margins(self.button10) self.grid.attach(self.button10, 4, 4, 1, 1) self.start_up = Gtk.CheckButton.new_with_label(start_up_label) self.start_up.set_active(show_at_start_up) self.start_up.connect("toggled", self.start_up_toggle) - self.start_up = self._set_default_margins(self.start_up) self.grid.attach(self.start_up, 1, 13, 2, 1) - self.show() + width = self.get_size()[0] + width = int(width * 0.125) + self.button10.set_margin_start(width) + self.button10.set_margin_end(width) + self.button6.set_margin_start(width) + self.button6.set_margin_end(width) + self.button4.set_margin_start(width) + self.button2.set_margin_end(width) + self.button3.set_margin_start(width) + self.button1.set_margin_start(width) + self.button9.set_margin_end(width) + self.button9.set_margin_start(width) + self.button8.set_margin_end(width) + self.button7.set_margin_end(width) + self.button7.set_margin_start(width) + self.button5.set_margin_end(width) + self.label2.set_margin_end(width) + self.label8.set_margin_end(width) + self.label5.set_margin_end(width) + self.label7.set_margin_end(width) + self.label7.set_margin_start(width) + self.label4.set_margin_start(width) + self.label10.set_margin_start(width) + self.label9.set_margin_start(width) + self.label10.set_margin_end(width) + self.label9.set_margin_end(width) + self.label9.set_margin_start(width) + self.label6.set_margin_end(width) + self.label6.set_margin_start(width) + self.label1.set_margin_start(width) + self.start_up.set_margin_start(int(width / 2)) + self.start_up.set_margin_bottom(int(width / 2)) + + self.show_all() def show_readme(self, widget): version = subprocess.check_output(["lsb_release", "-rs"]).decode() @@ -428,7 +416,7 @@ def removal_conf(self, button): self.button2 = self._set_default_margins(self.button2) self.grid.attach(self.button2, 3, 2, 1, 1) - self.show() + self.show_all() def show_accessibility_settings(self, button): self.clear_window() @@ -438,12 +426,10 @@ def show_accessibility_settings(self, button): \t\t%s\t\t\t """ % (lang_sup)) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 1, 2, 1) self.label3 = Gtk.Label() self.label3.set_markup(font) - self.label3 = self._set_default_margins(self.label3) self.grid.attach(self.label3, 1, 3, 1, 1) self.font_button = Gtk.FontButton() @@ -462,26 +448,45 @@ def show_accessibility_settings(self, button): # set font and size for button self.font_button.set_font(system_font) self.font_button.connect("font-set", self.set_font) - self.font_button = self._set_default_margins(self.font_button) self.grid.attach(self.font_button, 2, 3, 1, 1) self.label4 = Gtk.Label() self.label4.set_markup("%s" % (access_label)) self.label4.set_justify(Gtk.Justification.CENTER) - self.label4 = self._set_default_margins(self.label4) self.grid.attach(self.label4, 1, 4, 1, 1) - self.button6 = Gtk.Button.new_from_icon_name("accessibility") + self.button6 = Gtk.Button.new_from_icon_name("accessibility", 3) self.button6.connect("clicked", self.goto_accessibility) - self.button6 = self._set_default_margins(self.button6) self.grid.attach(self.button6, 2, 4, 1, 1) self.button1 = Gtk.Button.new_with_label(label=Back) self.button1.connect("clicked", self.reset) - self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 1, 20, 1, 1) - self.show() + width = self.get_size()[0] + height = int(width * 0.025) + width = int(width * 0.05) + # self.label4.set_margin_top(height) + self.label4.set_margin_bottom(height) + self.label4.set_margin_start(width) + # self.label4.set_margin_end(width) + # self.label3.set_margin_end(width) + self.label3.set_margin_start(width) + # self.label3.set_margin_top(height) + self.label3.set_margin_bottom(height) + self.button6.set_margin_top(height) + self.button6.set_margin_bottom(height) + self.button6.set_margin_start(width) + self.button6.set_margin_end(width) + self.button1.set_margin_bottom(height) + self.button1.set_margin_start(width) + self.button1.set_margin_end(width) + self.font_button.set_margin_end(width) + self.font_button.set_margin_start(width) + self.font_button.set_margin_top(height) + self.font_button.set_margin_bottom(height) + + self.show_all() def goto_accessibility(self, button): subprocess.Popen("xfce4-accessibility-settings") @@ -498,43 +503,52 @@ def onlangsupportclicked(self, button): \t\t%s\t\t\t """ % (lang_sup2)) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 1, 2, 1) self.label1 = Gtk.Label() self.label1.set_markup(lang_sup3) self.label1.set_justify(Gtk.Justification.CENTER) - self.label1 = self._set_default_margins(self.label1) self.grid.attach(self.label1, 1, 2, 2, 1) - self.button0 = Gtk.Button.new_from_icon_name("system-software-install") + self.button0 = Gtk.Button.new_from_icon_name("system-software-install", + 3) self.button0.connect("clicked", self.install_locale_packages) - self.button0 = self._set_default_margins(self.button0) self.grid.attach(self.button0, 1, 3, 2, 1) self.label2 = Gtk.Label() self.label2.set_markup(lang_sup4) self.label2.set_justify(Gtk.Justification.CENTER) - self.label2 = self._set_default_margins(self.label2) self.grid.attach(self.label2, 1, 4, 2, 1) - self.button2 = Gtk.Button.new_from_icon_name("preferences-desktop-locale") + self.button2 = Gtk.Button.new_from_icon_name("preferences-desktop-locale", + 3) self.button2.connect("clicked", self.onlanguageclicked) - self.button2 = self._set_default_margins(self.button2) self.grid.attach(self.button2, 1, 5, 2, 1) self.label3 = Gtk.Label() self.label3.set_markup("\n") self.label3.set_justify(Gtk.Justification.CENTER) - self.label3 = self._set_default_margins(self.label3) self.grid.attach(self.label3, 1, 6, 2, 1) self.button1 = Gtk.Button.new_with_label(label=Back) self.button1.connect("clicked", self.reset) - self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 1, 20, 1, 1) - self.show() + width1 = self.get_size()[0] + width = int(width1 * 0.125) + self.button0.set_margin_start(width) + self.label1.set_margin_start(width) + self.label2.set_margin_start(width) + self.label2.set_margin_end(width) + self.label1.set_margin_end(width) + self.button0.set_margin_end(width) + self.button2.set_margin_start(width) + self.button2.set_margin_end(width) + self.button1.set_margin_end(width) + self.button1.set_margin_start(int(width1 * 0.025)) + self.button1.set_margin_bottom(int(width1 * 0.025)) + + self.show_all() def install_locale_packages(self, button): lang = os.getenv("LANG").split(".") @@ -649,7 +663,7 @@ def onhelpclicked(self, button): button1 = self._set_default_margins(button1) self.grid.attach(button1, 1, 20, 1, 1) - self.show() + self.show_all() def open_discord(self, button): cache = apt.cache.Cache() @@ -904,7 +918,7 @@ def ondriveclicked(self, button): button3 = self._set_default_margins(button3) self.grid.attach(button3, 5, 20, 1, 1) - self.show() + self.show_all() def driver_install_confirmation(self, button): self.clear_window() @@ -929,7 +943,7 @@ def driver_install_confirmation(self, button): button2 = self._set_default_margins(button2) self.grid.attach(button2, 3, 3, 1, 1) - self.show() + self.show_all() def install_missing_drivers(self, button): # filter down to just uninstalled drivers @@ -997,7 +1011,7 @@ def post_install_window(self): button1 = self._set_default_margins(button1) self.grid.attach(button1, 1, 20, 1, 1) - self.show() + self.show_all() def open_synaptic(self, button): @@ -1016,7 +1030,6 @@ def onshortcutclicked(self, button): self.label = Gtk.Label() self.label.set_markup("" + TITLE_sc + "") self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 1, 3, 1) self.label = Gtk.Label() @@ -1024,13 +1037,11 @@ def onshortcutclicked(self, button): Ctrl+Alt+T """) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 2, 1, 1) self.label = Gtk.Label() self.label.set_markup(sc_0) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 3, 2, 1, 1) self.label = Gtk.Label() @@ -1038,13 +1049,11 @@ def onshortcutclicked(self, button): Ctrl+Alt+F """) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 3, 1, 1) self.label = Gtk.Label() self.label.set_markup(sc_1) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 3, 3, 1, 1) self.label = Gtk.Label() @@ -1052,13 +1061,11 @@ def onshortcutclicked(self, button): Ctrl+Alt+M """) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 4, 1, 1) self.label = Gtk.Label() self.label.set_markup(sc_2) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 3, 4, 1, 1) self.label = Gtk.Label() @@ -1066,13 +1073,11 @@ def onshortcutclicked(self, button): Alt+F """) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 5, 1, 1) self.label = Gtk.Label() self.label.set_markup(sc_3) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 3, 5, 1, 1) self.label = Gtk.Label() @@ -1080,13 +1085,11 @@ def onshortcutclicked(self, button): Left Super """) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 6, 1, 1) self.label = Gtk.Label() self.label.set_markup(sc_4) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 3, 6, 1, 1) self.label = Gtk.Label() @@ -1094,21 +1097,24 @@ def onshortcutclicked(self, button): Ctrl+Alt+L """) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 7, 1, 1) self.label = Gtk.Label() self.label.set_markup(sc_5) self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 3, 7, 1, 1) self.button1 = Gtk.Button.new_with_label(label=Back) self.button1.connect("clicked", self.reset) - self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 1, 20, 3, 1) - self.show() + width = self.get_size()[0] + width = int(width * 0.25) + self.button1.set_margin_start(width) + self.button1.set_margin_end(width) + self.button1.set_margin_bottom(int(width / 10)) + + self.show_all() def onuninstallclicked(self, button): # have an uninstall comfirmation dialoge then uninstall based on @@ -1152,7 +1158,7 @@ def tutorial(self, button): self.button3 = self._set_default_margins(self.button3) self.grid.attach(self.button3, 2, 2, 1, 1) - self.show() + self.show_all() def onclicked(self, button): if (button.get_label() == Next): @@ -1182,7 +1188,7 @@ def onclicked(self, button): elif self.check < -1: self.reset("clicked") - self.show() + self.show_all() def multi_desktop(self, button): self.clear_window() @@ -1203,7 +1209,7 @@ def multi_desktop(self, button): self.button2 = self._set_default_margins(self.button2) self.grid.attach(self.button2, 3, 2, 1, 1) - self.show() + self.show_all() def onmultiyesclicked(self, button): self.clear_window() @@ -1220,7 +1226,7 @@ def onmultiyesclicked(self, button): self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 3, 2, 1, 1) - self.show() + self.show_all() def exit(self, button): global show_at_start_up @@ -1237,26 +1243,19 @@ def exit(self, button): exit(1) def clear_window(self): - width = self.grid.get_width() - height = self.grid.get_height() - for each in range(height, -1, -1): - self.grid.remove_row(each) - - -class welcome(Adw.Application): - def __init__(self, **kwargs): - super().__init__(**kwargs) - self.connect('activate', self.on_activate) - - def on_activate(self, app): - self.win = MainWindow(application=app) - self.win.present() + children = self.grid.get_children() + for each in children: + self.grid.remove(each) def welcome_show(): - app = welcome(application_id="org.draugeros.welcome") - app.run() - + window = welcome() + window.set_decorated(True) + window.set_resizable(False) + window.set_position(Gtk.WindowPosition.CENTER) + window.connect("delete-event", welcome.exit) + window.show_all() + Gtk.main() if __name__ == '__main__': try: From ca345408c78d1cfdce5beb0465c5b7471ec5ffb7 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 22 Mar 2023 00:07:05 -0400 Subject: [PATCH 33/39] Rework notification of lack of support If a Drauger OS installation doesn't have internet. It doesn't really matter if it's supported or not. It can't download updates anyways. And, this file is so small, it should download quickly on even the slowest 1G cellular connections and 16K modems. Creation of the notification UI will be in the next commit(s). --- DEBIAN/control | 4 +- usr/bin/drauger-welcome | 2 +- usr/share/drauger-welcome/tut.py | 88 ++++++++++++++++++++++++++++++-- 3 files changed, 87 insertions(+), 7 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index a44a593..457ea68 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,11 +1,11 @@ Package: drauger-welcome -Version: 4.9.6 +Version: 4.9.7 Maintainer: Thomas Castleman Section: misc Homepage: https://github.com/drauger-os-development/drauger-welcome Architecture: amd64 Priority: optional -Depends: python3 (>=3.5.1-3), gir1.2-gtk-3.0 (>=3.24.12-1ubuntu1), drauger-icons (>=0.0.2), bash, procps, xfconf, python3-apt +Depends: python3 (>=3.5.1-3), gir1.2-gtk-3.0 (>=3.24.12-1ubuntu1), drauger-icons (>=0.0.2), bash, procps, xfconf, python3-apt, python3-urllib3 (>1.25) Replaces: drauger-tutorial (>=1.0) Breaks: drauger-tutorial (>=1.0) Description: Welcome screen and tutorial All-in-One for Drauger OS diff --git a/usr/bin/drauger-welcome b/usr/bin/drauger-welcome index 34b93ff..bf23986 100755 --- a/usr/bin/drauger-welcome +++ b/usr/bin/drauger-welcome @@ -25,7 +25,7 @@ from __future__ import print_function import sys import drauger_welcome -VERSION = "4.9.6" +VERSION = "4.9.7" HELP = """ drauger-welcome, Version %s \t-h, --help print this help dialoge. diff --git a/usr/share/drauger-welcome/tut.py b/usr/share/drauger-welcome/tut.py index 72cee6a..90a2b2d 100755 --- a/usr/share/drauger-welcome/tut.py +++ b/usr/share/drauger-welcome/tut.py @@ -24,24 +24,104 @@ from __future__ import print_function import sys from os import path, getenv -from subprocess import Popen +import subprocess +import urllib3 import drauger_welcome.main_ui as main_ui + # Make it easier for us to print to stderr def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) + +def get_support(url): + """Check for support with the central EOL designation file""" + # get data + data = url.request("GET", + "https://download-optimizer.draugeros.org/docs/EOL.txt") + data = data.data.decode().split("\n") + # filter comments + for each in range(len(data) - 1, -1, -1): + if data[each] == "": + del data[each] + elif data[each][0] == "#": + del data[each] + # parse remaining data + for each in enumerate(data): + data[each[0]] = each[1].split(" - ") + data = dict(data) + return data + + +def get_release(): + """Get Drauger OS release""" + # first source + with open("/usr/drauger/os-info.txt", "r") as file: + data_1 = file.read() + if data_1[-1] == "\n": + data_1 = data_1[:-1].split(" ")[0] + # second source + data_2 = subprocess.check_output(["lsb_release", "-rs"]).decode()[:-1] + # third source + with open("/etc/os-release", "r") as file: + data_3 = file.read().split("\n") + data_3 = [each for each in data_3 if "VERSION" in each] + data_3 = dict([each.split("=") for each in data_3]) + data_3 = data_3["VERSION_ID"].strip("\"") + # check to see if sources agree + if data_1 in (data_2, data_3) + return data_1 + if data_2 == data_3: + return data_2 + return "UNKNOWN" + + +def has_support(url): + """Check to see if the current release has support + 0: has support + 1: Support ending soon + 2: No support, upgrading possible + 3: No support, available to download + 4: No support, cannot download + """ + support_policy = get_support(url) + release = get_release() + if release == "UNKNOWN": + return 4 + try: + support_policy = support_policy[release] + except IndexError: + return 0 + if support_policy == "AEL": + return 1 + if support_policy == "EWR": + return 2 + if support_policy == "EBA": + return 3 + return 4 + + HOME = getenv("HOME") +http = urllib3.PoolManager() +support_status = has_support(http) # check if system-installer will be running, if it is, do not show the welcome screen with open("/proc/cmdline", "r") as cmdline_file: cmdline = cmdline_file.read() if "system-installer" in cmdline: # Not wanted to be running ootb + if support_status >= 2: + # notify of lack of support + pass sys.exit(0) if ((not path.exists(HOME + "/.drauger-tut")) and (not path.exists("/etc/system-installer/oem-post-install.flag"))): try: main_ui.welcome_show() except Exception as e: - Popen("/usr/share/drauger-welcome/log-out 2 /usr/share/drauger-welcome/tut.py \"Error: %s . main_ui.py has failed.\"" % (e)) -else: - exit(2) + subprocess.Popen("/usr/share/drauger-welcome/log-out 2 /usr/share/drauger-welcome/tut.py \"Error: %s . main_ui.py has failed.\"" % (e)) +# Notify of lack of support +if support_status == 1: + # Notify of UPCOMING lack of support + pass +elif support_status >= 2: + # notify of lack of support + pass From 8f2767c8708fcf23e20515412a2705cf10ef0482 Mon Sep 17 00:00:00 2001 From: Thomas Castleman <31315409+Batcastle@users.noreply.github.com> Date: Thu, 23 Mar 2023 10:42:51 -0400 Subject: [PATCH 34/39] remove uninstall button and other code This breaks `drauger-welcome`. Also, we want this package to remain installed for the future "Lack of support" warning being included. --- .../dist-packages/drauger_welcome/main_ui.py | 49 +------------------ 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py b/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py index 9ffec4e..38e2c8e 100755 --- a/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py +++ b/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py @@ -3,7 +3,7 @@ # # main_ui.py # -# Copyright 2022 Thomas Castleman +# Copyright 2023 Thomas Castleman # Additional contributors: Logan L Johnson # # This program is free software; you can redistribute it and/or modify @@ -329,15 +329,6 @@ def reset(self, button): self.button8.connect("clicked", self.onshortcutclicked) self.grid.attach(self.button8, 6, 6, 1, 1) - self.label9 = Gtk.Label() - self.label9.set_markup(uninstall) - self.label9.set_justify(Gtk.Justification.CENTER) - self.grid.attach(self.label9, 4, 9, 1, 1) - - self.button9 = Gtk.Button.new_from_icon_name("delete", 3) - self.button9.connect("clicked", self.removal_conf) - self.grid.attach(self.button9, 4, 10, 1, 1) - self.label10 = Gtk.Label() self.label10.set_markup(lang_sup2) self.label10.set_justify(Gtk.Justification.CENTER) @@ -362,8 +353,6 @@ def reset(self, button): self.button2.set_margin_end(width) self.button3.set_margin_start(width) self.button1.set_margin_start(width) - self.button9.set_margin_end(width) - self.button9.set_margin_start(width) self.button8.set_margin_end(width) self.button7.set_margin_end(width) self.button7.set_margin_start(width) @@ -377,8 +366,6 @@ def reset(self, button): self.label10.set_margin_start(width) self.label9.set_margin_start(width) self.label10.set_margin_end(width) - self.label9.set_margin_end(width) - self.label9.set_margin_start(width) self.label6.set_margin_end(width) self.label6.set_margin_start(width) self.label1.set_margin_start(width) @@ -397,27 +384,6 @@ def start_up_toggle(self, widget): show_at_start_up = self.start_up.get_active() print(show_at_start_up) - def removal_conf(self, button): - self.clear_window() - - self.label = Gtk.Label() - self.label.set_markup(message_show_remove) - self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) - self.grid.attach(self.label, 1, 1, 3, 1) - - self.button1 = Gtk.Button.new_with_label(label=YES) - self.button1.connect("clicked", self.onuninstallclicked) - self.button1 = self._set_default_margins(self.button1) - self.grid.attach(self.button1, 1, 2, 1, 1) - - self.button2 = Gtk.Button.new_with_label(label=NO) - self.button2.connect("clicked", self.reset) - self.button2 = self._set_default_margins(self.button2) - self.grid.attach(self.button2, 3, 2, 1, 1) - - self.show_all() - def show_accessibility_settings(self, button): self.clear_window() @@ -1115,18 +1081,7 @@ def onshortcutclicked(self, button): self.button1.set_margin_bottom(int(width / 10)) self.show_all() - - def onuninstallclicked(self, button): - # have an uninstall comfirmation dialoge then uninstall based on - # the answer - try: - subprocess.check_call("/usr/share/drauger-welcome/u.sh") - except subprocess.CalledProcessError: - subprocess.check_call(["/usr/share/drauger-welcome/log-out", - "2", "/usr/share/drauger-welcome/main.py", - "/etc/drauger-welcome/u.sh has failed. See error log entry for u.sh for more info.", - "drauger-welcome", "UNKNOWN", "UNKNOWN"]) - + def onyesclicked(self, button): self.onuninstallclicked("clicked") From 390a47eaedcdd6033d26e162d46c126f5889eefb Mon Sep 17 00:00:00 2001 From: Thomas Castleman <31315409+Batcastle@users.noreply.github.com> Date: Thu, 23 Mar 2023 11:28:24 -0400 Subject: [PATCH 35/39] Delete u.sh file is no longer needed --- usr/share/drauger-welcome/u.sh | 65 ---------------------------------- 1 file changed, 65 deletions(-) delete mode 100755 usr/share/drauger-welcome/u.sh diff --git a/usr/share/drauger-welcome/u.sh b/usr/share/drauger-welcome/u.sh deleted file mode 100755 index f40a9a6..0000000 --- a/usr/share/drauger-welcome/u.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# -*- coding: utf-8 -*- -# -# u.sh -# -# Copyright 2022 Thomas Castleman -# -# 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 2 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, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. -# -function translate () -{ - VAR="$1" - CONCAT_1="$2" - CONCAT_2="$3" - if [ -d /etc/drauger-locales/"${LANG//.UTF-8/}" ]; then - FILE=$(grep -v '^#' /etc/drauger-locales/"${LANG//.UTF-8/}"/drauger-welcome.conf) - else - FILE="None" - fi - if [ "$VAR" == "uninst_notify" ] && [ "$FILE" == "None" ]; then - uninst_notify="drauger-welcome has been removed" - return "$uninst_notify" - elif [ "$VAR" == "uninst_notify" ]; then - uninst_notify=$(echo "$FILE" | grep "^uninst_notify" | awk -F '"' '{print $2}') - return "$uninst_notify" - fi - if [ "$VAR" == "remove" ] && [ "$FILE" == "None" ]; then - remove="Removing drauger-welcome . . ." - return "$remove" - elif [ "$VAR" == "remove" ]; then - remove=$(echo "$FILE" | grep "^remove" | awk -F '"' '{print $2}') - return "$remove" - fi - if [ "$VAR" == "error_uninst" ] && [ "$FILE" == "None" ]; then - error_uninst="An error was encountered removing drauger-welcome. Error code $CONCAT_1 was thrown from apt.\nPlease run 'sudo apt purge drauger-welcome' in a terminal in order to remove it." - return "$error_uninst" - elif [ "$VAR" == "error_uninst" ]; then - error_uninst=$(echo "$FILE" | grep "^error_uninst" | awk -F '"' '{print $2}' | sed "s/\$error/$CONCAT_1/") - return "$error_uninst" - fi - -} -{ - /usr/bin/pkexec /usr/bin/apt -y purge drauger-welcome | /usr/bin/zenity --progress --pulsate --auto-close --no-cancel --text=$(translate "remove") - /usr/bin/notify-send --icon="/usr/share/icons/Drauger/scalable/menus/drauger_os-logo.svg" --app-name="Drauger Welcome" $(translate "uninst_notify") - exit 0 -} || { - error="$?" - /usr/bin/zenity --error --no-wrap --text=$(translate "error_uninst" $error) - /usr/share/drauger-welcome/log-out "$error" /usr/share/drauger-welcome/u.sh "apt has throw an error on de-install. Usually a package has been configured wrong and apt is struggling to recover." "drauger-installer" "$PWD" "$0" - exit 2 -} From 7ff01c8d6bf5bf0acb980f05169400f6f627e846 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 24 Mar 2023 00:21:13 -0400 Subject: [PATCH 36/39] updated dependencies --- DEBIAN/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEBIAN/control b/DEBIAN/control index 457ea68..e46ea9f 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -5,7 +5,7 @@ Section: misc Homepage: https://github.com/drauger-os-development/drauger-welcome Architecture: amd64 Priority: optional -Depends: python3 (>=3.5.1-3), gir1.2-gtk-3.0 (>=3.24.12-1ubuntu1), drauger-icons (>=0.0.2), bash, procps, xfconf, python3-apt, python3-urllib3 (>1.25) +Depends: python3 (>=3.5.1-3), gir1.2-gtk-3.0 (>=3.24.12-1ubuntu1), drauger-icons (>=0.0.2), bash, procps, xfconf, python3-apt, python3-urllib3 (>=1.25) Replaces: drauger-tutorial (>=1.0) Breaks: drauger-tutorial (>=1.0) Description: Welcome screen and tutorial All-in-One for Drauger OS From 99fc21de37f54bd401e3cbf91b7993d23a5d25c8 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 24 Mar 2023 00:23:02 -0400 Subject: [PATCH 37/39] complete support for alerts window. need to add a "do not show again" flag for each support level above 0. --- .../dist-packages/drauger_welcome/__init__.py | 3 +- usr/share/drauger-welcome/tut.py | 149 ++++++++++++++---- 2 files changed, 117 insertions(+), 35 deletions(-) diff --git a/usr/lib/python3/dist-packages/drauger_welcome/__init__.py b/usr/lib/python3/dist-packages/drauger_welcome/__init__.py index 28a719a..0166e81 100755 --- a/usr/lib/python3/dist-packages/drauger_welcome/__init__.py +++ b/usr/lib/python3/dist-packages/drauger_welcome/__init__.py @@ -3,7 +3,7 @@ # # __init__.py # -# Copyright 2022 Thomas Castleman +# Copyright 2023 Thomas Castleman # # 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 @@ -23,3 +23,4 @@ # """__init__ for drauger-welcome""" from drauger_welcome import main_ui as main_ui +from drauger_welcome import alerts as alerts diff --git a/usr/share/drauger-welcome/tut.py b/usr/share/drauger-welcome/tut.py index 90a2b2d..edc915d 100755 --- a/usr/share/drauger-welcome/tut.py +++ b/usr/share/drauger-welcome/tut.py @@ -3,7 +3,7 @@ # # tut.py # -# Copyright 2022 Thomas Castleman +# Copyright 2023 Thomas Castleman # # 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 @@ -27,11 +27,12 @@ import subprocess import urllib3 import drauger_welcome.main_ui as main_ui +import drauger_welcome.alerts as alerts # Make it easier for us to print to stderr def eprint(*args, **kwargs): - print(*args, file=sys.stderr, **kwargs) + print(*args, file=sys.stderr, **kwargs) def get_support(url): @@ -43,12 +44,12 @@ def get_support(url): # filter comments for each in range(len(data) - 1, -1, -1): if data[each] == "": - del data[each] - elif data[each][0] == "#": - del data[each] + del data[each] + elif data[each][0] == "#": + del data[each] # parse remaining data for each in enumerate(data): - data[each[0]] = each[1].split(" - ") + data[each[0]] = each[1].split(" - ") data = dict(data) return data @@ -57,22 +58,22 @@ def get_release(): """Get Drauger OS release""" # first source with open("/usr/drauger/os-info.txt", "r") as file: - data_1 = file.read() + data_1 = file.read() if data_1[-1] == "\n": - data_1 = data_1[:-1].split(" ")[0] + data_1 = data_1[:-1].split(" ")[0] # second source data_2 = subprocess.check_output(["lsb_release", "-rs"]).decode()[:-1] # third source with open("/etc/os-release", "r") as file: - data_3 = file.read().split("\n") + data_3 = file.read().split("\n") data_3 = [each for each in data_3 if "VERSION" in each] data_3 = dict([each.split("=") for each in data_3]) data_3 = data_3["VERSION_ID"].strip("\"") # check to see if sources agree - if data_1 in (data_2, data_3) - return data_1 + if data_1 in (data_2, data_3): + return data_1 if data_2 == data_3: - return data_2 + return data_2 return "UNKNOWN" @@ -84,20 +85,23 @@ def has_support(url): 3: No support, available to download 4: No support, cannot download """ - support_policy = get_support(url) + try: + support_policy = get_support(url) + except urllib3.exceptions.MaxRetryError: + return 0 release = get_release() if release == "UNKNOWN": - return 4 + return 4 try: support_policy = support_policy[release] - except IndexError: - return 0 + except (KeyError, IndexError): + return 0 if support_policy == "AEL": - return 1 + return 1 if support_policy == "EWR": - return 2 + return 2 if support_policy == "EBA": - return 3 + return 3 return 4 @@ -106,22 +110,99 @@ def has_support(url): support_status = has_support(http) # check if system-installer will be running, if it is, do not show the welcome screen with open("/proc/cmdline", "r") as cmdline_file: - cmdline = cmdline_file.read() + cmdline = cmdline_file.read() if "system-installer" in cmdline: - # Not wanted to be running ootb - if support_status >= 2: - # notify of lack of support - pass - sys.exit(0) + # Not wanted to be running ootb + if support_status == 2: + # notify of lack of support + alerts.post_alert("No Longer Supported", f"""WARNING +Your current version of Drauger OS ({ get_release() }) is no +longer supported. In order to remedy this, please upgrade to +the next version by run these commands in a terminal: + + +sudo apt update +sudo apt install drauger-upgrade-script +upgrade-drauger + +""") + elif support_status == 3: + alerts.post_alert("No Longer Supported, Upgrade No Longer Available", f"""WARNING +Your current version of Drauger OS ({ get_release() }) is no +longer supported, and upgrading to the next version must be +done manually, or you must install a new OS. + +You have been warned. +""") + elif support_status == 4: + alerts.post_alert("Extremely Old Release", f"""WARNING +Your current version of Drauger OS ({ get_release() }) is extremely old +and no longer supported. No updates are available. Upgrading is extremely +risky, as is continuing to run this version of Drauger OS. + +Here be dragons. Proceed at your own peril. +You have been warned. +""") + elif support_status == 1: + post_alert("Support Ending Soon", """NOTICE +Your current version of Drauger OS (7.6) is going to +be losing support soon. In order to avoid this, and upgrade to the +new version, please run these commands in a terminal at your +earliest convenience: + + +sudo apt update +sudo apt install drauger-upgrade-script +upgrade-drauger + +""") + sys.exit(0) if ((not path.exists(HOME + "/.drauger-tut")) and (not path.exists("/etc/system-installer/oem-post-install.flag"))): - try: - main_ui.welcome_show() - except Exception as e: - subprocess.Popen("/usr/share/drauger-welcome/log-out 2 /usr/share/drauger-welcome/tut.py \"Error: %s . main_ui.py has failed.\"" % (e)) + try: + main_ui.welcome_show() + except Exception as e: + subprocess.Popen("/usr/share/drauger-welcome/log-out 2 /usr/share/drauger-welcome/tut.py \"Error: %s . main_ui.py has failed.\"" % (e)) # Notify of lack of support -if support_status == 1: - # Notify of UPCOMING lack of support - pass -elif support_status >= 2: +if support_status == 2: # notify of lack of support - pass + alerts.post_alert("No Longer Supported", f"""WARNING +Your current version of Drauger OS ({ get_release() }) is no +longer supported. In order to remedy this, please upgrade to +the next version by run these commands in a terminal: + + +sudo apt update +sudo apt install drauger-upgrade-script +upgrade-drauger + +""") +elif support_status == 3: + alerts.post_alert("\tNo Longer Supported, Upgrade No Longer Available\t", f"""WARNING +Your current version of Drauger OS ({ get_release() }) is no +longer supported, and upgrading to the next version must be +done manually, or you must install a new OS. + +You have been warned. +""") +elif support_status == 4: + alerts.post_alert("Extremely Old Release", f"""WARNING +Your current version of Drauger OS ({ get_release() }) is extremely old +and no longer supported. No updates are available. Upgrading is extremely +risky, as is continuing to run this version of Drauger OS. + +Here be dragons. Proceed at your own peril. +You have been warned. +""") +elif support_status == 1: + alerts.post_alert("Support Ending Soon", """NOTICE +Your current version of Drauger OS (7.6) is going to +be losing support soon. In order to avoid this, and upgrade to the +new version, please run these commands in a terminal at your +earliest convenience: + + +sudo apt update +sudo apt install drauger-upgrade-script +upgrade-drauger + +""") From b5d27a412da92ce3ae8a31e7621a12c0d3a456b9 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 26 Mar 2023 01:20:57 -0400 Subject: [PATCH 38/39] add alerts lib, implement "no show" flag --- .../dist-packages/drauger_welcome/alerts.py | 122 ++++++++++++++++++ usr/share/drauger-welcome/tut.py | 45 ++++--- 2 files changed, 152 insertions(+), 15 deletions(-) create mode 100755 usr/lib/python3/dist-packages/drauger_welcome/alerts.py diff --git a/usr/lib/python3/dist-packages/drauger_welcome/alerts.py b/usr/lib/python3/dist-packages/drauger_welcome/alerts.py new file mode 100755 index 0000000..4e28aaf --- /dev/null +++ b/usr/lib/python3/dist-packages/drauger_welcome/alerts.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# alerts.py +# +# Copyright 2023 Thomas Castleman +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +# +# +"""Explain what this program does here!!!""" +from __future__ import print_function +import sys +import json +import os +import gi +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk + + +def __eprint__(*args, **kwargs): + """Make it easier for us to print to stderr""" + print(*args, file=sys.stderr, **kwargs) + + +if sys.version_info[0] == 2: + __eprint__("Please run with Python 3 as Python 2 is End-of-Life.") + exit(2) + + +class Alert(Gtk.Window): + """Alert window""" + def __init__(self, window_title, message, msg_type): + """Initialize Window""" + Gtk.Window.__init__(self, title=window_title) + self.grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL) + self.add(self.grid) + self.icon = "/usr/share/icons/Drauger/scalable/menus/drauger_os-logo.svg" + self.set_icon_from_file(self.icon) + + self.HOME = os.getenv("HOME") + with open(f"{ self.HOME }/.config/drauger-welcome/no-show.json", + "r") as file: + self.show_settings = json.load(file) + + self.msg_type = msg_type + + self.reset(window_title, message) + + def reset(self, window_title, message): + """Create Window contents""" + label = Gtk.Label() + label.set_markup(f"{ window_title }") + label.set_justify(Gtk.Justification.CENTER) + label = self._set_default_margins(label) + self.grid.attach(label, 1, 1, 8, 1) + + label1 = Gtk.Label() + label1.set_markup(message) + label1.set_justify(Gtk.Justification.CENTER) + label1 = self._set_default_margins(label1) + self.grid.attach(label1, 1, 2, 8, 1) + + start_up = Gtk.CheckButton.new_with_label("Do not show this alert again") + start_up.set_active(not self.show_settings[self.msg_type]) + start_up.connect("toggled", self.start_up_toggle) + start_up = self._set_default_margins(start_up) + self.grid.attach(start_up, 1, 3, 2, 1) + + button = Gtk.Button.new_with_label("Close") + button.connect("clicked", self.exit) + button = self._set_default_margins(button) + self.grid.attach(button, 8, 3, 1, 1) + + def start_up_toggle(self, widget): + """Control whether to show this alert or not""" + active = not widget.get_active() + self.show_settings[self.msg_type] = active + with open(f"{ self.HOME }/.config/drauger-welcome/no-show.json", + "w") as file: + json.dump(self.show_settings, file, indent=2) + with open(f"{ self.HOME }/.config/drauger-welcome/no-show.json", + "r") as file: + self.show_settings = json.load(file) + + def _set_default_margins(self, widget): + """Set default margin size""" + widget.set_margin_start(10) + widget.set_margin_end(10) + widget.set_margin_top(10) + widget.set_margin_bottom(10) + return widget + + def exit(self, button): + """Exit""" + Gtk.main_quit("delete-event") + self.destroy() + self.data = 1 + return 1 + + +def post_alert(title, message, msg_type): + window = Alert(title, message, msg_type) + window.set_decorated(False) + window.set_resizable(False) + window.set_position(Gtk.WindowPosition.CENTER) + window.connect("delete-event", Alert.exit) + window.show_all() + Gtk.main() diff --git a/usr/share/drauger-welcome/tut.py b/usr/share/drauger-welcome/tut.py index edc915d..f183ddc 100755 --- a/usr/share/drauger-welcome/tut.py +++ b/usr/share/drauger-welcome/tut.py @@ -23,9 +23,10 @@ # from __future__ import print_function import sys -from os import path, getenv +import os import subprocess import urllib3 +import json import drauger_welcome.main_ui as main_ui import drauger_welcome.alerts as alerts @@ -105,15 +106,29 @@ def has_support(url): return 4 -HOME = getenv("HOME") +HOME = os.getenv("HOME") http = urllib3.PoolManager() support_status = has_support(http) + +# Check for show settings +show_settings = {"EOL": True, "EBA": True, "EWR": True, "AEL": True} +if not os.path.exists(f"{ HOME }/.config/drauger-welcome"): + os.mkdir(f"{ HOME }/.config/drauger-welcome") +if not os.path.exists(f"{ HOME }/.config/drauger-welcome/no-show.json"): + with open(f"{ HOME }/.config/drauger-welcome/no-show.json", "w") as file: + json.dump(show_settings, file, indent=2) +else: + with open(f"{ HOME }/.config/drauger-welcome/no-show.json", "r") as file: + show_settings = json.load(file) + +# show settings loaded or generated + # check if system-installer will be running, if it is, do not show the welcome screen with open("/proc/cmdline", "r") as cmdline_file: cmdline = cmdline_file.read() if "system-installer" in cmdline: # Not wanted to be running ootb - if support_status == 2: + if ((support_status == 2) and (show_settings["EWR"])): # notify of lack of support alerts.post_alert("No Longer Supported", f"""WARNING Your current version of Drauger OS ({ get_release() }) is no @@ -126,7 +141,7 @@ def has_support(url): upgrade-drauger """) - elif support_status == 3: + elif ((support_status == 3) and (show_settings["EBA"])): alerts.post_alert("No Longer Supported, Upgrade No Longer Available", f"""WARNING Your current version of Drauger OS ({ get_release() }) is no longer supported, and upgrading to the next version must be @@ -134,7 +149,7 @@ def has_support(url): You have been warned. """) - elif support_status == 4: + elif ((support_status == 4) and (show_settings["EOL"])): alerts.post_alert("Extremely Old Release", f"""WARNING Your current version of Drauger OS ({ get_release() }) is extremely old and no longer supported. No updates are available. Upgrading is extremely @@ -143,9 +158,9 @@ def has_support(url): Here be dragons. Proceed at your own peril. You have been warned. """) - elif support_status == 1: - post_alert("Support Ending Soon", """NOTICE -Your current version of Drauger OS (7.6) is going to + elif ((support_status == 1) and (show_settings["AEL"])): + post_alert("Support Ending Soon", f"""NOTICE +Your current version of Drauger OS ({ get_release() }) is going to be losing support soon. In order to avoid this, and upgrade to the new version, please run these commands in a terminal at your earliest convenience: @@ -157,13 +172,13 @@ def has_support(url): """) sys.exit(0) -if ((not path.exists(HOME + "/.drauger-tut")) and (not path.exists("/etc/system-installer/oem-post-install.flag"))): +if ((not os.path.exists(HOME + "/.drauger-tut")) and (not os.path.exists("/etc/system-installer/oem-post-install.flag"))): try: main_ui.welcome_show() except Exception as e: subprocess.Popen("/usr/share/drauger-welcome/log-out 2 /usr/share/drauger-welcome/tut.py \"Error: %s . main_ui.py has failed.\"" % (e)) # Notify of lack of support -if support_status == 2: +if ((support_status == 2) and (show_settings["EWR"])): # notify of lack of support alerts.post_alert("No Longer Supported", f"""WARNING Your current version of Drauger OS ({ get_release() }) is no @@ -176,7 +191,7 @@ def has_support(url): upgrade-drauger """) -elif support_status == 3: +elif ((support_status == 3) and (show_settings["EBA"])): alerts.post_alert("\tNo Longer Supported, Upgrade No Longer Available\t", f"""WARNING Your current version of Drauger OS ({ get_release() }) is no longer supported, and upgrading to the next version must be @@ -184,7 +199,7 @@ def has_support(url): You have been warned. """) -elif support_status == 4: +elif ((support_status == 4) and (show_settings["EOL"])): alerts.post_alert("Extremely Old Release", f"""WARNING Your current version of Drauger OS ({ get_release() }) is extremely old and no longer supported. No updates are available. Upgrading is extremely @@ -193,9 +208,9 @@ def has_support(url): Here be dragons. Proceed at your own peril. You have been warned. """) -elif support_status == 1: - alerts.post_alert("Support Ending Soon", """NOTICE -Your current version of Drauger OS (7.6) is going to +elif ((support_status == 1) and (show_settings["AEL"])): + alerts.post_alert("Support Ending Soon", f"""NOTICE +Your current version of Drauger OS ({ get_release() }) is going to be losing support soon. In order to avoid this, and upgrade to the new version, please run these commands in a terminal at your earliest convenience: From c267aa3e7333f06b6c89a8fcc4e3e58472bb9710 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sat, 1 Apr 2023 14:56:46 -0400 Subject: [PATCH 39/39] fixed AttributeError, improved spacing on Welcome Screen --- DEBIAN/control | 2 +- usr/bin/drauger-welcome | 2 +- .../dist-packages/drauger_welcome/main_ui.py | 68 ++++++++----------- .../applications/Drauger_Welcome.desktop | 4 +- 4 files changed, 34 insertions(+), 42 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index e46ea9f..3bc75d4 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: drauger-welcome -Version: 4.9.7 +Version: 4.9.8 Maintainer: Thomas Castleman Section: misc Homepage: https://github.com/drauger-os-development/drauger-welcome diff --git a/usr/bin/drauger-welcome b/usr/bin/drauger-welcome index bf23986..dcd29f2 100755 --- a/usr/bin/drauger-welcome +++ b/usr/bin/drauger-welcome @@ -25,7 +25,7 @@ from __future__ import print_function import sys import drauger_welcome -VERSION = "4.9.7" +VERSION = "4.9.8" HELP = """ drauger-welcome, Version %s \t-h, --help print this help dialoge. diff --git a/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py b/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py index 38e2c8e..d9a80d7 100755 --- a/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py +++ b/usr/lib/python3/dist-packages/drauger_welcome/main_ui.py @@ -250,128 +250,120 @@ def reset(self, button): Drauger OS %s """ % (s) + "") self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 1, 8, 1) self.label = Gtk.Label() self.label.set_markup(welcome_label) self.label.set_justify(Gtk.Justification.CENTER) + self.label = self._set_default_margins(self.label) self.grid.attach(self.label, 1, 2, 8, 1) self.label1 = Gtk.Label() self.label1.set_markup(website) self.label1.set_justify(Gtk.Justification.CENTER) + self.label1 = self._set_default_margins(self.label1) self.grid.attach(self.label1, 1, 3, 1, 1) self.button1 = Gtk.Button.new_from_icon_name("cs-network", 3) self.button1.connect("clicked", self.onwebclicked) + self.button1 = self._set_default_margins(self.button1) self.grid.attach(self.button1, 1, 4, 1, 1) self.label2 = Gtk.Label() self.label2.set_markup(README) self.label2.set_justify(Gtk.Justification.CENTER) + self.label2 = self._set_default_margins(self.label2) self.grid.attach(self.label2, 6, 3, 1, 1) self.button2 = Gtk.Button.new_from_icon_name("document", 3) self.button2.connect("clicked", self.show_readme) + self.button2 = self._set_default_margins(self.button2) self.grid.attach(self.button2, 6, 4, 1, 1) self.label3 = Gtk.Label() self.label3.set_markup(tutorial_label) self.label3.set_justify(Gtk.Justification.CENTER) + self.label3 = self._set_default_margins(self.label3) self.grid.attach(self.label3, 1, 5, 1, 1) self.button3 = Gtk.Button.new_from_icon_name("dictionary", 3) self.button3.connect("clicked", self.tutorial) + self.button3 = self._set_default_margins(self.button3) self.grid.attach(self.button3, 1, 6, 1, 1) self.label4 = Gtk.Label() self.label4.set_markup(help_button) self.label4.set_justify(Gtk.Justification.CENTER) + self.label4 = self._set_default_margins(self.label4) self.grid.attach(self.label4, 1, 7, 1, 1) self.button4 = Gtk.Button.new_from_icon_name("help", 3) self.button4.connect("clicked", self.onhelpclicked) + self.button4 = self._set_default_margins(self.button4) self.grid.attach(self.button4, 1, 8, 1, 1) self.label5 = Gtk.Label() self.label5.set_markup(drivers) self.label5.set_justify(Gtk.Justification.CENTER) + self.label5 = self._set_default_margins(self.label5) self.grid.attach(self.label5, 6, 7, 1, 1) self.button5 = Gtk.Button.new_from_icon_name("jockey", 3) self.button5.connect("clicked", self.ondriveclicked) + self.button5 = self._set_default_margins(self.button5) self.grid.attach(self.button5, 6, 8, 1, 1) self.label6 = Gtk.Label() self.label6.set_markup(lang_sup) self.label6.set_justify(Gtk.Justification.CENTER) + self.label6 = self._set_default_margins(self.label6) self.grid.attach(self.label6, 4, 5, 1, 1) self.button6 = Gtk.Button.new_from_icon_name("accessibility", 3) self.button6.connect("clicked", self.show_accessibility_settings) + self.button6 = self._set_default_margins(self.button6) self.grid.attach(self.button6, 4, 6, 1, 1) self.label7 = Gtk.Label() self.label7.set_markup(donate) - self.label.set_justify(Gtk.Justification.CENTER) + self.label7.set_justify(Gtk.Justification.CENTER) + self.label7 = self._set_default_margins(self.label7) self.grid.attach(self.label7, 4, 7, 1, 1) self.button7 = Gtk.Button.new_from_icon_name("money-manager-ex", 3) self.button7.connect("clicked", self.ondonateclicked) + self.button7 = self._set_default_margins(self.button7) self.grid.attach(self.button7, 4, 8, 1, 1) self.label8 = Gtk.Label() self.label8.set_markup(shortcuts) self.label8.set_justify(Gtk.Justification.CENTER) + self.label8 = self._set_default_margins(self.label8) self.grid.attach(self.label8, 6, 5, 1, 1) self.button8 = Gtk.Button.new_from_icon_name("keyboard", 3) self.button8.connect("clicked", self.onshortcutclicked) + self.button8 = self._set_default_margins(self.button8) self.grid.attach(self.button8, 6, 6, 1, 1) - self.label10 = Gtk.Label() - self.label10.set_markup(lang_sup2) - self.label10.set_justify(Gtk.Justification.CENTER) - self.grid.attach(self.label10, 4, 3, 1, 1) + self.label9 = Gtk.Label() + self.label9.set_markup(lang_sup2) + self.label9.set_justify(Gtk.Justification.CENTER) + self.label9 = self._set_default_margins(self.label9) + self.grid.attach(self.label9, 4, 3, 1, 1) - self.button10 = Gtk.Button.new_from_icon_name("preferences-desktop-locale", 3) - self.button10.connect("clicked", self.onlangsupportclicked) - self.grid.attach(self.button10, 4, 4, 1, 1) + self.button9 = Gtk.Button.new_from_icon_name("preferences-desktop-locale", 3) + self.button9.connect("clicked", self.onlangsupportclicked) + self.button9 = self._set_default_margins(self.button9) + self.grid.attach(self.button9, 4, 4, 1, 1) self.start_up = Gtk.CheckButton.new_with_label(start_up_label) self.start_up.set_active(show_at_start_up) self.start_up.connect("toggled", self.start_up_toggle) + self.start_up= self._set_default_margins(self.start_up) self.grid.attach(self.start_up, 1, 13, 2, 1) - width = self.get_size()[0] - width = int(width * 0.125) - self.button10.set_margin_start(width) - self.button10.set_margin_end(width) - self.button6.set_margin_start(width) - self.button6.set_margin_end(width) - self.button4.set_margin_start(width) - self.button2.set_margin_end(width) - self.button3.set_margin_start(width) - self.button1.set_margin_start(width) - self.button8.set_margin_end(width) - self.button7.set_margin_end(width) - self.button7.set_margin_start(width) - self.button5.set_margin_end(width) - self.label2.set_margin_end(width) - self.label8.set_margin_end(width) - self.label5.set_margin_end(width) - self.label7.set_margin_end(width) - self.label7.set_margin_start(width) - self.label4.set_margin_start(width) - self.label10.set_margin_start(width) - self.label9.set_margin_start(width) - self.label10.set_margin_end(width) - self.label6.set_margin_end(width) - self.label6.set_margin_start(width) - self.label1.set_margin_start(width) - self.start_up.set_margin_start(int(width / 2)) - self.start_up.set_margin_bottom(int(width / 2)) - self.show_all() def show_readme(self, widget): @@ -1081,7 +1073,7 @@ def onshortcutclicked(self, button): self.button1.set_margin_bottom(int(width / 10)) self.show_all() - + def onyesclicked(self, button): self.onuninstallclicked("clicked") diff --git a/usr/share/applications/Drauger_Welcome.desktop b/usr/share/applications/Drauger_Welcome.desktop index ae45d56..6a915c2 100644 --- a/usr/share/applications/Drauger_Welcome.desktop +++ b/usr/share/applications/Drauger_Welcome.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Name=Drauger Welcome -Version=4.6 -Exec=/usr/share/drauger-welcome/main_ui.py +Version=4.9.8 +Exec=/usr/bin/drauger-welcome Comment=Welcome Screen for Drauger OS Icon=/usr/share/icons/Drauger/scalable/menus/drauger_os-logo.svg Type=Application