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

Where does finicky store the path to the config file? #315

Open
usizu opened this issue Jul 29, 2023 · 6 comments
Open

Where does finicky store the path to the config file? #315

usizu opened this issue Jul 29, 2023 · 6 comments

Comments

@usizu
Copy link

usizu commented Jul 29, 2023

Any ideas, suggestions or other feedback

Question: is there a config file in which finicky remembers the path to the specified .finicky.js file?

Reason: In the finicky menu it's possible to select a config file at an arbitrary path. I'm using a dotfile manager to manage my .finicky.js file at a non-default path (.config/..., to keep my ~/ folder tidy) which means manually telling finicky where the new file is located when installing finicky and the config on a fresh machine.

I want to have the whole thing automated (finicky with Brew bundle and the config with chez-moi). It's almost there except I need to manually tell finicky where the new config is located.
Is there some file in which finicky is storing the path to .finicky.js, so that I could put into my dotfile manager also? Then when I deploy finicky and its settings to a new machine, I won't have to manually point it to the custom config path.

Hope I'm making sense, thanks for any info

@jbleuzen
Copy link

jbleuzen commented Oct 4, 2023

It's a constant in the code => /Finicky/Finicky/Config.swift
I think you can't do what you want...

@kyounger
Copy link

Interestingly, there is a way to "Use another file..." from the menu bar drop down. If you add a different config file location through that UI, and then run the command:

/usr/libexec/PlistBuddy -c print ~/Library/Preferences/net.kassett.finicky.plist

It clearly shows that file being stored in some encoded way. Beyond my MacFu to understand how to get that set programmatically.

@kyounger
Copy link

The other issue is that it seems it can't use a symlink as the config file setting, making using nix home-manager difficult.

@kyounger
Copy link

If it helps anyone else coming here for the same thing, I ended up just hacking a little around it.

  home.file.".config/finicky" = {
    source = ./finicky;
    onChange = "cat ~/.config/finicky/fincky.js > ~/.finicky.js";
  };

@gshpychka
Copy link

If it helps anyone else coming here for the same thing, I ended up just hacking a little around it.

  home.file.".config/finicky" = {
    source = ./finicky;
    onChange = "cat ~/.config/finicky/fincky.js > ~/.finicky.js";
  };

Thanks for this! This might be even better:

{config, ...}: let
  filePath = "finicky/config.js";
in {
  xdg.configFile.${filePath} = {
    source = ./config.js;
    onChange = "cat ${config.xdg.configHome}/${filePath} > ${config.home.homeDirectory}/.finicky.js";
  };
}

@dudeofawesome
Copy link

dudeofawesome commented Oct 5, 2024

The path to the config file is stored in Finicky's plist file at ~/Library/Preferences/net.kassett.finicky.plist, under the config_location_bookmark path.

The field type is set to data, which seems to contain a "bookmark", which acts as a link to the actual file.

Apple's NSUrl can be used to generate this bookmark data, which can then be output as hex to use in the plist.

I've got a PR open with mkalias to add support for writing the bookmark data directly to stdout.

Once that PR is merged and nixpkgs is updated to use the new version, a simple bash script in nix's onChange (or a home.activation script) could look like this:

onChange = ''
  PATH="/usr/bin:$PATH" $DRY_RUN_CMD defaults write \
    net.kassett.finicky config_location_bookmark \
      -data "$(${pkgs.mkalias}/bin/mkalias "${config.home.homeDirectory}/${config.xdg.configFile.finicky.target}")"
'';

Or use my branch today using an overlay:

nixpkgs.overlays = [
  (final: prev: {
    mkalias = prev.mkalias.overrideAttrs (old: {
      src = prev.fetchFromGitHub {
        owner = "dudeofawesome";
        repo = "mkalias";
        rev = "feat/stdout-hex-data";
        hash = "sha256-pPIMLnbpx8A9nvKsrOFFcsSu2v260dLr+4HQAc8A9xc=";
      };
    });
  })
];

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

5 participants