Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please provide a way to change settings without modifying the repository #1384

Open
jaresty opened this issue Feb 10, 2024 · 11 comments
Open

Comments

@jaresty
Copy link
Contributor

jaresty commented Feb 10, 2024

Currently, the talon settings file is committed to this repository. If I want to change those settings that are committed to the repository I need to deal with uncommitted changes or maintain my own branch. Some options that could work:

  • don't commit the settings at all (provide an example instead)
  • clearly document how to override settings using your own file that is more specific
  • instead of configuring settings in the configuration file, set the defaults in code
@ekuiter
Copy link

ekuiter commented Mar 12, 2024

A fourth option (which I currently use) is to maintain your own .talon Git repository, put almost everything but the user directory into .gitignore, and add community as a Git submodule (along with other plugins like cursorless). Then, to override stuff from community:

  • to customize CSV files: add a community-settings directory (as shown below) and link to it with
    rm -rf user/community/settings
    ln -s ../community-settings user/community/settings
    
    so community can find it. This emulates the approach cursorless uses out of the box.
    grafik
  • to customize settings: just add a .talon file (like the one below) including your overridden settings. The key is to make sure that this is loaded after the community repository, for example by putting it into a directory starting with d (which comes after community lexicographically).
    settings():
        user.mouse_enable_pop_click = 2
        user.mouse_hide_mouse_gui = 1
    
    tag(): user.prefixed_numbers
    

This has the added benefit that you can control (using Git submodule commands) the versions of community and other plugins (e.g., to update to new versions without tedious merging or to roll back undesired changes). Also, setting up talon on another computer is now a simple git clone --recursive and creating the symbolic link as shown above.

@jaresty
Copy link
Contributor Author

jaresty commented Mar 12, 2024

I've been told that the trick with talon files is that more specific matching always wins. You can override the settings file by adding a more specific tag. There is also an open pull request which changes many settings to talon list files that can be overridden #1382

@jaresty
Copy link
Contributor Author

jaresty commented Mar 12, 2024

I think there are various ways of solving this problem and this is evidence that this is a real issue for some.

@jaresty
Copy link
Contributor Author

jaresty commented Jul 6, 2024

Adding some documentation to the README to explain how to use the talon list files to override things such as modifier keys (#1477)

@jaresty
Copy link
Contributor Author

jaresty commented Jul 6, 2024

I also added a pull request to the contributing guidelines to suggest a way to provide settings that will be a little more friendly to folks who are not forking the community repository: #1482

@bentitmus
Copy link

bentitmus commented Aug 13, 2024

Edit: ignore this I made a mistake

I tried the option @ekuiter gave, but that doesn't work for me on macOS because Python fails in core/user_settings.py as the symlink is not a directory so it tries to create settings which fails (and then everything breaks). A really simple fix for this in the short term is to use the following logic for finding settings:

# NOTE: Store settings in a `settings` directory at the same level as `community`
#   but fallback on the `community/settings` directory
SETTINGS_DIR = Path(__file__).parents[2] / "settings"
if not SETTINGS_DIR.is_dir():
    SETTINGS_DIR = Path(__file__).parents[1] / "settings"
if not SETTINGS_DIR.is_dir():
    os.mkdir(SETTINGS_DIR)

This should avoid breaking anyone's existing set-up but also allow these files to be commited in a repo. I can raise a PR for this, but won't bother if it will be rejected.

@jaresty
Copy link
Contributor Author

jaresty commented Aug 13, 2024

You don't need to modify the repo - I have it working without modification based on my dotfiles on macos: https://github.com/jaresty/mac-dotfiles

@bentitmus
Copy link

bentitmus commented Aug 13, 2024

Edit: ignore this I made a mistake

You're doing this with symlinks (created by the Makefile) which is what I had and it didn't work for me. Here's the error message I get in my Talon log:

2024-08-13 18:15:29.992 ERROR user.community.core.system_paths (/Users/ben/.talon/user/community/core/system_paths.py) import failed
   18:          lib/python3.11/threading.py:995 * # loader thread
   17:          lib/python3.11/threading.py:1038* 
   16:          lib/python3.11/threading.py:975 * 
   15:              app/resources/loader.py:853 | 
   14:              app/resources/loader.py:785 | 
   13:              app/resources/loader.py:645 | 
   12:              app/resources/loader.py:661 | 
   11:              app/resources/loader.py:716 | 
   10:              app/resources/loader.py:425 | # [stack splice]
    9: lib/python3.11/importlib/__init__.py:126 | 
    8:              app/resources/loader.py:240 | 
    7:              app/resources/loader.py:235 | 
    6:  user/community/core/system_paths.py:11  | from .user_settings import get_list_fr..
    5:              app/resources/loader.py:359 | 
    4:              app/resources/loader.py:240 | 
    3:              app/resources/loader.py:235 | 
    2: user/community/core/user_settings.py:12  | os.mkdir(SETTINGS_DIR)
    1:                                            ^^^^^^^^^^^^^^^^^^^^^^
FileExistsError: [Errno 17] File exists: '/Users/ben/.talon/user/community/settings'

It's failing on:

if not SETTINGS_DIR.is_dir():
    os.mkdir(SETTINGS_DIR)

because SETTINGS_DIR.is_dir() is false.

I created a symlink pointing from ~/.talon/user/community/settings to ~/.talon/user/local/settings.

Here's my GitHub .config directory, and at the end of my INSTALL.macos file I set-up the symlinks.

@jaresty
Copy link
Contributor Author

jaresty commented Aug 13, 2024

I've been running with symlinks without issues for a while. This is the link I set up:


ln -sf ~/mac-dotfiles/talon-settings ../.talon/user/community/settings

Are you making the same symlink or doing something different?

@jaresty
Copy link
Contributor Author

jaresty commented Aug 13, 2024

Can you try using ls on your symlink to verify you can follow the link?

@bentitmus
Copy link

Yes, user incompetence I'm afraid! I thought I had checked this but clearly not as I had it pointing to the wrong place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants