mattr- / slate

A window management application (replacement for Divvy/SizeUp/ShiftIt)
GNU General Public License v3.0
614 stars 39 forks source link

slate not loading javascript config file #67

Closed hoxiea closed 8 years ago

hoxiea commented 8 years ago

Hey, everyone.

I've been playing around with Slate for a few days, and it's great. I started with a non-javascript config file (~/.slate), based on Tristan Hume's, and mostly got things working the way I wanted them.

However, I wanted a way to "throw the current window to the monitor that it's not on" (which BetterTouchTool does quite well), and that seemed like a job for a dynamic ~/.slate.js config file.

Slate doesn't seem to be reading my .slate.js file, though. This became clear after a few "tweak/reload" cycles that didn't seem to have any effect on Slate functionality, at which point I just added the line

throw "Loading Javascript file!";

According to the documentation, this should cause an alert to appear (and I definitely saw error alerts when I got things wrong with my static config file), but no alerts appear.

I'm on ElCap 10.11.3, haven't had any issues with the Accessibility System Preferences, I'm running Slate 1.2.0 installed via homebrew cask, and my home directory contains the following:

~> pwd
/Users/work
~> ls -al | grep "slate"
lrwxr-xr-x   1 work  staff     17 Mar 19 11:28 .slate -> dotfiles/dotslate
lrwxr-xr-x   1 work  staff     20 Mar 21 06:29 .slate.js -> dotfiles/dotslate.js

Any thoughts about what I'm doing wrong here? I tried temporarily moving the files themselves to my home directory (instead of using symbolic links), but that didn't change anything.

Thanks in advance!

mattr- commented 8 years ago

Are you trying to use both a static config and a JS config file? If so, the static config takes precedence over the JS config and you'll need to move everything over.

hoxiea commented 8 years ago

Thanks for the prompt reply, Matt.

I am trying to use both a static config file and a JS config file. I thought that I could do that, based on the documentation:

To use JavaScript configs, create the file .slate.js in your home directory. You can use .slate.js alongside your .slate file if you like and Slate will load both (.slate first, then .slate.js). You can also use only the .slate.js if you want. All JavaScript configs should go into the .slate.js file.

That seemed pretty reasonable to me. But based on your comment, I started experimenting with different combinations of config files. Here's what I observed:

static file JS file observed behavior
none single line: throw "abc"; abc alert, followed by an alert about "no config file found." No static functionality
full working file single line: throw "abc"; abc alert. If I choose to skip, then all my static functionality is present. So it does seem able to load both a static and a dynamic config file.
full working file example js function found here Both static and JS functionality work just fine
full working file example js function found here, plus throw "abc"; abc alert. Skipping gives both static and JS functionality
full working file example js and throw at the bottom, started adding my own functionality at the top no alert or dynamic functionality; static functionality is fine

I managed to isolate a syntax error in my custom javascript (an open paren lacked a closing paren), and fixing the error caused my custom functionality to work. So I guess the moral of the story is "You can have both static and dynamic, but good luck debugging your dynamic stuff?"

mattr- commented 8 years ago

I'm glad that I was wrong about them not co-existing!

mattr- commented 8 years ago

I opened #68 for the troubleshooting problems and I'll close this one since the problem is solved for you now.