launchctl is a major mode in Emacs that eases the loading and unloading of services (user agents and system daemons) managed by launchd on Mac OS X.
launchctl interfaces with the command line tool launchctl
under the hood.
Launchctl is available from MELPA.
This package requires tabulated-list-mode which is only available for Emacs 24 and onwards.
If you install the package manually, put this in your dot emacs file:
(require 'launchctl)
Do M-x launchctl
to enter launchctl mode.
Most commands are service-specific: you simply move the point to the corresponding service and execute that command.
Note that some commands (namely edit, load, unload, enable and disable) require
users to supply the path to the corresponding service configuration file
(.plist). launchctl will first look for <service-name>.plist
under the directories defined in launchctl-search-path
, and if the file
can't be found, prompt you for the path.
See Customization below on how to define your own search path.
Refresh the buffer.
Sort the buffer by service name.
You'll be prompted for a file name. See customization on how to customize the configuration template.
Put the code below in your .emacs to have Emacs recognize plist files as XML files:
(add-to-list 'auto-mode-alist '("\\.plist$" . nxml-mode))
Equivalent to
bash$ launchctl load <service-configuration-file>
Equivalent to
bash$ launchctl unload <service-configuration-file>
Unload and then reload.
Once a service has been disabled, you won't be able to start or load it.
Equivalent to
bash$ launchctl unload -w <service-configuration-file>
To start or load a disabled service, you must enable it first.
Equivalent to:
bash$ launchctl load -w <service-configuration-file>
Equivalent to
bash$ launchctl start <service-name>
Equivalent to
bash$ launchctl stop <service-name>
Stop and then start the service.
Equivalent to
bash$ launchctl remove <service-name>
Display service info
Equivalent to:
bash$ launchctl list <service-name>
You will be prompted for a regular expression. Only services whose names match the expression will be shown. See Customization below on how to set a default value.
Set an environment variable. You will be prompted for the variable name and its
value (separated by space), e.g. SOME_VAR "SOME VALUE"
.
Equivalent to:
bash$ launchctl setenv SOME_VAR "SOME_VALUE"
Unset an environment variable. You will be prompted for the variable name.
Equivalent to:
bash$ launchctl unsetenv SOME_VAR
Display a help message in the mini-buffer.
You can M-x customize-group
(group name: launchctl
) to
customize launchctl.
The directories to look for service configuration files. The default value should be good for most people.
;;; Default
("~/Library/LaunchAgents" "/System/Library/LaunchAgents" "/System/Library/LaunchDaemons")
When you choose to create (n
) a new configuration file, the corresponding
file buffer will be populated by this template.
This regular expression will be used by launchctl to filter results . An
empty string (default) or .
means no filtering will be done.
Customize the appearance of the Name column.
Customize the widths of the columns
Turn the header line on or off.