Save this as a .js file and point CodeScript ToolKit to it as your “Startup script path.” It’ll make it so you can no longer swipe to open the left and right sidebars on mobile.
If you also want to make it so you can’t swipe to close the left/right sidebar and would rather just tap out of them to close them, change the line
if (eventName === "swipe" && data && data.direction === "x" && data.points === 1 && app.workspace.leftSplit.collapsed && app.workspace.rightSplit.collapsed) return;
to
if (eventName === "swipe" && data && data.direction === "x" && data.points === 1) return;
To also disable the two finger navigation swipes, remove the && data.points === 1 part from the if statement.
exports.invoke = async (app) => {
function removeXSwipe(thing) {
if (!thing) return;
const proto = Object.getPrototypeOf(thing);
if (!proto || typeof proto.trigger !== "function" || proto.trigger.__x_removed) return;
const orig = proto.trigger;
proto.trigger = function (eventName, data) {
try {
if (eventName === "swipe" && data && data.direction === "x" && data.points === 1 && app.workspace.leftSplit.collapsed && app.workspace.rightSplit.collapsed) return;
} catch (err) {
console.error(err);
}
return orig.apply(this, arguments);
};
proto.trigger.__x_removed = true;
}
const thingsToHookInto = [app?.workspace, app?.workspace?.rootSplit, app?.workspace?.activeLeaf];
if (!window.__x_swipe_removed || app.isMobile) {
for (const thing of thingsToHookInto) removeXSwipe(thing);
window.__x_swipe_removed = true;
}
}
Relevant feature request: Settings to disable the “Swipe Left/Right action” - Feature requests - Obsidian Forum
Tip: Long pressing the three dots on the right side of the Obsidian app header opens the right sidebar. This is default Obsidian behavior.