Skip to main content

Make executable files run after user login

Project description

pyautostart

PyAutostart is a Python library for making all sorts of executables files be run after the user logged in into his computer for macOS, Linux and Windows.

Please note that Linux is not yet being supported.

Installation

Use the package manager pip to install PyAutostart.

pip install pyautostart

Usage

Platform independent

Make a file be run after login

The options dict must contain args which has to be a list that usually contain the path to the executable file. The name parameter of autostart.enable sets the name of the file which will then be created by the platform dependent implementation.

from pyautostart import SmartAutostart

autostart = SmartAutostart()
options = {
    "args": [
        "/path/to/executable/file"
    ]
}
autostart.enable(name="com.example.myapplication", options=options)

Disable automatic execution

Calling autostart.disable will delete the file which is being created by autostart.enable. The name parameter has to be the one set during autostart.enable.

from pyautostart import SmartAutostart

autostart = SmartAutostart()
autostart.disable(name="com.example.myapplication")

macOS

Make a file be run after login

The options dict contains the configuration for launchd. For a list of all valid options and their meanings, go to the Wikipedia article of launchd. The name parameter of autostart.enable sets the name of the file which will be stored in /Users/<username>/Library/LaunchAgents if not changed.

from pyautostart import MacAutostart

autostart = MacAutostart()
options = {
    "Label": "Name of",
    "ProgramArguments": [
        "python3",
        "/path/to/your/file.py"
    ]
}
autostart.enable(name="com.example.myapplication", options=options)

Disable automatic execution

Calling autostart.disable will delete the file which is being created by autostart.enable. The name parameter has to be the one set during autostart.enable.

from pyautostart import MacAutostart

autostart = MacAutostart()
autostart.disable(name="com.example.myapplication")

Windows

Make a file be run after login

The options dict must contain executable, which has to store to path to your executable file. autostart.enable will then create a .bat file which by default contains start "" <executable>".

This file will be stored inside C:\\Users\\<username>\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup.

If you want to replace the start "" command. Add command: "<command>" to the options dict.

from pyautostart import WindowsAutostart

autostart = WindowsAutostart()
options = {
    "executable": "C:\\path\\to\\your\\executable",
}
autostart.enable(name="com.example.myapplication", options=options)

Disable automatic execution

Calling autostart.disable will delete the file which is being created by autostart.enable. The name parameter has to be the one set during autostart.enable.

from pyautostart import WindowsAutostart

autostart = WindowsAutostart()
autostart.disable(name="com.example.myapplication")

Linux

Linux is not supported yet.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

GNU GENERAL PUBLIC 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

pyautostart-0.1.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyautostart-0.1.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file pyautostart-0.1.0.tar.gz.

File metadata

  • Download URL: pyautostart-0.1.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.1

File hashes

Hashes for pyautostart-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2a3b2b4ee446ca1517846a304fb68cf2d302e3f5101f8e4af8bc5d195a03744d
MD5 bdce76dd6a352de445f46fb2d297cda3
BLAKE2b-256 eb51ff44d8c4552c335e9ffcb76bf0b773fa123745e56efb8211821bc2b3a1fc

See more details on using hashes here.

File details

Details for the file pyautostart-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyautostart-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.1

File hashes

Hashes for pyautostart-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0e2fd37b73c89d406b31a84876f08a1c6143c040b7d2e909c40a61a8d6dfaba
MD5 1d5722e56cf96927283acf6f3de4ad55
BLAKE2b-256 24e985af7e147c7161d1bc804c1af1f13a5312c517a5c8b319d4830add62a34a

See more details on using hashes here.

Supported by

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