Skip to content

Instantly share code, notes, and snippets.

View jacobsalmela's full-sized avatar
:octocat:
To all that makes us unique

Jacob Salmela jacobsalmela

:octocat:
To all that makes us unique
View GitHub Profile
@jacobsalmela
jacobsalmela / create_users.py
Created March 3, 2015 20:20
Create users via the JSS based on the computer name.
#!/usr/bin/python
#----------AUTHOR------------
# Jacob Salmela
# 20 February 2014
# Updated: 2014-12-11
#-----------IMPORTS----------
from os import system
from subprocess import call
from socket import gethostname
@jacobsalmela
jacobsalmela / set_dock.py
Created March 3, 2015 20:15
Single script to set the dock for multiple users
#!/usr/bin/python
#----------AUTHOR------------
# Jacob Salmela
# 3 January 2014
#-----------IMPORTS----------
from subprocess import call
from platform import mac_ver
from re import findall
from socket import gethostname
@jacobsalmela
jacobsalmela / enforceMacHD.sh
Created February 26, 2015 20:03
Reset the volume name to "Macintosh HD" if it is different.
#!/bin/bash
volumeName=$(diskutil info / | awk '/Volume Name/ {print substr ($0, index ($0,$3))}')
echo "Current volume name: $volumeName"
# If the volume is not named Macintosh HD
if [ "$volumeName" != "Macintosh HD" ];then
# Rename it
diskutil renameVolume "$volumeName" "Macintosh HD"
volumeName=$(diskutil info / | awk '/Volume Name/ {print substr ($0, index ($0,$3))}')
echo "Root volume is now named: $volumeName"
@jacobsalmela
jacobsalmela / removeSSID.sh
Created February 26, 2015 20:01
Remove an SSID from the preferred networks list
#!/bin/bash
#----------VARIABLES---------
undesiredNetwork="SSID-To-Remove"
wifiOrAirport=$(/usr/sbin/networksetup -listallnetworkservices | grep -Ei '(Wi-Fi|AirPort)')
echo $wifiOrAirport
wirelessDevice=$(networksetup -listallhardwareports | awk "/$wifiOrAirport/,/Device/" | awk 'NR==2' | cut -d " " -f 2)
echo $wirelessDevice
#-----------SCRIPT-----------
# Remove the SSID from the list of preferred networks
@jacobsalmela
jacobsalmela / enforceWallpaper.py
Created February 17, 2015 13:35
Script that enforces the wallpaper on Mavericks and Yosemite
#!/usr/bin/python
# Universal enforce wallpaper script for 10.9 and up
# Based on https://gist.github.com/gregneagle/6957826#file-gistfile1-py
from AppKit import NSWorkspace, NSScreen
from Foundation import NSURL
from platform import mac_ver
from subprocess import call
from os import system
from os import getlogin
import sqlite3
@jacobsalmela
jacobsalmela / com.domain.enforceWallpaper
Created February 17, 2015 13:30
Launch Agent to run a script that enforces the wallpaper on Mavericks and Yosemite
<?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>org.domain.enforceWallpaper</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/triggers/enforceWallpaper.py</string>
</array>
@jacobsalmela
jacobsalmela / siriControlsSpotify.scpt
Created January 30, 2015 15:33
April fool's Spotify script
repeat
tell application "System Events" to delay 3.0
tell application "System Events" to set currentApp to name of first process where frontmost is true
if currentApp is "Spotify" then
try
-- Create a random number to do one of three things
set randomNum to random number from 1 to 3
if randomNum is 1 then
tell application "Spotify" to pause
@jacobsalmela
jacobsalmela / suckSafari.scpt
Created January 27, 2015 21:14
April fools Safari "suck" prank
repeat
tell application "System Events" to delay 3.0
tell application "System Events" to set currentApp to name of first process where frontmost is true
if currentApp is "Safari" then
try
tell application "System Events"
tell process "Safari"
key down {shift}
-- Click the minimize button
@jacobsalmela
jacobsalmela / aprilFoolsMoveMouse.sh
Created January 27, 2015 19:20
April Fools to move mouse to random positions at random intervals
#!/bin/bash
# Randomly moves the mouse and/or clicks
#
# Random delay (in seconds) to trigger an action
function random_delay()
{
RANGE=180
delayInSeconds=$RANDOM
let "delayInSeconds %=$RANGE"
@jacobsalmela
jacobsalmela / unshare_all_printers.sh
Last active August 20, 2022 13:57 — forked from rmanly/unshare_all_printers.bash
Unshares printers and disables Printer Sharing
#!/bin/bash
#while read -r _ _ printer _; do
# /usr/sbin/lpadmin -p "${printer/:}" -o printer-is-shared=false
#done < <(/usr/bin/lpstat -v)
# Slightly faster when there are a lot of printers
lpstat -p | grep printer | cut -d" " -f2 | xargs -I{} lpadmin -p {} -o printer-is-shared=false
# Also disable Printer Sharing in the Sharing pane
cupsctl --no-share-printers