FelixKratz / SketchyBar

A highly customizable macOS status bar replacement
https://felixkratz.github.io/SketchyBar/
GNU General Public License v3.0
5.45k stars 85 forks source link

make CONFIG_DIR configureable via option #425

Closed breuerfelix closed 10 months ago

breuerfelix commented 10 months ago

first of all thanks for this awesome project!

my setup: i am using home-manager to manage my dotfiles and since i am using your sketchybar plugins anyways, i just use your repository as a flake input for my dotfiles and just have my own sketchybarrc file. All other files are consumed from your dotfiles repo. In nix all input files live in the nix store which is somewhere located at /nix/store/somehash/felixkratz/dotfiles/...

I can set the CONFIG_DIR variable in the sketchybarrc file in order to source from the correct paths, but when sketchybar calls the update functions, it sets the config_dir variable back to the location where it is located (which is /Users/user/.config/sketchybarrc.

So my feature request ist the following: i want to be able to set the config_dir path via parameter. If empty, use the path where the script runs, if passed, use the path provided.

I can try to implement it myself (not familiar with C) but i would not start working my way through the code if you won't merge it anyways. So i wanna ask beforehand, would you merge it? And since you know your codebase, maybe it is just a no brainer for you and you have it done in minutes instead of me going through a new codebase :)

cheers felix

FelixKratz commented 10 months ago

If you start sketchybar with the flag: sketchybar -c <path_to_sketchybarrc> you can supply any sketchybarrc file in any folder and then the CONFIG_DIR variable will be the parent directory of that file. This way you can change the CONFIG_DIR directory to any directory you like.

Does this help you with your problem? In any case, you can pass any environment variable to any script executed by sketchybar simply by setting it in the script variable prior to invoking the actual script, e.g.:

sketchybar --set <name> script='SOME_VAR=something /path/to/some/script.sh'

This way you could also overwrite the CONFIG_DIR variable passed to the scripts on update, since sketchybar sets the variable prior to the script being executed, such that setting up the variable in the script takes precedence.

breuerfelix commented 10 months ago

Well sadly this does not solve my problem since i have my own sketchybarrc in the .config/sketchybar folder, because i do not wanna use all of your modules. Also i cannot set the variable in the sketchybar command since therefore i use the items scripts from your repository so i am not able to overwrite this ...

https://github.com/breuerfelix/dotfiles/blob/main/darwin/sketchybar.nix here is my setup (if you know nix a little bit). I managed to find a workaround for it and copy your items, colors and icon_map also to my .config/sketchybar.

But i also thought about the CONFIG_DIR as a global variable a little bit longer and i guess my proposal is not the optimal solution either. It think of your plugins like "packages" that i can consume and customize via variables (like config dir). So if someone else also has plugins, i just want to add them to my inputs and use them. This would not be possible with one config_dir variable which is the same for ALL sketchybar items added. In a dream world, i would need to have this variable to be modified for each item added and i guess that is more work for a niche use case ... Thanks for mentioning these ways of customizing the varible, i didn't know that, maybe i come up with another solution :)