Skip to content

Instantly share code, notes, and snippets.

View clburlison's full-sized avatar

Clayton Burlison clburlison

View GitHub Profile
@gregneagle
gregneagle / fancy_defaults_read.py
Last active October 9, 2024 15:59
fancy_defaults_read.py: Reads a preference, prints its value, type, and where it is defined.
#!/usr/bin/python
import os
import sys
from CoreFoundation import (CFPreferencesAppValueIsForced,
CFPreferencesCopyAppValue,
CFPreferencesCopyValue,
kCFPreferencesAnyUser,
kCFPreferencesAnyHost,
@timsutton
timsutton / Popen_quit_by_pid.py
Last active June 27, 2024 09:08
Two examples of launching an application and quitting it using `NSRunningApplication.terminate()`
#!/usr/bin/python
# Alternate example using subprocess.Popen and finding the NSRunningApplication by PID
import AppKit
from time import sleep
from Foundation import NSURL
proc = subprocess.Popen(['/Applications/Xcode.app/Contents/MacOS/Xcode'])
@pudquick
pudquick / last.py
Last active July 26, 2024 08:19
Parsing utmp/utmpx record entries for login, logout, shutdown and reboot on macOS with python and ctypes
from ctypes import CDLL, Structure, POINTER, c_int64, c_int32, c_int16, c_char, c_uint32
from ctypes.util import find_library
import time
c = CDLL(find_library("System"))
# https://opensource.apple.com/source/Libc/Libc-1158.50.2/include/NetBSD/utmpx.h.auto.html
# https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man3/endutxent.3.html#//apple_ref/doc/man/3/endutxent
BOOT_TIME = 2
@joshua-d-miller
joshua-d-miller / 802.1x Fix.py
Last active January 18, 2019 12:46
When deploying an EAP-TLS profile for 802.1x Ethernet, this script will create a User Identity preference which will allow a logged in user to use any Ethernet interface that is connected to their machine.
#!/usr/bin/python
# pylint: disable=C0103, W0612, E1101, E0602, E0611
# pylint: disable=W0101, W0110, W0141
''''Fix 802.1x When Using Config Profiles and EAP-TLS'''
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This script will determine the profile ID that was used when
# installing the 802.1x Ethernet Identity preference and make
# a copy of the keychain entry to be used as a user identity preference
# so that any Ethernet can be used when a user is logged in. As of 10.12.3
#!/bin/bash
#
# Restore the machine's saved .MASManifest.
echo "===== restore_masmanifest ====="
VARDBPATH="{{target_volume}}/private/var/db"
@timsutton
timsutton / suppress_adobe_cc_signin.py
Last active February 7, 2017 23:02
Update all installed Adobe product install metadata to suppress the "Sign into Adobe CC" dialog box. This will likely make its way into https://github.com/timsutton/make-adobe-cc-license-pkg/
#!/usr/bin/python
# pylint: disable=locally-disabled, line-too-long
from __future__ import print_function
import os
import re
import sys
from glob import glob
'''Routines for manipulating the Dock'''
import os
import subprocess
from Foundation import NSURL
from Foundation import CFPreferencesAppSynchronize
from Foundation import CFPreferencesCopyAppValue
from Foundation import CFPreferencesSetAppValue
@gregneagle
gregneagle / munki_do.py
Created September 4, 2016 05:51
munki_do.py
#!/usr/bin/python
# encoding: utf-8
#
# Copyright 2009-2016 Greg Neagle.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@pudquick
pudquick / autotimezone.py
Last active February 11, 2020 15:55
Forcing automatic timezone discovery with pyobjc on OS X
# Tested on 10.11
# Assumes your network is in a state to actually do the discovery and that you have
# automatic timezone discovery enabled in Date & Time and Location services enabled
# (Generally this means wifi enabled on your device and network stack is up)
# For enabling location services and auto, check Allister's work here:
# https://gist.github.com/arubdesu/b72585771a9f606ad800
from Foundation import NSBundle
TZPP = NSBundle.bundleWithPath_("/System/Library/PreferencePanes/DateAndTime.prefPane/Contents/Resources/TimeZone.prefPane")
@timsutton
timsutton / rename_ios_devices.py
Created August 24, 2016 19:33
Simple script to rename connected iOS devices according to a CSV file, using Apple Configurator 2's cfgutil command.
#!/usr/bin/python
#
# Simple script to batch-rename attached iOS devices according to UUID to name mappings
# in a CSV file.
#
# Usage: rename_devices.py <csvfile>
#
#
# The CSV file should be comma-separated and contain at least the 'udid' and 'name'
# fields. Such a CSV can be exported from Configurator. Any additional field will simply