Skip to content

JavaScript API documentation

Keith Smiley edited this page Nov 16, 2020 · 10 revisions

It's not written in JavaScript. But this pseudo-code conveys more information, so yeah.

Valid modifiers: cmd | alt | ctrl | shift (case insensitive)

Valid keys: single case insensitive character or special keys (plus F-keys, numpad, etc. listed here)

Require

You can modularize your config using the require function. It will load the referenced .js file and reload it if changes are detected.

require('<path to some.js file>');

If the path is a relative path it's resolved relative to the (real) location of the .conductor.js file. If the .conductor.js file is a symlink the symlink is resolved before resolving the location of the required file.

This feature was contributed by @pascalw.

API

class api
  static Hotkey bind(String key, Array<String> mods, Function callback)
  static void reload()
  static void launch(String appName)
  static void alert(String message, double durationSeconds)
  static void runCommand(String commandPath, Array args)
  static void log(String message)
end

Window

Safe to say most of the stuff we do is in here...

class Window
  static Window focusedWindow()
  static Array<Window> allWindows()
  static Array<Window> visibleWindows()
  static Array<Window> visibleWindowsMostRecentFirst()
  Array<Window> otherWindowsOnSameScreen()
  Array<Window> otherWindowsOnAllScreens()
end

Every screen (aka monitor or display) combines to form a giant rectangle. Every window lives in this rectangle. So this is why window positions and sizes don't have a "screen" parameter. It's already taken into account by the coordinates you give it. To figure out coordinates on a given screen, use the Screen methods.

  Rect frame()
  Point topLeft()
  Size size()
  void setFrame(Rect frame)
  void setTopLeft(Point thePoint)
  void setSize(Size theSize)
  void maximize()
  void minimize()
  void unMinimize()
  Screen screen()
  App app()
  boolean isNormalWindow()
  boolean focusWindow()
  void focusWindowLeft()
  void focusWindowRight()
  void focusWindowUp()
  void focusWindowDown()
  Array<Window> windowsToWest()
  Array<Window> windowsToEast()
  Array<Window> windowsToNorth()
  Array<Window> windowsToSouth()
  String title()
  boolean isWindowMinimized()
end

App

class App
  static Array<App> runningApps()
  Array<Window> allWindows()
  Array<Window> visibleWindows()
  String title()
  boolean isHidden()
  void show()
  void hide()
  int pid()
  void kill()
  void kill9()
end

Screen

Frame sizes and get the next previous screen on a multi screen layout, get the current screen for an Window through the Window api. This also allows you to set the brightness. This is done with a number between 0 and 100. This sets the brightness for all screens.

class Screen
  Rect frameIncludingDockAndMenu()
  Rect frameWithoutDockOrMenu()
  Screen nextScreen()
  Screen previousScreen()
  double getBrightness()
  void setBrightness(double brightness)
end

Hotkey

A Hotkey definition which can be enabled or disabled, loop them and enable / disable en masse to do modal style control of your desktop.

class Hotkey
  boolean enable()
  void disable()
  String key()
  Array<String> mods()
end

Mouse Position

The position of the mouse, captured and restored to and from a Point

class MousePosition
  static Point capture()
  static void  restore(Point mousePoint)
end

Point

A simple point object for 2D coords.

class Point
  property double x
  property double y
end

Size

A simple 2D size object

class Size
  property double width
  property double height
end

Rectangle

You guessed it, a 2D oblong.

class Rect
  property double x
  property double y
  property double width
  property double height
end

Conductor Window Manager

a lightweight scriptable OS X window manager.

Clone this wiki locally