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