Skip to content

Instantly share code, notes, and snippets.

View soundsnw's full-sized avatar

soundsnw

View GitHub Profile
#!/bin/bash
# macOS printer script: if color queue is selected, revert to grayscale
# Get logged in user
loggedInUser=$(/usr/bin/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");')
# If the print queues have been deleted, re-add them
@soundsnw
soundsnw / Preload Chrome bookmarks on macOS
Last active June 10, 2019 22:01
preload-chrome-bookmarks.sh
#!/bin/bash
# Output Chrome Bookmarks to /Library/Google/bookmarks.html
if [ ! -d "/Library/Google" ]
then
mkdir "/Library/Google"
fi
(
@soundsnw
soundsnw / standard-user-access.sh
Created June 11, 2019 12:33
Give macOS standard users access to networking, printing and more
#!/bin/sh
#
# Provides standard user access to preference panels they would expect to be able to access, and might need access to.
#
# Provides standard users access to system preferences
/usr/bin/security authorizationdb write system.preferences allow
#!/bin/bash
loggedInUser=$( /usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | awk -F’: ‘ ‘/[[:space:]]+Name[[:space:]]:/ { if ( $2 != "loginwindow" ) { print $2 }}’ )
sudo -u $loggedInUser chflags -R nouchg /Users/$loggedInUser
diskutil resetUserPermissions / $loggedInUser
exit 0
@soundsnw
soundsnw / approve-mau-daemon.sh
Created July 18, 2019 21:08
approve-mau-daemon.sh
#!/bin/bash
# Pre-approve the popup that asks the user to approve running the MAU daemon
# Get the logged in user
loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
# Register MAU
<?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>forceLimitAdTracking</key>
<true/>
<key>AD_DEVICE_IDFA</key>
<string>00000000-0000-0000-0000-000000000000</string>
</dict>
</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>allowDiagnosticSubmission</key>
<false/>
</dict>
</plist>
#!/bin/bash
# Enable location services and automatic time zone configuration
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1
uuid=$(/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57)
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.$uuid LocationServicesEnabled -int 1
#!/bin/bash
# Enable location services and automatic time zone configuration
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1
uuid=$(/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57)
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.$uuid LocationServicesEnabled -int 1
#!/bin/bash
# Set time zone and enable network time server
sudo /usr/sbin/systemsetup -setusingnetworktime off
sudo /usr/sbin/systemsetup -settimezone "Europe/London"
sudo /usr/sbin/systemsetup -setnetworktimeserver time.euro.apple.com