Skip to main content

Extremely basic launchctl wrapper for macOS.

Project description

service

Extremely basic launchctl wrapper for macOS.

Requirements

  • macOS 12.x+
  • Python 3.10.x, 3.11.x

Installation

pip install py-service

Usage

Usage: service [OPTIONS] COMMAND [ARGS]...

  Extremely basic launchctl wrapper for macOS.

Options:
  -c, --config TEXT  The configuration file to use
  --help             Show this message and exit.
  -v, --verbose      Increase verbosity
  --version          Show the version and exit.

Commands:
  disable  Disable a service (system domain only).
  enable   Enable a service (system domain only).
  restart  Restart a service.
  start    Start a service.
  stop     Stop a service.

Services can be referenced by name, file name (with or without ".plist" extension), or the full path to the file. When referenced by name the service will be resolved using the defined reverse domains (see Configuration). Examples of valid service references are:

  • baz (when reverse domains are defined)
  • com.foobar.baz
  • com.foobar.baz.plist
  • /Library/LaunchDaemons/com.foobar.baz
  • /Library/LaunchDaemons/com.foobar.baz.plist

Note: Targeting a macOS system service found in the /System/* path will raise an error and terminate without attempting to modify the service state. These services typically cannot be changed unless SIP is disabled.

Examples

Start a service:

$ service start com.gui.xserv
xserv started

Enable and start a service (system domain):

$ sudo service start --enable com.sys.xserv
xserv enabled and started

Stop a service:

$ service stop com.gui.xserv
xserv stopped

Stop and disable a service (system domain):

$ sudo service stop --disable com.sys.xserv
xserv stopped and disabled

Restart a service:

$ service restart com.gui.xserv
xserv restarted

Enable a service (system domain):

$ sudo service enable com.sys.xserv
xserv enabled

Disable a service (system domain):

$ sudo service disable com.sys.xserv
xserv disabled

Configuration

Reverse domains can be defined in the file ~/.config/service.toml. When a service is referenced by name it will be resolved to a file in the current domain (system/gui) using the defined reverse domains. Services cannot be referenced by their name alone if no reverse domains are defined.

Example configuration:

reverse-domains = [
  "com.bar.foo",
  "org.bat.baz"
]

With this configuration, a service in the gui domain at ~/Library/LaunchAgents/com.bar.foo.xserv.plist can be targeted using only its name (xserv):

$ service start xserv
xserv started

License

service is released under the MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_service-2.0.3.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

py_service-2.0.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file py_service-2.0.3.tar.gz.

File metadata

  • Download URL: py_service-2.0.3.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for py_service-2.0.3.tar.gz
Algorithm Hash digest
SHA256 4b45ea97d996ce5594181899a18584e427a02dde84b95e201fc41f8f6f2e91aa
MD5 c309d853ed458f52522ed92662e61a01
BLAKE2b-256 f444146622a7d42a6d9625b59c7d47cbea6b803ec81bce008d224979d6178410

See more details on using hashes here.

File details

Details for the file py_service-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: py_service-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for py_service-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 484d1047e2d4c8c43e4d027bfd56122b51ed375862b26b72ae1343aaade8e21c
MD5 eea4b298760fb84868f52bc08a3b1f3a
BLAKE2b-256 f641ec66cb319fde24cebb66a73616b7a663df1569441af553426fd77149c988

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page