All Projects → homebysix → Docklib

homebysix / Docklib

Licence: other
Python module intended to assist IT administrators with manipulation of the macOS Dock.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Docklib

kinobi
An external patch definition server for Jamf Pro
Stars: ✭ 76 (+4.11%)
Mutual labels:  macadmin
pre-commit-macadmin
Pre-commit hooks for Mac admins.
Stars: ✭ 43 (-41.1%)
Mutual labels:  macadmin
Vfuse
Convert bootable DMG images for use in VMware Fusion
Stars: ✭ 392 (+436.99%)
Mutual labels:  macadmin
management tools
A collection of scripts and packages to simplify OS X management.
Stars: ✭ 93 (+27.4%)
Mutual labels:  macadmin
Installomator
Installation script to deploy standard software on Macs
Stars: ✭ 472 (+546.58%)
Mutual labels:  macadmin
sudoers manager
A standalone Python script to help administrators manage their sudoers file.
Stars: ✭ 28 (-61.64%)
Mutual labels:  macadmin
jamfpro-extension-attributes
🔍 A repository for EAs to use for reporting in the Jamf Pro Server
Stars: ✭ 30 (-58.9%)
Mutual labels:  macadmin
Fleet
A flexible control server for osquery fleets
Stars: ✭ 1,068 (+1363.01%)
Mutual labels:  macadmin
LAPSforMac
Local Administrator Password Solution for Mac
Stars: ✭ 29 (-60.27%)
Mutual labels:  macadmin
Munkiadmin
macOS app for managing Munki repositories
Stars: ✭ 310 (+324.66%)
Mutual labels:  macadmin
diskspace
macOS command line tool to return the available disk space on APFS volumes
Stars: ✭ 123 (+68.49%)
Mutual labels:  macadmin
jamfscripts
Scripts I use non API related
Stars: ✭ 15 (-79.45%)
Mutual labels:  macadmin
GNU-bash-mac-installer
Downloads and builds a Mac package installer for GNU bash 5
Stars: ✭ 17 (-76.71%)
Mutual labels:  macadmin
blade runner
Blade Runner is a Jamf Pro based Python application that automates and implements a framework to offboard, secure erase and document deprecated Mac systems.
Stars: ✭ 24 (-67.12%)
Mutual labels:  macadmin
Outset
Automatically process packages, profiles, and scripts during boot, login, or on demand.
Stars: ✭ 478 (+554.79%)
Mutual labels:  macadmin
cleanup manager
Cleanup Manager helps you clean up folders on your Mac's hard drive.
Stars: ✭ 22 (-69.86%)
Mutual labels:  macadmin
mac scripts
A collection of scripts used to Manage Mac OS X computers.
Stars: ✭ 38 (-47.95%)
Mutual labels:  macadmin
Jamf Interaction Toolkit
Standardized UEX Toolkit to display dialog and support postponing running policies.
Stars: ✭ 58 (-20.55%)
Mutual labels:  macadmin
Macvars
command library for scripting osx
Stars: ✭ 34 (-53.42%)
Mutual labels:  macadmin
Splashbuddy
Onboarding splash screen for Jamf Pro. Improves DEP provisioning for macOS.
Stars: ✭ 309 (+323.29%)
Mutual labels:  macadmin

docklib

This is a Python module intended to assist IT administrators with manipulation of the macOS Dock.

Originally created as a Gist by @gregneagle, this fork has been modified to include support for some additional Dock features, and has been packaged for multiple distribution options.

Installation

There are multiple methods of installing docklib, depending on how you plan to use it.

Package installer

You can use the included build_pkg.sh script to build a macOS installer .pkg file. You can use this package to install docklib on your own Mac, or deploy the package using a tool like Jamf or Munki to install docklib on managed devices.

To run the script, cd to a local clone of this repository, then run:

./build_pkg.sh

The resulting pkg will be built in a temporary folder and shown in the Finder.

NOTE: The default install destination is /Library/Python/2.7/site-packages/docklib, which makes docklib available to the built-in macOS Python 2.7 framework. If you leverage a different Python installation, you'll need to modify this path in the build_pkg.sh script prior to building the installer package.

Pip

Docklib has been published to PyPI in order to make it available for installation using pip.

pip install docklib

This method is not intended to be used directly on managed devices, but it could be leveraged alongside a custom Python framework (like one built with macadmins/python or relocatable-python) using a requirements file.

Manual

Another method of using docklib is to simply place the docklib.py file in the same location as the Python script(s) you use to manipulate the macOS dock. Some examples of such scripts are included below.

Examples

Add Microsoft Word to the right side of the Dock

from docklib import Dock

dock = Dock()
item = dock.makeDockAppEntry("/Applications/Microsoft Word.app")
dock.items["persistent-apps"].append(item)
dock.save()

Add Microsoft Word to the left side of the Dock

from docklib import Dock

dock = Dock()
item = dock.makeDockAppEntry("/Applications/Microsoft Word.app")
dock.items["persistent-apps"] = [item] + dock.items["persistent-apps"]
dock.save()

Replace Mail.app with Outlook in the Dock

from docklib import Dock

dock = Dock()
dock.replaceDockEntry("/Applications/Microsoft Outlook.app", "Mail")
dock.save()

Remove Calendar from the Dock

from docklib import Dock

dock = Dock()
dock.removeDockEntry("Calendar")
dock.save()

Display the current orientation of the Dock

from docklib import Dock

dock = Dock()
print dock.orientation

Make the Dock display on the left, and enable autohide

from docklib import Dock

dock = Dock()
dock.orientation = "left"
dock.autohide = True
dock.save()

Add the Documents folder to the right side of the Dock

Displays as a stack to the right of the Dock divider, sorted by modification date, that expands into a fan when clicked. This example checks for the existence of the Documents item and only adds it if it's not already present.

import os
from docklib import Dock

dock = Dock()
if dock.findExistingLabel("Documents", section="persistent-others") == -1:
    item = dock.makeDockOtherEntry(
        os.path.expanduser("~/Documents"), arrangement=3, displayas=1, showas=1
    )
    dock.items["persistent-others"] = [item] + dock.items["persistent-others"]
    dock.save()

Add a URL to the right side of the Dock

Displays as a globe to the right of the Dock divider, that launches a URL in the default browser when clicked. This example checks for the existence of the Documents item and only adds it if it's not already present.

import os
from docklib import Dock

dock = Dock()
if dock.findExistingLabel("GitHub", section="persistent-others") == -1:
    item = dock.makeDockOtherURLEntry("https://www.github.com/", label="GitHub")
    dock.items["persistent-others"] = [item] + dock.items["persistent-others"]
    dock.save()

Specify a custom Dock for the local IT technician account

import os
from docklib import Dock

tech_dock = [
    "/Applications/Google Chrome.app",
    "/Applications/App Store.app",
    "/Applications/Managed Software Center.app",
    "/Applications/System Preferences.app",
    "/Applications/Utilities/Activity Monitor.app",
    "/Applications/Utilities/Console.app",
    "/Applications/Utilities/Disk Utility.app",
    "/Applications/Utilities/Migration Assistant.app",
    "/Applications/Utilities/Terminal.app",
]
dock = Dock()
dock.items["persistent-apps"] = []
for item in tech_dock:
    if os.path.exists(item):
        item = dock.makeDockAppEntry(item)
        dock.items["persistent-apps"].append(item)
dock.save()

Or if you prefer using a list comprehension:

import os
from docklib import Dock

tech_dock = [
    "/Applications/Google Chrome.app",
    "/Applications/App Store.app",
    "/Applications/Managed Software Center.app",
    "/Applications/System Preferences.app",
    "/Applications/Utilities/Activity Monitor.app",
    "/Applications/Utilities/Console.app",
    "/Applications/Utilities/Disk Utility.app",
    "/Applications/Utilities/Migration Assistant.app",
    "/Applications/Utilities/Terminal.app",
]
dock = Dock()
dock.items["persistent-apps"] = [
    dock.makeDockAppEntry(item) for item in tech_dock if os.path.exists(item)
]
dock.save()
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].