Skip to content

Commit

Permalink
Merge pull request #25 from tcet-opensource/resolution-fix
Browse files Browse the repository at this point in the history
Resolution and Installer Fix
  • Loading branch information
Akash6222 authored Feb 11, 2024
2 parents 07754b7 + f908046 commit 0274e66
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 49 deletions.
Binary file added tcet-welcome/assets/docker_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tcet-welcome/assets/github_cli_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tcet-welcome/assets/golang_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tcet-welcome/assets/google_chrome_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tcet-welcome/assets/intellij_idea_(ce)_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tcet-welcome/assets/java_17_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tcet-welcome/assets/libre_office_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tcet-welcome/assets/pycharm_(ce)_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tcet-welcome/assets/rust_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tcet-welcome/assets/vs_code_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 54 additions & 43 deletions tcet-welcome/scripts/installer.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#!/usr/bin/env python

import multiprocessing
import os
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Gtk, GdkPixbuf
import subprocess
import signal

package_map = {
"NodeJS": "nodejs",
"Docker": "docker",
"Google Chrome": "google-chrome",
"VS Code": "visual-studio-code-bin",
"Java": "jdk17-openjdk",
"Libre Office": "libreoffice-still",
"PyCharm (CE)":"pycharm-community-edition",
"Libre Office": "libreoffice-still",
"Java 17": "jdk17-openjdk",
"GitHub CLI":"github-cli",
"Neovim":"neovim",
"Rust":"rust",
"Intellij Idea (CE)":"intellij-idea-community-edition",
"GoLang":"go"
}
Expand All @@ -24,66 +27,74 @@ class MyApp(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Application Installer (BETA)")
self.set_border_width(10)
self.set_default_size(500, 200)
self.set_default_size(400, 200)
self.set_resizable(False)

grid = Gtk.Grid()
grid.set_column_spacing(10)
grid.set_row_spacing(10)
grid.set_column_spacing(15)
grid.set_row_spacing(15)
self.add(grid)

self.set_icon_from_file(f"{installDir}/assets/tcetlinux-logo.png")

self.checkboxes = {}

col = 0
row = 0
self.col = 0
self.row = 0
for i, displayed_name in enumerate(package_map):
icon_path = f"{installDir}/assets/{displayed_name.lower().replace(' ', '_')}_icon.png"
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(icon_path, 48, 48, True)

vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)

image = Gtk.Image.new_from_pixbuf(pixbuf)
vbox.pack_start(image, False, False, 0)

checkbox = Gtk.CheckButton(label=displayed_name)
self.checkboxes[displayed_name] = checkbox
if i % 5 == 0 and i > 0:
col = 0
row += 1
vbox.pack_start(checkbox, False, False, 0)

grid.attach(checkbox, col, row, 1, 1)
col += 1
grid.attach(vbox, self.col, self.row, 1, 1)
self.col += 1
if self.col == 5:
self.col = 0
self.row += 1


button = Gtk.Button(label="Install")
button.set_property("height-request", 0)
grid.set_column_homogeneous(True)
grid.set_row_homogeneous(True)
grid.attach(button, 2, 2, 1, 1)
grid.attach(button, 2, self.row+1, 1, 1)
button.connect("clicked", self.on_install_clicked)

def error_msg(self, package):
dialog = Gtk.MessageDialog(transient_for=self,flags=0, message_type=Gtk.MessageType.ERROR,buttons=Gtk.ButtonsType.OK,text="Error installing "+package)
dialog.format_secondary_text("Package "+package+" is not available. Please update the mirrorlist and try again.")
dialog.run()
dialog.destroy()
Gtk.main_quit()

def success_msg(self):
dialog = Gtk.MessageDialog(transient_for=self,flags=0, message_type=Gtk.MessageType.ERROR,buttons=Gtk.ButtonsType.OK,text="Packages Installed ")
dialog.format_secondary_text("Packages are installed successfully.")
dialog.run()
dialog.destroy()
Gtk.main_quit()
def clear_checkboxes(self):
for checkbox in self.checkboxes.values():
checkbox.set_active(False)

def on_install_clicked(self, widget):
to_install = [v for k,v in package_map.items() if self.checkboxes[k].get_active()]
error = False
installCMD = "pkexec yay -S --noconfirm"
for package in to_install:
subprocess.run(["pkexec", "yay", "-S", package, "--noconfirm"])
try:
subprocess.check_output(["pacman", "-Q", package]).decode().split("\n")
except subprocess.CalledProcessError:
self.error_msg(package)
error = True

if not error:
self.success_msg()

installCMD = installCMD + " " + package
result = os.popen('echo $XDG_CURRENT_DESKTOP').read().strip()
match result:
case "GNOME":
p = subprocess.Popen(["gnome-terminal", "--","bash", "-c", installCMD], preexec_fn=os.setpgrp)
process = multiprocessing.Process(target = p)
if not process.is_alive:
os.killpg(p.pid, signal.SIGINT)
case "XFCE":
p = subprocess.Popen(["xfce4-terminal", "-e", installCMD], preexec_fn=os.setpgrp)
process = multiprocessing.Process(target = p)
if not process.is_alive:
os.killpg(p.pid, signal.SIGINT)
case _:
# yad --image="dialog-question" --title "Alert" --text "Can't recongnize desktop environment" --button="yad-ok:0"
print("Cant Recognize DE")

self.clear_checkboxes()

win = MyApp()
win.connect("destroy", Gtk.main_quit)
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()
6 changes: 6 additions & 0 deletions tcet-welcome/scripts/resolution.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/bash

case $XDG_CURRENT_DESKTOP in "GNOME") bash -c 'gnome-control-center display';;
"XFCE") bash -c 'xfce4-display-settings';;
*) yad --image="dialog-question" --title "Alert" --text "Can't recongnize desktop environment" --button="yad-ok:0";;
esac
8 changes: 7 additions & 1 deletion tcet-welcome/scripts/update.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/env bash
TERM=""

xfce4-terminal -e "pkexec pacman --noconfirm -Syyu"
case $XDG_CURRENT_DESKTOP in "GNOME") TERM=kgx;;
"XFCE") TERM=xfce4-terminal;;
*) yad --image="dialog-question" --title "Alert" --text "Can't recongnize desktop environment" --button="yad-ok:0";;
esac

$TERM -e "pkexec pacman --noconfirm -Syyu"

12 changes: 10 additions & 2 deletions welcome
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@

DIR=/usr/local/share/tcet-welcome

TERM=""

case $XDG_CURRENT_DESKTOP in "GNOME") TERM=kgx;;
"XFCE") TERM=xfce4-terminal;;
*) yad --image="dialog-question" --title "Alert" --text "Can't recongnize desktop environment" --button="yad-ok:0";;
esac

yad --title "Welcome" \
--form \
--window-icon=$DIR/assets/tcetlinux-logo.png \
--columns=2\
--rows=5 \
--width=640 \
--height=380 \
--fixed \
--no-escape \
--image=$DIR/assets/Tcet_Linux.png \
--field="<b>Install TCET Linux</b>":fbtn "bash -c 'sudo -E calamares -D 8'" \
--field="<b>Update PC</b>":fbtn "bash -c '$DIR/scripts/update.sh'" \
--field="<b>Fix Screen Resolution</b>":fbtn "bash -c 'xfce4-display-settings'" \
--field="<b>Fix Screen Resolution</b>":fbtn "bash -c '$DIR/scripts/resolution.sh'" \
--field="<b>Arch User Repository (AUR)</b>":fbtn "bash -c '$DIR/scripts/aur.sh'" \
--field="<b>Join our discord Server</b>":fbtn "bash -c '$DIR/scripts/discord.sh'" \
--field="<b>Application Installer (BETA)</b>":fbtn "bash -c '$DIR/scripts/py-installer.sh'" \
--field="<b>Update Mirrors</b>":fbtn "xfce4-terminal -x '$DIR/scripts/mirror.sh'" \
--field="<b>Update Mirrors</b>":fbtn "$TERM -e '$DIR/scripts/mirror.sh'" \
--field="<b>Arch Wiki</b>":fbtn "bash -c '$DIR/scripts/archwiki.sh'" \
--field="<b>Contribute to TCET Linux</b>":fbtn "bash -c '$DIR/scripts/github.sh'" \
--field="<b>About US</b>":fbtn "bash -c '$DIR/scripts/py-about.sh'" \
Expand Down
14 changes: 11 additions & 3 deletions welcome-after
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@

DIR=/usr/local/share/tcet-welcome

TERM=""

case $XDG_CURRENT_DESKTOP in "GNOME") TERM=kgx;;
"XFCE") TERM=xfce4-terminal;;
*) yad --image="dialog-question" --title "Alert" --text "Can't recongnize desktop environment" --button="yad-ok:0";;
esac

yad --title "Welcome" \
--form \
--window-icon=$DIR/assets/tcetlinux-logo.png \
--columns=2\
--rows=5 \
--width=640 \
--height=380 \
--fixed \
--no-escape \
--image=$DIR/assets/Tcet_Linux.png \
--field="<b>Update PC</b>":fbtn "bash -c '$DIR/scripts/update.sh'" \
--field="<b>Fix Screen Resolution</b>":fbtn "bash -c 'xfce4-display-settings'" \
--field="<b>Fix Screen Resolution</b>":fbtn "bash -c '$DIR/scripts/resolution.sh'" \
--field="<b>Arch User Repository (AUR)</b>":fbtn "bash -c '$DIR/scripts/aur.sh'" \
--field="<b>Join our discord Server</b>":fbtn "bash -c '$DIR/scripts/discord.sh'" \
--field="<b>Toggle Autostart</b>":fbtn " xfce4-terminal -x '$DIR/scripts/autostart.sh'"\
--field="<b>Update Mirrors</b>":fbtn "xfce4-terminal -x '$DIR/scripts/mirror.sh'" \
--field="<b>Toggle Autostart</b>":fbtn "$TERM -e '$DIR/scripts/autostart.sh'"\
--field="<b>Update Mirrors</b>":fbtn "$TERM -e '$DIR/scripts/mirror.sh'" \
--field="<b>Application Installer (BETA)</b>":fbtn "bash -c '$DIR/scripts/py-installer.sh'" \
--field="<b>Arch Wiki</b>":fbtn "bash -c '$DIR/scripts/archwiki.sh'" \
--field="<b>Contribute to TCET Linux</b>":fbtn "bash -c '$DIR/scripts/github.sh'" \
Expand Down

0 comments on commit 0274e66

Please sign in to comment.