Remapping quick switcher button on the mobile navigation bar

If you want to fairly easily override or re-map the quick switcher button on mobile, save this as a .js file and point the CodeScript ToolKit to it as your “Startup script path.” Replace new Notice("Hello, world!"); with whatever you want.

export async function invoke(app) {
	const switcherbutton = app?.mobileNavbar?.containerEl?.querySelector('.mobile-navbar-action-quick-switcher');

	switcherbutton.addEventListener('click', (event) => {
		event.stopImmediatePropagation();
		event.preventDefault();
		new Notice("Hello, world!");
	}, true); 
}

Running whatever command you want

To get the command IDs for every command palette command, run
console.log(Object.keys(app.commands.commands))
then, in your script, you can use it like
app.commands.executeCommandById('workspace:edit-file-title')[1].

Related feature request


  1. This goes into editing the current file’s title. ↩︎

2 Likes

Hi @Abisheik , is this still working in Obsidian 1.11.4 ?

Additionally, do you know of a plugin that allows for further personalization of the navigation bar? Commander kind of works for the Tab bar but with the revamp on mobile I see potential to increase the utility of the navigation bar (at top and below).

I’ve edited it a few times since initially posting it. It should still be working as of 1.11.4.

I don’t know any plugins to do want you want, but check out my adventure of moving the reading mode toggle; could give you ideas on how to do it with code:
[Mobile] Make the reading mode toggle button more reachable (overrides the ribbon menu button) - Share & showcase - Obsidian Forum

1 Like