Pyroh / Fluor

A handy tool for macOS allowing you to switch Fn keys' mode based on active application.
https://fluorapp.net
MIT License
1.94k stars 118 forks source link

Fluor and "defaults write" command #52

Closed ruzickap closed 4 years ago

ruzickap commented 4 years ago

Hello.

I'm trying to configure Fluor using command line, but it doesn't work for some reason...

I configured 2 application in Fluor (using gui) and got this output:

$ defaults read com.pyrolyse.Fluor AppRules
(
        {
        behavior = 1;
        id = "org.mozilla.firefox";
        path = "/Applications/Firefox.app";
    },
        {
        behavior = 2;
        id = "com.googlecode.iterm2";
        path = "/Applications/iTerm.app";
    }
)

Then I quit Fluor and removed all it's Application rules using defaults delete com.pyrolyse.Fluor AppRules.

Then I add new AppRules configuration using this command:

$ defaults write com.pyrolyse.Fluor AppRules -array '{
  behavior = 1;
  id = "org.mozilla.firefox";
  path = "/Applications/Firefox.app";
}' '{
  behavior = 2;
  id = "com.googlecode.iterm2";
  path = "/Applications/iTerm.app";
}'

# Output is the same like in the first example:
$ defaults read com.pyrolyse.Fluor AppRules
(
        {
        behavior = 1;
        id = "org.mozilla.firefox";
        path = "/Applications/Firefox.app";
    },
        {
        behavior = 2;
        id = "com.googlecode.iterm2";
        path = "/Applications/iTerm.app";
    }
)

Then I started Fluor again, but I do not see any defined rules in the window.

I have no idea what needs to be done to set these rules using command line.

Thank you for the answer

Pyroh commented 4 years ago

I’l l try to reproduce the issue. I bet you’re not just looking for a mass rule delete, can you share what you’d like to do here ? There may be a more suitable solution.

ruzickap commented 4 years ago

Sure...

I'm trying to configure Fluor using command line (probably defaults write is a good choice).

I do not want to use GUI at all and have it configured, before first start.

It means if I get a new MacOS the steps should be like:

brew install fluor
sudo sqlite3 ...
defaults write ...
defaults write ...
...
sudo reboot

And everything should be ready to use... But the example above when I'm trying to add 2 Application Rules using defaults write doesn't work for me.

Pyroh commented 4 years ago

I successfully reproduced the bug. defaults read com.pyrolyse.Fluor shows outdated information. But ~/Library/Preferences/com.pyrolyse.Fluor.plist is up-to-date. It must be a cache issue or something. We would lose time trying to solve it.

Anyway, instead of defaults [command] com.pyrolyse.Fluorjust use defaults [command] ~/Library/Preferences/com.pyrolyse.Fluor it should work.

ruzickap commented 4 years ago

I tried it but still no Rules in the GUI:

$ defaults write ~/Library/Preferences/com.pyrolyse.Fluor AppRules -array '{
  behavior = 1;
  id = "org.mozilla.firefox";
  path = "/Applications/Firefox.app";
}' '{
  behavior = 2;
  id = "com.googlecode.iterm2";
  path = "/Applications/iTerm.app";
}'

I also tried defaults write ~/Library/Preferences/com.pyrolyse.Fluor.plist just to be sure, but still nothing...

ruzickap commented 4 years ago

Seems like this is working fine and I'm able to configure rules using command line:

defaults write com.pyrolyse.Fluor AppRules -array-add '
<dict>
        <key>behavior</key>
        <integer>2</integer>
        <key>id</key>
        <string>com.googlecode.iterm2</string>
        <key>path</key>
        <string>/Applications/iTerm.app</string>
</dict>'

Closing...