# \[Space-Script\] Command to toggle sync mode

**URL:** <https://community.silverbullet.md/t/space-script-command-to-toggle-sync-mode/1721>\
**Category:** Tricks & Techniques\
**Created:** [January 29, 2025, 3:26pm UTC](https://community.silverbullet.md/t/space-script-command-to-toggle-sync-mode/1721 "2025-01-29T15:26:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![22rw](https://community.silverbullet.md/user_avatar/community.silverbullet.md/22rw/32/659_2.png) [@22rw](https://community.silverbullet.md/u/22rw)\
**Post date:** [January 29, 2025, 3:26pm UTC](https://community.silverbullet.md/t/space-script-command-to-toggle-sync-mode/1721/1 "2025-01-29T15:26:06Z")

</div>

Since silverbullet’s navigation is usually keyboard focused and i don’t like having to click a button everytime I want to toggle the client sync mode, I just made this basic command by copying the code from the button in [editor\_ui.tsx](https://github.com/silverbulletmd/silverbullet/blob/11a2adbea6cb10d3d777a389474ee32d32a1d2e2/web/editor_ui.tsx#L234):

```auto
silverbullet.registerCommand({name: "Sync: Toggle"}, async () => {
  if(client.syncMode) {
    localStorage.removeItem("syncMode");
    await editor.flashNotification(
      "Now switching to online mode, one moment please...",
      "info"
    );
  } else {
    localStorage.setItem("syncMode", true);
    await editor.flashNotification(
      "Now switching to sync mode, one moment please...",
      "info"
    );
  }
  await new Promise(resolve => setTimeout(resolve, 1000));
  location.reload();
}); 

```

Not really a neccessity, but it probably saves me about 1 click / month. Absolutely worth it.

---

<div class="post-metadata">

**Author:** ![kolmone](https://community.silverbullet.md/user_avatar/community.silverbullet.md/kolmone/32/948_2.png) [@kolmone](https://community.silverbullet.md/u/kolmone)\
**Post date:** [January 29, 2025, 8:23pm UTC](https://community.silverbullet.md/t/space-script-command-to-toggle-sync-mode/1721/2 "2025-01-29T20:23:21Z")

</div>

This is nice, lets me hide the sync button while still having a way to change modes if needed.
