Skip to content

Instantly share code, notes, and snippets.

@jewel12
Last active December 11, 2015 20:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jewel12/4656239 to your computer and use it in GitHub Desktop.
Save jewel12/4656239 to your computer and use it in GitHub Desktop.

基本的には https://github.com/jigish/slate/wiki/JavaScript-Configs を参照

JavaScriptによる設定ファイルの置き場所

  • .slate.jsをホームディレクトリに置く
  • .slate => .slate.js の順で読み込まれる

globalオブジェクト

  • slate => SlateのAPIにアクセスできる
  • _ => underscore.jsを使う

slate オブジェクト

  • Slateの設定と環境やウィンドウの情報を取得できる
  • S というオブジェクトにエイリアスされているので、slate.log("hi");がS.log("hi");と書ける

Config API

https://github.com/jigish/slate/wiki/Global-Configs の設定を行う。

S.config, S.cfg, S.configAll, S.cfga

  • slate.config(name, value);と設定できる。
  • name : 設定名
  • value: 設定によって文字列や数値 etc. となる
  • configAll, cfga
    • 一括設定できる

S.operation, S.op

Slateのoperationオブジェクトを生成する。 Slateが提供している操作の一覧は→ https://github.com/jigish/slate/wiki/Operations

var object = slate.operation(name, params);

  • name: move等の操作名
  • params: 操作に渡すパラメータをハッシュ形式で

var fullscreen = slate.operation("move", { "x" : "screenOriginX", "y" : "screenOriginY", "width" : "screenSizeX", "height" : "screenSizeY" });

S.bind, S.bindAll

キーバインドの設定

slate.bind(keystroke, action, repeat);

  • keystroke : "1:ctrl" の用に設定する
  • action: eoperationオブジェクトを設定
    • もしくは関数オブジェクト
    • 関数オブジェクトへの引数にはフォーカスしているウィンドウオブジェクトが渡される
  • repat

S.layout

layout情報を持つオブジェクトを生成。

var name = slate.layout(name, { app : params, app : params ... });

S.default

解像度やモニターの数などを設定できる。

S.source

外部設定ファイルの読み込み。

Info API

S.shell, S.sh

コマンドの実行結果を取得できる。

var output = slate.shell(commandAndArgs, waitForExit, path); var echoOutput = S.sh("/usr/echo hello", true, "~/");

  • commandAndArgs : 文字列でコマンドと引数を渡す
  • waitForExit : true にしておくとコマンドの実行が終わるまで待つ
  • path : ワーキングディレクトリ

S.window

現在フォーカスしているウィンドウの情報を取得。

var windowObject = slate.window();

windowオブジェクトについては→ https://github.com/jigish/slate/wiki/Window-Object

S.windowUnderPoint

x,y座標で指定したところにあるウィンドウのオブジェクトを取得。これを使うと面白いことができそう。

S.isPointOffScreen, S.isRectOffScreen

S.eachScreen

それぞれのscreenに対して処理を行う

S.log

S.log(message);

でコンソールアプリに出力される

screenオブジェクト

Applicationオブジェクト

  • pid, nameが取得できる
  • eachWindowはアプリケーション内のウィンドウのそれぞれに対して処理できる
  • mainWindow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment