swiftbar / SwiftBar

Powerful macOS menu bar customization tool
https://swiftbar.app
MIT License
2.93k stars 92 forks source link

[feature request] make the scripts directory headlessly configurable #330

Closed IvarWithoutBones closed 2 years ago

IvarWithoutBones commented 2 years ago

Hello, I was wondering if you would be interested in added a command line or configuration file option to set the path to the scripts directory.

I'm using Nix to manage my user environment, which takes care of managing dependencies for some scripts I use with this project. Those scripts are written to nix's store, a completely isolated directory which path looks something like /nix/store/<sha256 hash>-swiftbar-scripts/. The <hash> part would change if any dependencies update, or if I make any changes to the scripts.

It would be great if I could point swiftbar to that store path without having to go through the GUI, that's quite a pain right now. Since I also launch swiftbar through a service managed with nix, I could easily point it to the correct directory with a command line flag, so that no graphical setup is required for my configuration to work.

I currently work around the store paths being inconsistent upon updates by symlinking my scripts directory from the store to /etc/swiftbar-scripts, but its not quite an optimal solution since I still need to go through the GUI to select that.

melonamin commented 2 years ago

How about #192?

IvarWithoutBones commented 2 years ago

Thanks for the quick response!

Unfortunately that doesn't quite do the trick. Running that command will work when setting the directory the first time, but it doesn't update it when running the command again with a different directory.

With it my configuration does work without the need of going through the GUI which is great, but I still need to symlink stuff to /etc.

melonamin commented 2 years ago

Shouldn’t be the case, this command changes the plugin directory, it does more or less the same thing as the UI.

The trick is to restart SwiftBar if it is running.

IvarWithoutBones commented 2 years ago

Shouldn’t be the case, this command changes the plugin directory, it does more or less the same thing as the UI.

The trick is to restart SwiftBar if it is running.

That's odd. It doesn't seem to update the plugin folder at all for me, even after restarting it. Tried the following without swiftbar running to attempt to debug this:

~ > mkdir foo                                                      INSERT
~ > sudo defaults write com.ameba.Swiftbar PluginDirectory foo     
~ > defaults write com.ameba.Swiftbar PluginDirectory foo          
~ > SwiftBar                                          

But the directory used was still the same as before I ran these commands, the foo directory is not recognized at all. The defaults seem correct though:

~ > defaults read com.ameba.Swiftbar PluginDirectory                           
foo
~ > sudo defaults read com.ameba.Swiftbar PluginDirectory                      
foo

Also tried to set the default to $(realpath "foo") with no luck.

Where does it store these preferences? I dont see com.ameba.Swiftbar in ~/Library or /Library.

IvarWithoutBones commented 2 years ago

Ah, never mind! It appears the capitalization in my command wasn't correct, com.ameba.Swiftbar -> com.ameba.SwiftBar did the trick :)