From 1b3800804eb7de33b477fe9e2610b9550e6e564f Mon Sep 17 00:00:00 2001 From: mendhak Date: Sat, 3 Aug 2024 10:19:41 +0100 Subject: [PATCH 01/12] Don't add submenu items if non exist --- src/grub-reboot-picker.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/grub-reboot-picker.py b/src/grub-reboot-picker.py index 69a62b7..22edae6 100755 --- a/src/grub-reboot-picker.py +++ b/src/grub-reboot-picker.py @@ -7,8 +7,11 @@ from gi.repository import Gtk, AppIndicator3 -SHOW_GRUB_MENU_SUB_MENUS = True -DEVELOPMENT_MODE = False +SHOW_GRUB_MENU_SUB_MENUS = False +DEVELOPMENT_MODE = True +GRUB_CONFIG_PATH = "/boot/grub/grub.cfg" +if DEVELOPMENT_MODE: + GRUB_CONFIG_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "grub.cfg") icon_name = "un-reboot" @@ -35,7 +38,7 @@ def get_grub_entries(): grub_entries.clear() grub_entries['menuitems'] = [] - for i, line in enumerate(open('/boot/grub/grub.cfg')): + for i, line in enumerate(open(GRUB_CONFIG_PATH)): for match in re.finditer(pattern, line): grub_entry = {} grub_entry['name'] = match.group(1) @@ -89,7 +92,7 @@ def get_grub_entries_with_submenus(): current_submenu = None submenu_entry_match = None - for i, line in enumerate(open('/boot/grub/grub.cfg')): + for i, line in enumerate(open(GRUB_CONFIG_PATH)): menu_entry_match = re.match(menu_pattern, line) if menu_entry_match: grub_entry = {} @@ -130,14 +133,15 @@ def build_menu(): menuitem = Gtk.MenuItem(label=grub_entry['name']) if len(grub_entry.get('submenuitems', [])) == 0: menuitem.connect('activate', do_grub_reboot, grub_entry) - submenu = Gtk.Menu() - for grub_entry_submenuitem in grub_entry.get('submenuitems', []): - # print(grub_entry_submenuitem) - submenu_item = Gtk.MenuItem(label=grub_entry_submenuitem['name']) - submenu_item.connect('activate', do_grub_reboot, grub_entry_submenuitem, - grub_entry) - submenu.append(submenu_item) - menuitem.set_submenu(submenu) + else: + submenu = Gtk.Menu() + for grub_entry_submenuitem in grub_entry.get('submenuitems', []): + # print(grub_entry_submenuitem) + submenu_item = Gtk.MenuItem(label=grub_entry_submenuitem['name']) + submenu_item.connect('activate', do_grub_reboot, grub_entry_submenuitem, + grub_entry) + submenu.append(submenu_item) + menuitem.set_submenu(submenu) menu.append(menuitem) From b5877cbaa0aaba05fda020d57f829aa6490ccc5b Mon Sep 17 00:00:00 2001 From: mendhak Date: Sat, 3 Aug 2024 11:17:25 +0100 Subject: [PATCH 02/12] Allow menu entries with double quotes instead of single only --- src/grub-reboot-picker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/grub-reboot-picker.py b/src/grub-reboot-picker.py index 22edae6..004fd54 100755 --- a/src/grub-reboot-picker.py +++ b/src/grub-reboot-picker.py @@ -7,7 +7,7 @@ from gi.repository import Gtk, AppIndicator3 -SHOW_GRUB_MENU_SUB_MENUS = False +SHOW_GRUB_MENU_SUB_MENUS = True DEVELOPMENT_MODE = True GRUB_CONFIG_PATH = "/boot/grub/grub.cfg" if DEVELOPMENT_MODE: @@ -81,7 +81,7 @@ def get_grub_entries_with_submenus(): } """ - menu_pattern = re.compile("^menuentry '([^']*)'") + menu_pattern = re.compile("^menuentry ['\"]([^'\"]*)['\"]") submenu_pattern = re.compile("^submenu '([^']*)'") submenu_entry_pattern = re.compile("^\\s+menuentry '([^']*)'") From c12582bb5f06fdac8e10bb5288d0ec2e5ea86cc8 Mon Sep 17 00:00:00 2001 From: mendhak Date: Sat, 3 Aug 2024 12:17:47 +0100 Subject: [PATCH 03/12] Single and double quote checking for top level menu items only --- src/grub-reboot-picker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grub-reboot-picker.py b/src/grub-reboot-picker.py index 004fd54..aeadc2a 100755 --- a/src/grub-reboot-picker.py +++ b/src/grub-reboot-picker.py @@ -33,7 +33,7 @@ def get_grub_entries(): ] } """ - pattern = re.compile("^menuentry '([^']*)'") + pattern = re.compile("^menuentry ['\"]([^'\"]*)['\"]") grub_entries = {} grub_entries.clear() grub_entries['menuitems'] = [] From 8a67dc85156c48e9e4a296ca4c3b41b641cc4365 Mon Sep 17 00:00:00 2001 From: mendhak Date: Sat, 3 Aug 2024 15:26:35 +0100 Subject: [PATCH 04/12] New method to parse grub cfg to get entries cleanly --- .gitignore | 4 +- src/grub-reboot-picker.py | 90 ++++++++++++++++++++++++++++++++------- 2 files changed, 78 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 2de72a6..a46df68 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ __pycache__ deb_dist *.tar.gz *.egg-info -tmp \ No newline at end of file +tmp + +grub*.cfg \ No newline at end of file diff --git a/src/grub-reboot-picker.py b/src/grub-reboot-picker.py index aeadc2a..2f59e74 100755 --- a/src/grub-reboot-picker.py +++ b/src/grub-reboot-picker.py @@ -8,13 +8,66 @@ SHOW_GRUB_MENU_SUB_MENUS = True -DEVELOPMENT_MODE = True +DEVELOPMENT_MODE = False GRUB_CONFIG_PATH = "/boot/grub/grub.cfg" if DEVELOPMENT_MODE: - GRUB_CONFIG_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "grub.cfg") + GRUB_CONFIG_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "grub.test3.cfg") icon_name = "un-reboot" +def get_all_grub_entries(file_path): + """ + Build a dictionary of Grub menu items with sub menu items if applicable. + Simply if it has child items it's a 'submenu' else it's just a top level menu. + { + 'Ubuntu': [], + 'Advanced options for Ubuntu': [ + 'Ubuntu, with Linux 6.8.0-39-generic', + 'Ubuntu, with Linux 6.8.0-39-generic (recovery mode)' + ], + 'Memory test (memtest86+x64.bin)': [], + 'Memory test (memtest86+x64.bin, serial console)': [], + 'UEFI Firmware Settings': [] + } + """ + with open(file_path, 'r') as file: + lines = file.readlines() + + menu_pattern = re.compile("^\\s*menuentry ['\"]([^'\"]*)['\"]") + submenu_pattern = re.compile("^\\s*submenu ['\"]([^']*)['\"]") + closing_brace_pattern = re.compile("^\\s*}") + + menu_entries = {} + + processing_submenu=False + submenu_item_added=False + + for line in lines: + submenu_match = submenu_pattern.match(line) + menu_match = menu_pattern.match(line) + closing_brace_match = closing_brace_pattern.match(line) + + if submenu_match: + submenu_title = submenu_match.group(1) + menu_entries[submenu_title] = [] + processing_submenu = True + elif menu_match: + menu_title = menu_match.group(1) + if processing_submenu: + menu_entries[submenu_title].append(menu_title) + submenu_item_added = True + else: + menu_entries[menu_title] = [] + elif closing_brace_match: + # submenu_item_added would match for the first nested closing brace, + # then processing_submenu for the top level closing brace. + if submenu_item_added: + submenu_item_added = False + elif processing_submenu: + processing_submenu = False + + + return menu_entries def get_grub_entries(): """ @@ -81,9 +134,16 @@ def get_grub_entries_with_submenus(): } """ - menu_pattern = re.compile("^menuentry ['\"]([^'\"]*)['\"]") - submenu_pattern = re.compile("^submenu '([^']*)'") + + with open(GRUB_CONFIG_PATH, 'r') as file: + lines = file.readlines() + + + + menu_pattern = re.compile("^\\s*menuentry ['\"]([^'\"]*)['\"]") + submenu_pattern = re.compile("^\\s*submenu '([^']*)'") submenu_entry_pattern = re.compile("^\\s+menuentry '([^']*)'") + # closing_brace_pattern = re.compile("^\s*\}") grub_entries = {} grub_entries.clear() @@ -124,21 +184,21 @@ def build_menu(): menu = Gtk.Menu() if SHOW_GRUB_MENU_SUB_MENUS: - grub_entries = get_grub_entries_with_submenus() + grub_entries = get_all_grub_entries(GRUB_CONFIG_PATH) else: - grub_entries = get_grub_entries() + # grub_entries = get_grub_entries() + grub_entries = get_all_grub_entries(GRUB_CONFIG_PATH) print(grub_entries) - for grub_entry in grub_entries['menuitems']: - menuitem = Gtk.MenuItem(label=grub_entry['name']) - if len(grub_entry.get('submenuitems', [])) == 0: + for grub_entry, grub_children in grub_entries.items(): + menuitem = Gtk.MenuItem(label=grub_entry) + if len(grub_children) == 0: menuitem.connect('activate', do_grub_reboot, grub_entry) else: submenu = Gtk.Menu() - for grub_entry_submenuitem in grub_entry.get('submenuitems', []): - # print(grub_entry_submenuitem) - submenu_item = Gtk.MenuItem(label=grub_entry_submenuitem['name']) - submenu_item.connect('activate', do_grub_reboot, grub_entry_submenuitem, + for grub_child in grub_children: + submenu_item = Gtk.MenuItem(label=grub_child) + submenu_item.connect('activate', do_grub_reboot, grub_child, grub_entry) submenu.append(submenu_item) menuitem.set_submenu(submenu) @@ -159,9 +219,9 @@ def build_menu(): def do_grub_reboot(menuitem, grub_entry, parent_grub_entry=None): if parent_grub_entry is not None: - grub_reboot_value = "{}>{}".format(parent_grub_entry['name'], grub_entry['name']) + grub_reboot_value = "{}>{}".format(parent_grub_entry, grub_entry) else: - grub_reboot_value = "{}".format(grub_entry['name']) + grub_reboot_value = "{}".format(grub_entry) if DEVELOPMENT_MODE: print("pkexec grub-reboot '{}' && sleep 1 && pkexec reboot".format(grub_reboot_value)) From ca97c3b2632f86e785aef6d6e025d859c31e4bc3 Mon Sep 17 00:00:00 2001 From: mendhak Date: Sat, 3 Aug 2024 15:41:37 +0100 Subject: [PATCH 05/12] Option to not include submenu items --- src/grub-reboot-picker.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/grub-reboot-picker.py b/src/grub-reboot-picker.py index 2f59e74..c5e4095 100755 --- a/src/grub-reboot-picker.py +++ b/src/grub-reboot-picker.py @@ -15,7 +15,7 @@ icon_name = "un-reboot" -def get_all_grub_entries(file_path): +def get_all_grub_entries(file_path, include_submenus=True): """ Build a dictionary of Grub menu items with sub menu items if applicable. Simply if it has child items it's a 'submenu' else it's just a top level menu. @@ -66,7 +66,11 @@ def get_all_grub_entries(file_path): elif processing_submenu: processing_submenu = False - + if not include_submenus: + for k, v in list(menu_entries.items()): + if len(v) > 0: + del menu_entries[k] + return menu_entries def get_grub_entries(): @@ -183,11 +187,8 @@ def get_grub_entries_with_submenus(): def build_menu(): menu = Gtk.Menu() - if SHOW_GRUB_MENU_SUB_MENUS: - grub_entries = get_all_grub_entries(GRUB_CONFIG_PATH) - else: - # grub_entries = get_grub_entries() - grub_entries = get_all_grub_entries(GRUB_CONFIG_PATH) + grub_entries = get_all_grub_entries(GRUB_CONFIG_PATH, SHOW_GRUB_MENU_SUB_MENUS) + print(grub_entries) for grub_entry, grub_children in grub_entries.items(): From d573b532713b5b38b0e01c7f2875dedffc7ae6a6 Mon Sep 17 00:00:00 2001 From: mendhak Date: Sat, 3 Aug 2024 15:45:59 +0100 Subject: [PATCH 06/12] Remove unused code and comments --- src/grub-reboot-picker.py | 153 -------------------------------------- 1 file changed, 153 deletions(-) diff --git a/src/grub-reboot-picker.py b/src/grub-reboot-picker.py index c5e4095..f57b2e5 100755 --- a/src/grub-reboot-picker.py +++ b/src/grub-reboot-picker.py @@ -6,7 +6,6 @@ gi.require_version('AppIndicator3', '0.1') from gi.repository import Gtk, AppIndicator3 - SHOW_GRUB_MENU_SUB_MENUS = True DEVELOPMENT_MODE = False GRUB_CONFIG_PATH = "/boot/grub/grub.cfg" @@ -73,116 +72,6 @@ def get_all_grub_entries(file_path, include_submenus=True): return menu_entries -def get_grub_entries(): - """ - Builds JSON from grub menu entries, just the top level ones, like this: - { - "menuitems": [ - { - "name": "Ubuntu" - }, - { - "name": "Windows Boot Manager (on /dev/nvme0n1p2)" - }, - { - "name": "UEFI Firmware Settings" - } - ] - } - """ - pattern = re.compile("^menuentry ['\"]([^'\"]*)['\"]") - grub_entries = {} - grub_entries.clear() - grub_entries['menuitems'] = [] - - for i, line in enumerate(open(GRUB_CONFIG_PATH)): - for match in re.finditer(pattern, line): - grub_entry = {} - grub_entry['name'] = match.group(1) - grub_entries['menuitems'].append(grub_entry) - # grub_entries.append(match.group(1)) - return grub_entries - - -def get_grub_entries_with_submenus(): - """ - Builds JSON from grub menu entries, with sub menu items like this: - { - "menuitems": [ - { - "name": "Ubuntu", - "submenuitems": [ - { - "name": "Ubuntu, with Linux 5.4.0-31-generic" - }, - { - "name": "Ubuntu, with Linux 5.4.0-31-generic (recovery mode)" - }, - { - "name": "Ubuntu, with Linux 5.4.0-29-generic" - }, - { - "name": "Ubuntu, with Linux 5.4.0-29-generic (recovery mode)" - } - ] - }, - { - "name": "Windows Boot Manager (on /dev/nvme0n1p2)", - "submenuitems": [] - }, - { - "name": "UEFI Firmware Settings", - "submenuitems": [] - } - ] - } - - """ - - with open(GRUB_CONFIG_PATH, 'r') as file: - lines = file.readlines() - - - - menu_pattern = re.compile("^\\s*menuentry ['\"]([^'\"]*)['\"]") - submenu_pattern = re.compile("^\\s*submenu '([^']*)'") - submenu_entry_pattern = re.compile("^\\s+menuentry '([^']*)'") - # closing_brace_pattern = re.compile("^\s*\}") - - grub_entries = {} - grub_entries.clear() - grub_entries['menuitems'] = [] - menu_entry_match = None - current_submenu = None - submenu_entry_match = None - - for i, line in enumerate(open(GRUB_CONFIG_PATH)): - menu_entry_match = re.match(menu_pattern, line) - if menu_entry_match: - grub_entry = {} - grub_entry['name'] = menu_entry_match.group(1) - grub_entries['menuitems'].append(grub_entry) - continue - - submenu_entry_match = re.match(submenu_pattern, line) - if submenu_entry_match: - grub_entry = {} - grub_entry['name'] = submenu_entry_match.group(1) - grub_entries['menuitems'].append(grub_entry) - # print(submenu_entry_match.group(1)) - current_submenu = grub_entry - current_submenu['submenuitems'] = [] - continue - - if current_submenu: - submenu_entry_match = re.match(submenu_entry_pattern, line) - if submenu_entry_match: - # print(submenu_entry_match.group(1)) - grub_entry = {} - grub_entry['name'] = submenu_entry_match.group(1) - current_submenu['submenuitems'].append(grub_entry) - return grub_entries - def build_menu(): menu = Gtk.Menu() @@ -240,38 +129,6 @@ def do_shutdown(_): def quit(_): Gtk.main_quit() -# win = Gtk.Window() -# win.connect("destroy", Gtk.main_quit) -# #win.set_icon_from_file("logo.svg") -# win.set_icon_name(icon_name) -# win.set_position(Gtk.WindowPosition.CENTER_ALWAYS) - -# grid = Gtk.Grid() -# win.add(grid) - -# button = Gtk.Button(label="Message") -# button.connect("clicked", on_button_clicked) -# button.set_size_request(300,100) -# #win.add(button) -# grid.add(button) - -# label = Gtk.Label() -# label.set_label("Hello World") -# label.set_angle(25) -# label.set_halign(Gtk.Align.END) -# grid.attach(label, 1, 2, 2, 1) -# # win.add(label) - -# statusicon = Gtk.StatusIcon() -# statusicon.set_from_file("logo.svg") -# statusicon.set_visible(True) -# statusicon.set_has_tooltip(True) - -# indicator = AppIndicator3.Indicator.new("customtray", -# os.path.abspath("logo.svg"), -# AppIndicator3.IndicatorCategory.APPLICATION_STATUS) - - indicator = AppIndicator3.Indicator.new( "customtray", icon_name, AppIndicator3.IndicatorCategory.APPLICATION_STATUS) @@ -279,14 +136,4 @@ def quit(_): indicator.set_menu(build_menu()) -# def reset_menu(): -# indicator.set_menu(build_menu()) -# return True - - -# GLib.timeout_add(5000, reset_menu) - -# win.set_default_size(500,500) -# win.show_all() - Gtk.main() From 9a26eddad95a8a57c99e9ba742ed0468def85372 Mon Sep 17 00:00:00 2001 From: mendhak Date: Sat, 3 Aug 2024 15:58:13 +0100 Subject: [PATCH 07/12] Back to development mode for now --- src/grub-reboot-picker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grub-reboot-picker.py b/src/grub-reboot-picker.py index f57b2e5..0356100 100755 --- a/src/grub-reboot-picker.py +++ b/src/grub-reboot-picker.py @@ -7,7 +7,7 @@ from gi.repository import Gtk, AppIndicator3 SHOW_GRUB_MENU_SUB_MENUS = True -DEVELOPMENT_MODE = False +DEVELOPMENT_MODE = True GRUB_CONFIG_PATH = "/boot/grub/grub.cfg" if DEVELOPMENT_MODE: GRUB_CONFIG_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "grub.test3.cfg") From f70a580035ff120ed7ec66f7505790eef9b213c9 Mon Sep 17 00:00:00 2001 From: mendhak Date: Sat, 3 Aug 2024 16:04:06 +0100 Subject: [PATCH 08/12] Minor linting and cleanup --- src/grub-reboot-picker.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/grub-reboot-picker.py b/src/grub-reboot-picker.py index 0356100..939d142 100755 --- a/src/grub-reboot-picker.py +++ b/src/grub-reboot-picker.py @@ -1,31 +1,34 @@ #!/usr/bin/env python3 +from gi.repository import Gtk, AppIndicator3 import gi import os import re gi.require_version("Gtk", "3.0") gi.require_version('AppIndicator3', '0.1') -from gi.repository import Gtk, AppIndicator3 + SHOW_GRUB_MENU_SUB_MENUS = True DEVELOPMENT_MODE = True GRUB_CONFIG_PATH = "/boot/grub/grub.cfg" if DEVELOPMENT_MODE: GRUB_CONFIG_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "grub.test3.cfg") + GRUB_CONFIG_PATH = "/boot/grub/grub.cfg" icon_name = "un-reboot" + def get_all_grub_entries(file_path, include_submenus=True): """ - Build a dictionary of Grub menu items with sub menu items if applicable. - Simply if it has child items it's a 'submenu' else it's just a top level menu. + Build a dictionary of Grub menu items with sub menu items if applicable. + Simply if it has child items it's a 'submenu' else it's just a top level menu. { - 'Ubuntu': [], + 'Ubuntu': [], 'Advanced options for Ubuntu': [ - 'Ubuntu, with Linux 6.8.0-39-generic', + 'Ubuntu, with Linux 6.8.0-39-generic', 'Ubuntu, with Linux 6.8.0-39-generic (recovery mode)' - ], - 'Memory test (memtest86+x64.bin)': [], - 'Memory test (memtest86+x64.bin, serial console)': [], + ], + 'Memory test (memtest86+x64.bin)': [], + 'Memory test (memtest86+x64.bin, serial console)': [], 'UEFI Firmware Settings': [] } """ @@ -35,17 +38,17 @@ def get_all_grub_entries(file_path, include_submenus=True): menu_pattern = re.compile("^\\s*menuentry ['\"]([^'\"]*)['\"]") submenu_pattern = re.compile("^\\s*submenu ['\"]([^']*)['\"]") closing_brace_pattern = re.compile("^\\s*}") - + menu_entries = {} - processing_submenu=False - submenu_item_added=False - + processing_submenu = False + submenu_item_added = False + for line in lines: submenu_match = submenu_pattern.match(line) menu_match = menu_pattern.match(line) closing_brace_match = closing_brace_pattern.match(line) - + if submenu_match: submenu_title = submenu_match.group(1) menu_entries[submenu_title] = [] @@ -58,8 +61,8 @@ def get_all_grub_entries(file_path, include_submenus=True): else: menu_entries[menu_title] = [] elif closing_brace_match: - # submenu_item_added would match for the first nested closing brace, - # then processing_submenu for the top level closing brace. + # submenu_item_added would match for the first nested closing brace, + # then processing_submenu for the top level closing brace. if submenu_item_added: submenu_item_added = False elif processing_submenu: @@ -69,7 +72,7 @@ def get_all_grub_entries(file_path, include_submenus=True): for k, v in list(menu_entries.items()): if len(v) > 0: del menu_entries[k] - + return menu_entries @@ -88,8 +91,7 @@ def build_menu(): submenu = Gtk.Menu() for grub_child in grub_children: submenu_item = Gtk.MenuItem(label=grub_child) - submenu_item.connect('activate', do_grub_reboot, grub_child, - grub_entry) + submenu_item.connect('activate', do_grub_reboot, grub_child, grub_entry) submenu.append(submenu_item) menuitem.set_submenu(submenu) @@ -129,6 +131,7 @@ def do_shutdown(_): def quit(_): Gtk.main_quit() + indicator = AppIndicator3.Indicator.new( "customtray", icon_name, AppIndicator3.IndicatorCategory.APPLICATION_STATUS) From 778ba2320b813034840487ef0ca5ed5dca97672c Mon Sep 17 00:00:00 2001 From: mendhak Date: Sat, 3 Aug 2024 16:05:40 +0100 Subject: [PATCH 09/12] Restore the gi repository import --- src/grub-reboot-picker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grub-reboot-picker.py b/src/grub-reboot-picker.py index 939d142..41cdaff 100755 --- a/src/grub-reboot-picker.py +++ b/src/grub-reboot-picker.py @@ -1,10 +1,10 @@ #!/usr/bin/env python3 -from gi.repository import Gtk, AppIndicator3 import gi import os import re gi.require_version("Gtk", "3.0") gi.require_version('AppIndicator3', '0.1') +from gi.repository import Gtk, AppIndicator3 SHOW_GRUB_MENU_SUB_MENUS = True From 5082d2111071d9213e20b8788031fb81e9059bab Mon Sep 17 00:00:00 2001 From: mendhak Date: Sat, 3 Aug 2024 17:03:01 +0100 Subject: [PATCH 10/12] Changelogs and version bumps --- CHANGELOG.md | 8 +++++++- README.md | 6 ++++++ setup.cfg | 2 +- setup.py | 2 +- src/grub-reboot-picker.py | 2 +- version.sh | 2 +- 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a927542..0e8ee1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,4 +12,10 @@ Rebuilt package for Ubuntu 22.04 Jammy Jellyfish * 0.0.8: Build for Ubuntu 23.04 - Rebuilt package for Ubuntu 23.04 Lunar Lobster \ No newline at end of file + Rebuilt package for Ubuntu 23.04 Lunar Lobster + + * 0.0.9: Parsing and menu hover bugfix + Bugfix, some menu items weren't parsed correctly. + Bugfix, menu items weren't nesting correctly. + Bugfix, menu items were being activated on hover. + Rebuilt package for Ubuntu 24.04 Noble Numbat. \ No newline at end of file diff --git a/README.md b/README.md index 5a1a553..d2994f8 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,12 @@ Then to build: ``` # Set the version +nano version.sh +# Update the changelog, carefully +nano CHANGELOG.md +# Set the suite to use, like jammy, noble, etc. +nano setup.cfg +# Read the version source version.sh # Clean everything rm -rf deb_dist dist *.tar.gz *.egg* build tmp diff --git a/setup.cfg b/setup.cfg index f4cdea8..1c486ee 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,7 @@ ignore-install-requires: True depends3: python3-gi, python3-gi-cairo, gir1.2-gtk-3.0, gir1.2-appindicator3-0.1 package3: grub-reboot-picker -suite: lunar +suite: noble section: utils copyright-file: LICENSE.md build-depends: python3-stdeb, fakeroot, python3-all, dh-python, python3-setuptools \ No newline at end of file diff --git a/setup.py b/setup.py index aff6e8d..8c392aa 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ into different OSes based on the grub menu. Basically, a wrapper around grub-reboot command. The icon sits in the tray area in gnome. - Tested on Ubuntu 20.04, 22.04, 23.04. + Tested on Ubuntu 20.04, 22.04, 23.04, 24.04 """, long_description_content_type="text/plain", url="https://github.com/mendhak/grub-reboot-picker", diff --git a/src/grub-reboot-picker.py b/src/grub-reboot-picker.py index 41cdaff..bb3018a 100755 --- a/src/grub-reboot-picker.py +++ b/src/grub-reboot-picker.py @@ -8,7 +8,7 @@ SHOW_GRUB_MENU_SUB_MENUS = True -DEVELOPMENT_MODE = True +DEVELOPMENT_MODE = False GRUB_CONFIG_PATH = "/boot/grub/grub.cfg" if DEVELOPMENT_MODE: GRUB_CONFIG_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "grub.test3.cfg") diff --git a/version.sh b/version.sh index beafdee..23674a0 100644 --- a/version.sh +++ b/version.sh @@ -1 +1 @@ -export version=0.0.8 +export version=0.0.9 From cf9669d7757ef877fc086fbd5f092d214d134926 Mon Sep 17 00:00:00 2001 From: mendhak Date: Sat, 3 Aug 2024 20:07:40 +0100 Subject: [PATCH 11/12] Allow grub-reboot-picker to read the grub.cfg file --- README.md | 4 ++-- com.mendhak.grubrebootpicker.desktop | 2 +- com.mendhak.grubrebootpicker.policy | 12 ++++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d2994f8..36787fd 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,10 @@ Clone this repo, then run the python script. ``` cd src -./grub-reboot-picker.py +sudo ./grub-reboot-picker.py ``` - +Sudo is required here because grub.cfg may not be readable (0600 permission) ## Building a distributable diff --git a/com.mendhak.grubrebootpicker.desktop b/com.mendhak.grubrebootpicker.desktop index 694d44c..a63be43 100644 --- a/com.mendhak.grubrebootpicker.desktop +++ b/com.mendhak.grubrebootpicker.desktop @@ -3,7 +3,7 @@ Type=Application Name=Grub Reboot Picker GenericName=Grub Reboot Picker Comment=Pick an OS to reboot into -Exec=/usr/sbin/grub-reboot-picker +Exec=pkexec /usr/sbin/grub-reboot-picker Terminal=false Icon=un-reboot Keywords=reboot;grub;restart;OS;windows;ubuntu; diff --git a/com.mendhak.grubrebootpicker.policy b/com.mendhak.grubrebootpicker.policy index bb589b6..9b9baf3 100644 --- a/com.mendhak.grubrebootpicker.policy +++ b/com.mendhak.grubrebootpicker.policy @@ -39,4 +39,16 @@ /usr/sbin/shutdown false + + Run grub-reboot-picker + Run grub-reboot-picker so it can read grub.cfg + un-reboot + + yes + yes + yes + + /usr/sbin/grub-reboot-picker + false + \ No newline at end of file From d81fc9cde7b30680e5758ff55120473ad0e3c032 Mon Sep 17 00:00:00 2001 From: mendhak Date: Sat, 3 Aug 2024 22:18:15 +0100 Subject: [PATCH 12/12] Move the suite into commandline arg and allow building multiple versions --- .gitignore | 3 ++- README.md | 6 ++---- setup.cfg | 1 - version.sh | 3 ++- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index a46df68..8ec3fb7 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ deb_dist *.egg-info tmp -grub*.cfg \ No newline at end of file +grub*.cfg +*.deb \ No newline at end of file diff --git a/README.md b/README.md index 36787fd..b5e97d3 100644 --- a/README.md +++ b/README.md @@ -80,18 +80,16 @@ sudo apt install python3-stdeb fakeroot python3-all dh-python lintian devscripts Then to build: ``` -# Set the version +# Set the version and suite (noble, jammy, etc) nano version.sh # Update the changelog, carefully nano CHANGELOG.md -# Set the suite to use, like jammy, noble, etc. -nano setup.cfg # Read the version source version.sh # Clean everything rm -rf deb_dist dist *.tar.gz *.egg* build tmp # Create the source and deb -python3 setup.py --command-packages=stdeb.command bdist_deb +python3 setup.py --command-packages=stdeb.command sdist_dsc --suite $suite bdist_deb # Run a lint against this deb lintian deb_dist/grub-reboot-picker_$version-1_all.deb # Look at information about this deb diff --git a/setup.cfg b/setup.cfg index 1c486ee..9499660 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,6 @@ ignore-install-requires: True depends3: python3-gi, python3-gi-cairo, gir1.2-gtk-3.0, gir1.2-appindicator3-0.1 package3: grub-reboot-picker -suite: noble section: utils copyright-file: LICENSE.md build-depends: python3-stdeb, fakeroot, python3-all, dh-python, python3-setuptools \ No newline at end of file diff --git a/version.sh b/version.sh index 23674a0..b09cf11 100644 --- a/version.sh +++ b/version.sh @@ -1 +1,2 @@ -export version=0.0.9 +export suite=focal +export version=0.0.9+$suite \ No newline at end of file