nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.62k stars 1.74k forks source link

joplin-desktop: keymap-desktop.json #5633

Open yajo opened 1 month ago

yajo commented 1 month ago

Description

We already have the ability to extend joplin-desktop settings with custom ones.

It would be very helpful if we were also able to declare hotkeys. Those are stored in a separate file (~/.config/joplin-desktop/keymap-desktop.json).

Sometimes there are some hotkeys that you can only add by altering that JSON file by hand, because they're not exposed on Joplin UI (example: https://github.com/benji300/joplin-note-tabs/issues/66#issuecomment-1938206993).

Current workaround is:

{
  home.file.".config/joplin-desktop/keymap-desktop.json" = {
    enable = true;
    text = builtins.toJSON [
      {
        command = "tabsSwitchLastActive";
        accelerator = "Ctrl+Tab";
      }
      {
        command = "tabsSwitchLeft";
        accelerator = "Ctrl+PageUp";
      }
      {
        command = "tabsSwitchRight";
        accelerator = "Ctrl+PageDown";
      }
    ];
  };
}

However, this would be way more ergonomic:

{
  programs.joplin-desktop.keymap = {
    tabsSwitchLastActive = "Ctrl+Tab";
    tabsSwitchLeft = "Ctrl+PageUp";
    tabsSwitchRight = "Ctrl+PageDown";
  }
}

Besides, if implemented in the HM module, another advantage is that we could use the same strategy as current config file, by extending current file instead of replacing it. That way, Joplin's UI won't fail when editing some other keyboard shortcut from UI because the file will be editable (not happening now with my workaround).

zorrobert commented 1 month ago

@yajo Hey, thanks for the suggestion, this looks very useful. I'll take a look and add it in the next PR :)