Skip to content

Instantly share code, notes, and snippets.

@scriptingosx
scriptingosx / com.scriptingosx.setdesktop.plist
Created September 14, 2018 12:56
simple LaunchAgent plist which re-sets the desktop at login with desktoppr https://github.com/scriptingosx/desktoppr
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.scriptingosx.setdesktop</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/desktoppr</string>
<string>/Library/Desktop Pictures/BoringBlueDesktop.png</string>
@scriptingosx
scriptingosx / checkmembers.sh
Created November 19, 2018 08:42
This script will loop through all users and use dseditgroup to check if they are a member of a given group (macOS)
#!/bin/bash
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
# checkusers
#
# written by Armin Briegel, Scripting OS X, 2018
#
# code is provided as is, with no guarantees that it will work etc.
# adapt and use as you will
@scriptingosx
scriptingosx / ard_installcheck.sh
Created January 14, 2016 11:43
Control ARD scripts
#!/bin/sh
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/munki export PATH
# this will run as a munki install_check script
# exit status of 0 means install needs to run
# exit status not 0 means no installation necessary
# adapted scripts from here: https://jamfnation.jamfsoftware.com/discussion.html?id=1989
@scriptingosx
scriptingosx / InstallerBuilds.sh
Created March 28, 2019 14:19
This script will print the build numbers of the macOS version from all installer apps
#!/bin/bash
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
installerBuildVersion() { # $1 path to the installer app
installerApp=${1:?"no path for installer"}
# echo "inspecting: $installerApp"
if [[ -d "$installerApp" ]]; then
identifier=$(/usr/libexec/PlistBuddy -c "print CFBundleIdentifier" "$installerApp/Contents/Info.plist")
@scriptingosx
scriptingosx / techs.sh
Last active October 15, 2019 13:49
Sample script to modify authorization db on macOS
#!/bin/bash
# modify the system.preferences right
/usr/bin/security authorizationdb write system.preferences <<EndOfPlist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>allow-root</key>
<true/>
@scriptingosx
scriptingosx / Build text link list from Tabs.applescript
Created January 5, 2016 09:10
Safari - Build Text Link List from Tabs
@scriptingosx
scriptingosx / desktop_picture_boringblue.mobileconfig
Last active November 18, 2020 22:58
sample configuration profile to set the desktop picture.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadDisplayName</key>
<string>Desktop</string>
<key>PayloadEnabled</key>
property defaultAccountName : "iCloud"
property defaultFolderName : "Saved iCloud Tabs"
global html
global processedURLs
on appendLineWithURLItem(urlItem)
my appendHTML(" <li>")
my appendHTML("<a href=\"" & |url| of urlItem & "\">")
my appendHTML(|Title| of urlItem)
@scriptingosx
scriptingosx / pwdf
Created February 8, 2017 09:27
pwdf - prints the path to the frontmost Finder window
#!/usr/bin/osascript
on run arguments
tell application "Finder"
-- no argument: get frontmost window or desktop
if (count of arguments) is 0 then
if (count of windows) is 0 then
set dir to (desktop as alias)
else
set dir to ((target of Finder window 1) as alias)
@scriptingosx
scriptingosx / .bash_profile
Created April 25, 2017 08:17
Sample Environment Variables in bash_profile/bashrc. (See http://scriptingosx.com/2017/04/on-bash-environment-variables/ for details)
# ENVIRONMENT VARIABLES
# add my ~/bin dir to path
PATH=${PATH}:~/bin
export PATH
# simple prompt
# default macOS prompt is: \h:\W \u\$
export PS1="\W \$ "