GrubHack grub2 boot screen config

Post Reply
User avatar
BruceSteers
Posts: 149
Joined: Thursday 23rd July 2020 5:20pm

GrubHack grub2 boot screen config

Post by BruceSteers » Thursday 17th September 2020 9:35pm

GrubHack by Bruce Steers

This is a simple app i made because i like to experiment with
operating systems and am often effecting my grub2 menu and wishing
to edit it easily, or change the default boot disk etc.

It reads the /boot/grub/grub.cfg file and lists all the menu entries

it allows you to re-order the items
delete entries
edit menu text
change menu timeout
set default menu entry

it also has options for...
running update-grub to do an OS probe and rebuild a new grub.cfg file
running grub-install to install the grub2 bootloader to a chosen disk
running "fdisk -l" to list all disk drives (i plan to make this an internal function)

It can also modify some things in the /etc/default/grub file
Set default resolution for the grub boot screen
Set the background image.
If chosen background image does not show on boot it's likely an incompatible format.
So theres a 'Convert' option that will convert it to a 1024x768 .png image and
save it in /usr/share/backgrounds/Edits/ (this has so far worked on every image i've
tried it with that initially would not show)

Note. MUST be run from a terminal/shell as root initially to configure pkexec if you have not
configured pkexec yourself to allow the Gambas runtime 'gbr3', after that you can
create menu items / launchers or just double click the application file, but not before.

Usage:
At launch it reads the grub configuration file and lists the menu items, finds the default and
the timeout.
Menu entries can be deleted, moved up or down and the default can be set. As can the Timeout.
Operation/buttons are self explainitory.


TO SAVE CHANGES YOU MUST RUN THIS PROGRAM AS ROOT

Disclaimer..
This program works fine as is and has for me for 9 years when it was only a Gambas2 app
but if the grub configuration format has a major change it may stop functioning as
expected and could cause boot faliure.
In the 9 years I've been using it the only format change i had to deal with was the Timeout time
setting moved somewhere else and the one i was setting didn't change it anymore. no big problem
and was soon resolved.
GrubHack-qt.zip
(83.02 KiB) Downloaded 10 times
updated , changed from gtk to qt to stop layout errors
Attachments
GrubHack.png
GrubHack.png (50.47 KiB) Viewed 427 times
Last edited by BruceSteers on Friday 18th September 2020 1:07am, edited 1 time in total.
If at first you don't succeed , try it differently.

PJBlack
Posts: 29
Joined: Tuesday 09th June 2020 10:26pm

Re: GrubHack grub2 boot screen config

Post by PJBlack » Thursday 17th September 2020 11:19pm

really nice that one ... but so much buggy ...

$ sudo gbr3 GrubHack.gambas
[sudo] Passwort für **********:

(GrubHack.gambas:4500): Pango-WARNING **: 01:16:28.365: pango_layout_set_markup_with_accel: Fehler in Zeile 2, Zeichen 29: Element »markup« wurde geschlossen, aber das derzeit offene Element ist »i«

(GrubHack.gambas:4500): Pango-WARNING **: 01:16:28.498: pango_layout_set_markup_with_accel: Fehler in Zeile 2, Zeichen 29: Element »markup« wurde geschlossen, aber das derzeit offene Element ist »i«

(GrubHack.gambas:4500): Pango-WARNING **: 01:17:01.709: pango_layout_set_markup_with_accel: Fehler in Zeile 2, Zeichen 29: Element »markup« wurde geschlossen, aber das derzeit offene Element ist »i«
FMain.?.0: #13: Null object
FMain.?.0 FMain.?.0
FMain.?.0: #13: Null object
FMain.?.0 FMain.?.0

User avatar
BruceSteers
Posts: 149
Joined: Thursday 23rd July 2020 5:20pm

Re: GrubHack grub2 boot screen config

Post by BruceSteers » Friday 18th September 2020 12:47am

PJBlack wrote:
Thursday 17th September 2020 11:19pm
really nice that one ... but so much buggy ...
aah those gtk layout errors eh.
The Pango errors are gtk bugs more than my app and out of my hands.
Here's a qt version that doesn't do that.

As for the other FMain erorrs i'm not sure, i could not produce them as you did,
it had compatibility set for gambas 3.8 so i've removed it, it's compiled on 3.12 so will work on 3.12+
Attachments
GrubHack-qt.zip
(83.02 KiB) Downloaded 19 times
Last edited by BruceSteers on Friday 18th September 2020 1:16am, edited 1 time in total.
If at first you don't succeed , try it differently.

User avatar
BruceSteers
Posts: 149
Joined: Thursday 23rd July 2020 5:20pm

Re: GrubHack grub2 boot screen config

Post by BruceSteers » Friday 18th September 2020 1:13am

only error i'm getting now is this..

bonus@bonus-pc:~$ sudo /media/bonus/Elements/LinuxStuff/GrubHack/GrubHack.gambas
[sudo] password for bonus:
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
bonus@bonus-pc:~$

I think thats my linux config though not the app
If at first you don't succeed , try it differently.

PJBlack
Posts: 29
Joined: Tuesday 09th June 2020 10:26pm

Re: GrubHack grub2 boot screen config

Post by PJBlack » Friday 18th September 2020 2:27am

ok ... i'm also getting this

$ sudo gbr3 GrubHack.gambas
[sudo] Passwort für ***:
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root
'

but i'm also getting this
GrubHack Error.png
GrubHack Error.png (12.8 KiB) Viewed 417 times
and after OK getting blank menu entries
GrubHack Error 2.png
GrubHack Error 2.png (26.34 KiB) Viewed 417 times
and ... trying to convert a background png gets me this

libpng warning: keyword "EPSON Standard RGB - Gamma 1.8": bad character '0x20'

User avatar
BruceSteers
Posts: 149
Joined: Thursday 23rd July 2020 5:20pm

Re: GrubHack grub2 boot screen config

Post by BruceSteers » Friday 18th September 2020 4:08pm

Right.. lol

Firstly thank you for the bug reports , please don't let my "Grrrr ffs!!" attitude seemed aimed at you in any way, that's just me venting lol.

I've gone back to gtk as the layout looked better than with qt.
Have got rid of the Pango error messages (buggyness) from gtk. How?
I loaded up my other linux and compiled the App on Gambas 3.15 :-\ that's all it took. compiling on a newer gambas, no code/layout changes but the warning messages have now gone. (so i'm blaming those bugs on Gambas ;) )

The error you were getting on load seemed to be i was giving an Integer a string value, but for some strange reason errors on your machine but on mine worked okay :-\ Well i added a Val() command to properly set the Integer. Hopefully should fix.
(Blame that one on me ;) )

As for the converting error, again not sure what that's about as the routine failing is taking the image from a PictureBox control and using the Image.Save(path) , The error you were getting 0x20 sounds like it's complaining about the Spaces in the filename. A file path shouldn't need quoting when used that way) i just tried using Quote(path) and it didn't like it. Maybe it will work better now i've compiled with 3.15?

I have just tested the convert command on a file with spaces in the name with no problems.

Question..
Have you hand-customised your grub.conf file in any way?
This could possibly cause an issue
Many thanks :)
Bruce
Attachments
GrubHack.zip
Updated (compiled on 3.15)
(83.24 KiB) Downloaded 14 times
If at first you don't succeed , try it differently.

User avatar
BruceSteers
Posts: 149
Joined: Thursday 23rd July 2020 5:20pm

Re: GrubHack grub2 boot screen config

Post by BruceSteers » Sunday 20th September 2020 10:18am

I've made a big layout change to this.
I've removed the ScrollView on the 2nd TabStip and put the image stuff on a different tab.
Now it doesn't give any layout warnings even if compiled on 3.12.

I also added my MakeIcon module to it and gave it a make desktop icon or menu item buttons (on the About page)

Curious to know if you got it to work PJBlack ?
If not i'd be curious to know why. maybe send me your grub.conf file?
Attachments
GrubHack.zip
(83.71 KiB) Downloaded 14 times
If at first you don't succeed , try it differently.

Post Reply