Skip to content

Instantly share code, notes, and snippets.

Armin Briegel scriptingosx

View GitHub Profile
@scriptingosx
scriptingosx / InstallerBuilds.sh
Created Mar 28, 2019
This script will print the build numbers of the macOS version from all installer apps
View InstallerBuilds.sh
#!/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 / checkmembers.sh
Created Nov 19, 2018
This script will loop through all users and use dseditgroup to check if they are a member of a given group (macOS)
View checkmembers.sh
#!/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 / allusers.sh
Created Nov 19, 2018
This script will try to determine a list of members of the given group and list all members (macOS)
View allusers.sh
#!/bin/bash
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
# allusers.sh
#
# 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 / userpictures.sh
Created Oct 23, 2018
sample script that loops through all users and sets a different user picture.
View userpictures.sh
#!/bin/bash
# create an array from all images in the User Pictures subfolders
IFS=$'\n' read -rd '' -a pictures <<< "$(find '/Library/User Pictures/Fun' -name *.tif -print )"
# loop through all users
picIndex=0
@scriptingosx
scriptingosx / setdesktop.sh
Created Sep 18, 2018
Sample script to set the desktop with desktoppr
View setdesktop.sh
#!/bin/bash
##
## sets the desktop using `desktoppr`
##
# set the path to the desktop image file here
picturepath="/Library/Desktop Pictures/BoringBlueDesktop.png"
@scriptingosx
scriptingosx / com.scriptingosx.setdesktop.plist
Created Sep 14, 2018
simple LaunchAgent plist which re-sets the desktop at login with desktoppr https://github.com/scriptingosx/desktoppr
View com.scriptingosx.setdesktop.plist
<?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 / desktop_picture_boringblue.mobileconfig
Last active Sep 12, 2018
sample configuration profile to set the desktop picture.
View desktop_picture_boringblue.mobileconfig
<?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>
@scriptingosx
scriptingosx / EmptyProfile.mobileconfig
Last active Aug 17, 2018
Empty Mobile Configuration file suitable as a placeholder for certain operations
View EmptyProfile.mobileconfig
<?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>PayloadDescription</key>
<string>Empty Profile that controls nothing</string>
<key>PayloadDisplayName</key>
@scriptingosx
scriptingosx / bashdisplay.sh
Last active Nov 1, 2018
bash functions using osascript to use some user interaction on macOS
View bashdisplay.sh
#!/bin/bash
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
consoleUser() {
python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");'
}
displaydialog() { # $1: message
message=${1:-"Message"}
@scriptingosx
scriptingosx / techs.sh
Last active Dec 26, 2018
Sample script to modify authorization db on macOS
View techs.sh
#!/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/>
You can’t perform that action at this time.