chore(users): fixed all the possible bugs and enhanced ui.

This commit is contained in:
Eshan Roy (Eshanized)
2024-05-01 17:36:10 +05:30
parent 1fd824db60
commit bcad1cc806
4 changed files with 72 additions and 70 deletions

View File

@@ -70,7 +70,7 @@ void SnigdhaOSAssistant::doInternetUpRequest(){
void SnigdhaOSAssistant::doUpdate(){ void SnigdhaOSAssistant::doUpdate(){
if (qEnvironmentVariableIsSet("SETUP_ASSISTANT_SELFUPDATE")) { if (qEnvironmentVariableIsSet("SNIGDHAOS_ASSISTANT_SELFUPDATE")) {
updateState(State::SELECT); updateState(State::SELECT);
return; return;
} }
@@ -78,7 +78,7 @@ void SnigdhaOSAssistant::doUpdate(){
QTemporaryFile* file = new QTemporaryFile(this); QTemporaryFile* file = new QTemporaryFile(this);
file->open(); file->open();
file->setAutoRemove(true); file->setAutoRemove(true);
process->start("/usr/bin/gnome-terminal", QStringList() << QString("sudo pacman -Syyu" + file->fileName() + "\"; read -p 'Press enter to exit'")); process->start("/usr/lib/snigdhaos/launch-terminal", QStringList() << QString("sudo pacman -Syyu 2>&1 && rm \"" + file->fileName() + "\"; read -p 'Press enter to exit'"));
connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this, process, file](int exitcode, QProcess::ExitStatus status) { connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this, process, file](int exitcode, QProcess::ExitStatus status) {
process->deleteLater(); process->deleteLater();
file->deleteLater(); file->deleteLater();
@@ -140,7 +140,7 @@ void SnigdhaOSAssistant::doApply(){
setupFile->close(); setupFile->close();
auto process = new QProcess(this); auto process = new QProcess(this);
process->start("/usr/bin/gnome-terminal", QStringList() << QString("/usr/lib/snigdhaos-assistant/apply.sh \"") + prepareFile->fileName() + "\" \"" + packagesFile->fileName() + "\" \"" + setupFile->fileName() + "\""); process->start("/usr/lib/snigdhaos/launch-terminal", QStringList() << QString("/usr/lib/snigdhaos-assistant/apply.sh \"") + prepareFile->fileName() + "\" \"" + packagesFile->fileName() + "\" \"" + setupFile->fileName() + "\"");
connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this, process, prepareFile, packagesFile, setupFile](int exitcode, QProcess::ExitStatus status) { connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this, process, prepareFile, packagesFile, setupFile](int exitcode, QProcess::ExitStatus status) {
process->deleteLater(); process->deleteLater();
prepareFile->deleteLater(); prepareFile->deleteLater();
@@ -148,44 +148,44 @@ void SnigdhaOSAssistant::doApply(){
setupFile->deleteLater(); setupFile->deleteLater();
if (exitcode == 0 && !packagesFile->exists()) { if (exitcode == 0 && !packagesFile->exists()) {
updateState(State::SUCCESS); updateState(State::SELECT);
} else { } else {
updateState(State::APPLY_RETRY); updateState(State::APPLY_RETRY);
} }
}); });
} }
void SnigdhaOSAssistant::doNvidiaCheck(){ // void SnigdhaOSAssistant::doNvidiaCheck(){
auto process = new QProcess(this); // auto process = new QProcess(this);
process->start("mhwd", QStringList() << "-li" // process->start("mhwd", QStringList() << "-li"
<< "--pci"); // << "--pci");
connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this, process](int exitcode, QProcess::ExitStatus status) { // connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this, process](int exitcode, QProcess::ExitStatus status) {
process->deleteLater(); // process->deleteLater();
if (exitcode == 0 && !QString(process->readAllStandardOutput()).contains("nvidia")) { // if (exitcode == 0 && !QString(process->readAllStandardOutput()).contains("nvidia")) {
auto process2 = new QProcess(this); // auto process2 = new QProcess(this);
process2->start("mhwd", QStringList() << "-l" // process2->start("mhwd", QStringList() << "-l"
<< "--pci"); // << "--pci");
connect(process2, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this, process2](int exitcode, QProcess::ExitStatus status) { // connect(process2, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this, process2](int exitcode, QProcess::ExitStatus status) {
process2->deleteLater(); // process2->deleteLater();
if (exitcode == 0 && QString(process2->readAllStandardOutput()).contains("nvidia")) // if (exitcode == 0 && QString(process2->readAllStandardOutput()).contains("nvidia"))
updateState(State::NVIDIA); // updateState(State::NVIDIA);
else // else
updateState(State::SELECT); // updateState(State::SELECT);
}); // });
} else { // } else {
updateState(State::SELECT); // updateState(State::SELECT);
} // }
}); // });
} // }
void SnigdhaOSAssistant::doNvidiaApply(){ // void SnigdhaOSAssistant::doNvidiaApply(){
auto process = new QProcess(this); // auto process = new QProcess(this);
process->start("/usr/bin/gnome-terminal", QStringList() << "sudo mhwd -a pci nonfree 0300; echo; read -p 'Press enter to exit'"); // process->start("/usr/lib/snigdhaos/launch-terminal", QStringList() << "sudo mhwd -a pci nonfree 0300; echo; read -p 'Press enter to exit'");
connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this, process](int exitcode, QProcess::ExitStatus status) { // connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this, process](int exitcode, QProcess::ExitStatus status) {
process->deleteLater(); // process->deleteLater();
updateState(State::SELECT); // updateState(State::SELECT);
}); // });
} // }
void SnigdhaOSAssistant::populateSelectWidget(){ void SnigdhaOSAssistant::populateSelectWidget(){
if (ui->selectWidget_tabs->count() > 1) if (ui->selectWidget_tabs->count() > 1)
@@ -280,21 +280,21 @@ void SnigdhaOSAssistant::updateState(State state){
ui->textStackedWidget->setCurrentWidget(ui->textWidget_updateRetry); ui->textStackedWidget->setCurrentWidget(ui->textWidget_updateRetry);
ui->textWidget_buttonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No); ui->textWidget_buttonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No);
break; break;
case State::NVIDIA_CHECK: // case State::NVIDIA_CHECK:
ui->mainStackedWidget->setCurrentWidget(ui->waitingWidget); // ui->mainStackedWidget->setCurrentWidget(ui->waitingWidget);
ui->waitingWidget_text->setText("Checking for NVIDIA drivers..."); // ui->waitingWidget_text->setText("Checking for NVIDIA drivers...");
doNvidiaCheck(); // doNvidiaCheck();
break; // break;
case State::NVIDIA: // case State::NVIDIA:
ui->mainStackedWidget->setCurrentWidget(ui->textWidget); // ui->mainStackedWidget->setCurrentWidget(ui->textWidget);
ui->textStackedWidget->setCurrentWidget(ui->textWidget_nvidia); // ui->textStackedWidget->setCurrentWidget(ui->textWidget_nvidia);
ui->textWidget_buttonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No); // ui->textWidget_buttonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No);
break; // break;
case State::NVIDIA_APPLY: // case State::NVIDIA_APPLY:
ui->mainStackedWidget->setCurrentWidget(ui->waitingWidget); // ui->mainStackedWidget->setCurrentWidget(ui->waitingWidget);
ui->waitingWidget_text->setText("Installing NVIDIA drivers..."); // ui->waitingWidget_text->setText("Installing NVIDIA drivers...");
doNvidiaApply(); // doNvidiaApply();
break; // break;
case State::QUIT: case State::QUIT:
ui->mainStackedWidget->setCurrentWidget(ui->textWidget); ui->mainStackedWidget->setCurrentWidget(ui->textWidget);
ui->textStackedWidget->setCurrentWidget(ui->textWidget_quit); ui->textStackedWidget->setCurrentWidget(ui->textWidget_quit);
@@ -325,7 +325,7 @@ void SnigdhaOSAssistant::updateState(State state){
void SnigdhaOSAssistant::updateState(QString state){ void SnigdhaOSAssistant::updateState(QString state){
if (state == "POST_UPDATE") if (state == "POST_UPDATE")
updateState(State::NVIDIA_CHECK); updateState(State::SELECT);
else if (state == "UPDATE_RETRY") else if (state == "UPDATE_RETRY")
updateState(State::UPDATE_RETRY); updateState(State::UPDATE_RETRY);
else else
@@ -354,12 +354,12 @@ void SnigdhaOSAssistant::on_textWidget_buttonBox_clicked(QAbstractButton* button
updateState(State::INTERNET); updateState(State::INTERNET);
} }
break; break;
case State::NVIDIA: // case State::NVIDIA:
if (ui->textWidget_buttonBox->standardButton(button) == QDialogButtonBox::Yes) // if (ui->textWidget_buttonBox->standardButton(button) == QDialogButtonBox::Yes)
updateState(State::NVIDIA_APPLY); // updateState(State::NVIDIA_APPLY);
else // else
updateState(State::SELECT); // updateState(State::SELECT);
return; // return;
case State::APPLY_RETRY: case State::APPLY_RETRY:
if (ui->textWidget_buttonBox->standardButton(button) == QDialogButtonBox::Yes) { if (ui->textWidget_buttonBox->standardButton(button) == QDialogButtonBox::Yes) {
updateState(State::APPLY); updateState(State::APPLY);

View File

@@ -28,9 +28,9 @@ public:
INTERNET, INTERNET,
UPDATE, UPDATE,
UPDATE_RETRY, UPDATE_RETRY,
NVIDIA_CHECK, // NVIDIA_CHECK,
NVIDIA, // NVIDIA,
NVIDIA_APPLY, // NVIDIA_APPLY,
SELECT, SELECT,
APPLY, APPLY,
APPLY_RETRY, APPLY_RETRY,
@@ -52,8 +52,8 @@ private:
void doInternetUpRequest(); void doInternetUpRequest();
void doUpdate(); void doUpdate();
void doApply(); void doApply();
void doNvidiaCheck(); // void doNvidiaCheck();
void doNvidiaApply(); // void doNvidiaApply();
void populateSelectWidget(); void populateSelectWidget();
void populateSelectWidget(QString filename, QString label); void populateSelectWidget(QString filename, QString label);
void updateState(State state); void updateState(State state);

View File

@@ -18,7 +18,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QStackedWidget" name="mainStackedWidget"> <widget class="QStackedWidget" name="mainStackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="textWidget"> <widget class="QWidget" name="textWidget">
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
@@ -30,12 +30,15 @@
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set> <set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property> </property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QStackedWidget" name="textStackedWidget"> <widget class="QStackedWidget" name="textStackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>4</number> <number>3</number>
</property> </property>
<widget class="QWidget" name="textWidget_welcome"> <widget class="QWidget" name="textWidget_welcome">
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
@@ -48,7 +51,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:24pt;&quot;&gt;Welcome to Snigdha OS!&lt;/span&gt;&lt;br/&gt;This interactive assistant will help you set up your system to your wishes.&lt;/p&gt;&lt;p&gt;Before the setup assistant can continue, initial system updates have to be applied and the Snigdha OS Assistant updated.&lt;br/&gt;Make sure you have a working internet connection before you continue.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:24pt;&quot;&gt;Welcome to &lt;b&gt;Snigdha OS!&lt;/b&gt;😊&lt;/span&gt;&lt;br/&gt;&lt;b&gt;Snigdha OS Assistant&lt;/b&gt; will help you set up your system to your wishes.&lt;/p&gt;&lt;p&gt;Before the Snigdha OS Assistant can continue, initial system updates have to be applied and the Snigdha OS Assistant is updated.&lt;br/&gt;Make sure you have a working internet connection before you continue.&lt;/p&gt;&lt;/br&gt;This application is inspired from &lt;b&gt;Garuda Linux&lt;/b&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="textFormat"> <property name="textFormat">
<enum>Qt::TextFormat::RichText</enum> <enum>Qt::TextFormat::RichText</enum>
@@ -77,7 +80,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Update failed!&lt;/span&gt;&lt;br/&gt;System update failed. Try again?&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://forum.snigdhaos.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Visit the Snigdha OS Forum&lt;/span&gt;&lt;/a&gt; if further issues occour.&lt;br/&gt;Finishing this update via the Snigdha OS Assistant is highly recommended in order to apply release-specific fixes.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Update failed!😒&lt;/span&gt;&lt;br/&gt;System update failed. Try again?😬&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://forum.snigdhaos.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Visit the Snigdha OS Forum&lt;/span&gt;&lt;/a&gt; if further issues occour.&lt;br/&gt;Finishing this update via the Snigdha OS Assistant is highly recommended in order to apply release-specific fixes.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="textFormat"> <property name="textFormat">
<enum>Qt::TextFormat::RichText</enum> <enum>Qt::TextFormat::RichText</enum>
@@ -173,7 +176,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Success!&lt;/span&gt;&lt;br/&gt;Your system is set up and ready to go!&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://forum.snigdhais.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Visit the Snigdha OS Forum&lt;/span&gt;&lt;/a&gt; if issues occour.&lt;br/&gt;&lt;a href=&quot;https://snigdhaos.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Snigdha OS Documentation&lt;br/&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href=&quot;https://wiki.archlinux.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Arch Linux Wiki&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Success!😎&lt;/span&gt;&lt;br/&gt;Your system is set up and ready to go!&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://forum.snigdhais.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Visit the Snigdha OS Forum&lt;/span&gt;&lt;/a&gt; if issues occour.&lt;br/&gt;&lt;a href=&quot;https://snigdhaos.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Snigdha OS Documentation&lt;br/&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href=&quot;https://wiki.archlinux.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Arch Linux Wiki&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="textFormat"> <property name="textFormat">
<enum>Qt::TextFormat::RichText</enum> <enum>Qt::TextFormat::RichText</enum>
@@ -205,7 +208,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Before you go&lt;/span&gt;&lt;/p&gt;&lt;p&gt;You can restart the setup assistant at any time.&lt;br/&gt;Finishing the Snigdha OS Assistant is recommended in order to apply release-specific fixes.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://forum.snigdhaos.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Visit the Snigdha OS Forum&lt;/span&gt;&lt;/a&gt; if issues occour.&lt;br/&gt;&lt;a href=&quot;https://snigdhaos.org/documentation/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Snigdha OS Documentation&lt;br/&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href=&quot;https://wiki.archlinux.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Arch Linux Wiki&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Before you go🧸&lt;/span&gt;&lt;/p&gt;&lt;p&gt;You can restart the Snigdha OS Assistant at any time.&lt;br/&gt;Finishing the Snigdha OS Assistant is recommended in order to apply release-specific fixes.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://forum.snigdhaos.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Visit the Snigdha OS Forum&lt;/span&gt;&lt;/a&gt; if issues occour.&lt;br/&gt;&lt;a href=&quot;https://snigdhaos.org/documentation/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Snigdha OS Documentation&lt;br/&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href=&quot;https://wiki.archlinux.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#754ffe;&quot;&gt;Arch Linux Wiki&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="textFormat"> <property name="textFormat">
<enum>Qt::TextFormat::RichText</enum> <enum>Qt::TextFormat::RichText</enum>
@@ -321,7 +324,6 @@
</property> </property>
<property name="packages" stdset="0"> <property name="packages" stdset="0">
<stringlist notr="true"> <stringlist notr="true">
<string>garuda-blackarch</string>
<string>blackarch-keyring</string> <string>blackarch-keyring</string>
<string>blackarch-menus</string> <string>blackarch-menus</string>
<string>blackarch-mirrorlist</string> <string>blackarch-mirrorlist</string>

View File

@@ -9,7 +9,7 @@ echo ""
echo "Installing packages.." echo "Installing packages.."
echo "" echo ""
installable_packages=$(comm -12 <(pacman -Slq | sort) <(sed s/\\s/\\n/g - <$2 | sort)) installable_packages=$(comm -12 <(pacman -Slq | sort) <(sed s/\\s/\\n/g - <$2 | sort))
sudo pacman -S --needed $installable_packages && rm $2 || { read -p "Error! Press enter to return to setup assistant."; exit; } sudo pacman -S --needed $installable_packages && rm $2 || { read -p "Error! Press enter to return to Snigdha OS Assistant."; exit; }
if [ -e "$3" ]; then if [ -e "$3" ]; then
echo "" echo ""
@@ -19,4 +19,4 @@ if [ -e "$3" ]; then
fi fi
echo "" echo ""
read -p "Press enter to return to setup assistant." read -p "Press enter to return to Snigdha OS Assistant."