Bash Documentation

Documentation for Bash has not been automatically generated, so here it is by hand.

All Bundler functions are prefixed by AlfredBundler::.

Load Functions

AlfredBundler::load

Loads an asset. Takes up to four arguments (minimum of two).

  1. type
  2. The type of asset. For libraries, use bash, for utilities, use utility.

  3. name
  4. The name of the asset.

  5. version
  6. (optional) The version of the asset. If a version is not specified, then latest will be assumed.

  7. json
  8. (optional) The path to the JSON file that defines the asset. The argument is needed only when loading a custom asset.

AlfredBundler::library

Loads a library. A wrapper function around AlfredBundler::load that automatically fills in type as bash. Thus, it requires one argument but will take three.

  1. name
  2. version
  3. json

AlfredBundler::utility

Loads a utility. A wrapper function around AlfredBundler::load that automatically fills in type as utility. Thus, it requires one argument but will take three.

  1. name
  2. version
  3. json

Icon Functions

AlfredBundler::icon

Loads an icon. Takes up to four arguments, which are the standard ones described on the icons page.

  1. font
  2. The icon font to use (see the icon server for a list of supported fonts). Use system to get a system icon.

  3. name
  4. The name of the icon. If you're asking for a system icon, do not include .icns.

  5. color
  6. (optional) A three- or six-digit hex color. If not specified, then it will fallback to 000000 (black).

  7. alter
  8. (optional) Takes either true or false, indicating whether or not to dynamically adjust the "lightness" of the icon based on the user's background. See the icons page for a better explanation. Defaults to false unless the color argument is not given in which case the alter value defaults to true.

Logging Functions

AlfredBundler::log

Logs to a file or the console (or both). Takes up to three arguments.

  1. message
  2. level
  3. destination

AlfredBundler::notify

Sends a system notification with CocoaDialog

  1. message
The workflow name will be the title of the notification, and the workflow's icon will be used as well. If the workflow's icon.png file does not exist, then the bundler's icon will be used instead.

Other Functions

There are several functions that the Bundler uses internally yet may be potentially helpful for a workflow author.

Among these is a small library for floating point math, which has an individual documentation page.

AlfredBundler::check_hex

Checks whether a string is a valid hex color.

Arguments: a hex color.

AlfredBundler::rgb_to_hsv

Converts an RGB colorspace to an HSV colorspace.

Arguments
  1. r
  2. a red value (0–255)

  3. g
  4. a green value (0–255)

  5. b
  6. a blue value (0–255)

AlfredBundler::hsv_to_rgb

Converts an HSV colorspace to an RGB colorspace.

Arguments
  1. h
  2. the hue, 0–360

  3. s
  4. the saturation, 0–1 (float)

  5. v
  6. the value, 0–1 (float)

AlfredBundler::hex_to_rgb

Converts a hex color to an RGB colorspace

Arguments
  1. hex
  2. a hex color as a string

AlfredBundler::rgb_to_hex

Converts an RGB colorspace to a hex string

Arguments
  1. r
  2. a red value (0–255)

  3. g
  4. a green value (0–255)

  5. b
  6. a blue value (0–255)

AlfredBundler::get_luminance

Calculates the luminance of a color

Takes either a hex string or an RGB color.
  1. hex
  2. A hex color as a string

--Or--

  1. r
  2. a red value (0–255)

  3. g
  4. a green value (0–255)

  5. b
  6. a blue value (0–255)

AlfredBundler::get_brightness

Returns either light or dark based on a luminance calculation

Takes either a hex string or an RGB color.
  1. hex
  2. A hex color as a string

--Or--

  1. r
  2. a red value (0–255)

  3. g
  4. a green value (0–255)

  5. b
  6. a blue value (0–255)

Questions?

Post on the Alfred Forum thread.

Bug Reports?

Open an issue in the Github queue.