1
0

Add experimental options to hide home screen widgets

Hook HomePageView's constructor to optionally hide widgets by their
internal objectName (row1col2, row2col2, row3). This is the runtime
equivalent of the corresponding kobopatch patches.

The hook is optional and all widget lookups are null-checked, so
unsupported firmware versions are handled gracefully.

Also adds nh_dump_log() call on init for debugging (fork-only).
This commit is contained in:
2026-03-17 12:13:34 +01:00
parent 833c6d40b4
commit c55840adbf
2 changed files with 52 additions and 0 deletions

22
res/doc
View File

@@ -219,6 +219,28 @@
# (..)_icon -> the path passed to QPixmap
# (..)_icon_active -> the path passed to QPixmap
#
# The following experimental options hide elements on the home screen by
# their internal widget name. These are the runtime equivalent of the
# corresponding kobopatch patches. A reboot is required for changes to take
# effect. If a widget is not found on the current firmware, it is silently
# skipped and a warning is written to syslog.
#
# <key> one of:
# hide_home_row1col2_enabled - hides the recommendations column in the top-right
# of the home screen, next to the book you are
# currently reading (when fewer than 2 books are open)
# hide_home_row2col2_enabled - hides the right column of the middle row on the
# home screen (usually shows the last viewed
# collection)
# hide_home_row3_enabled - hides the footer row below "My Books" on the home
# screen, which often advertises features like the
# Kobo Store, Pocket, and more
# <val> 0 or 1
#
# Example:
# experimental:hide_home_row1col2_enabled:1
# experimental:hide_home_row3_enabled:1
#
# For example, you might have a configuration file named "mystuff" like:
#
# menu_item :main :Show an Error :dbg_error :This is an error message!

View File

@@ -82,6 +82,10 @@ void (*MenuTextItem_MenuTextItem)(MenuTextItem*, QWidget* parent, bool checkable
void (*MenuTextItem_setText)(MenuTextItem*, QString const& text);
void (*MenuTextItem_registerForTapGestures)(MenuTextItem*);
// Home page widget hiding.
typedef QWidget HomePageView;
void (*HomePageView_HomePageView)(HomePageView*, QWidget* parent);
// Selection menu stuff (14622+).
typedef void SelectionMenuController; // note: items are re-initialized every time the menu is opened
typedef QWidget SelectionMenuView;
@@ -114,6 +118,9 @@ static struct nh_hook NickelMenuHook[] = {
// bottom nav main menu button injection (15505+)
{.sym = "_ZN11MainNavViewC1EP7QWidget", .sym_new = "_nm_menu_hook2", .lib = "libnickel.so.1.0.0", .out = nh_symoutptr(MainNavView_MainNavView), .desc = "bottom nav main menu button injection (15505+)", .optional = true}, //libnickel 4.23.15505 * _ZN11MainNavViewC1EP7QWidget
// home page widget hiding
{.sym = "_ZN12HomePageViewC1EP7QWidget", .sym_new = "_nm_homepageview_hook", .lib = "libnickel.so.1.0.0", .out = nh_symoutptr(HomePageView_HomePageView), .desc = "home page widget hiding", .optional = true},
// selection menu injection
{.sym = "_ZN23SelectionMenuController11addMenuItemEP17SelectionMenuViewP12MenuTextItemPKc", .sym_new = "_nm_menu_hook3", .lib = "libnickel.so.1.0.0", .out = nh_symoutptr(SelectionMenuController_addMenuItem), .desc = "selection menu injection", .optional = true}, //libnickel 4.20.14622 * _ZN23SelectionMenuController11addMenuItemEP17SelectionMenuViewP12MenuTextItemPKc
{.sym = "_ZN18WebSearchMixinBase17doWikipediaSearchERK7QStringS2_", .sym_new = "_nm_menu_hook4", .lib = "libnickel.so.1.0.0", .out = nh_symoutptr(WebSearchMixinBase_doWikipediaSearch), .desc = "selection menu injection (wikipedia handler)", .optional = true}, //libnickel 4.20.14622 * _ZN18WebSearchMixinBase17doWikipediaSearchERK7QStringS2_
@@ -208,6 +215,9 @@ static int nm_init() {
NM_LOG("... warning: size returned by nm_global_config_items is 0, ignoring for now (this is a bug; it should always have a menu item whether the default, an error, or the actual config)");
}
// FORK: always dump log to /mnt/onboard/.kobo/ for debugging (remove this line to revert)
nh_dump_log();
return 0;
}
@@ -481,6 +491,26 @@ extern "C" __attribute__((visibility("default"))) void _nm_menu_hook2(MainNavVie
NM_LOG("Added button.");
}
extern "C" __attribute__((visibility("default"))) void _nm_homepageview_hook(HomePageView *_this, QWidget *parent) {
NM_LOG("HomePageView::HomePageView(%p, %p)", _this, parent);
HomePageView_HomePageView(_this, parent);
const char *hide_widgets[] = {"row1col2", "row2col2", "row3"};
for (size_t i = 0; i < sizeof(hide_widgets) / sizeof(hide_widgets[0]); i++) {
char key[32];
snprintf(key, sizeof(key), "hide_home_%s_enabled", hide_widgets[i]);
const char *val = nm_global_config_experimental(key);
if (!val || strcmp(val, "1"))
continue;
QWidget *w = _this->findChild<QWidget*>(QString::fromLatin1(hide_widgets[i]));
if (w)
w->setVisible(false);
else
NM_LOG("warning: could not find home page widget '%s' to hide (it may not exist on this firmware version)", hide_widgets[i]);
}
}
// _nm_menu_hook4_item gets/sets the current menu item. It must only be called
// by one thread at a time. The item will be cleared after it has been used.
nm_menu_item_t *_nm_menu_hook4_item(nm_menu_item_t *it) {