Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AndrewWCarson/8659ae2578aa00148f3a4c2124440c05 to your computer and use it in GitHub Desktop.
Save AndrewWCarson/8659ae2578aa00148f3a4c2124440c05 to your computer and use it in GitHub Desktop.
Enable Current User to Manage Print Queue
#!/bin/bash
user=$(/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");')
dseditgroup -o edit -a "$(user)" _lpoperator
@AndrewWCarson
Copy link
Author

A few changes from the original. All minor improvements.

  1. Grabbing the login user the "correct" way. See Ben Toms' article here: https://macmule.com/2014/11/19/how-to-get-the-currently-logged-in-user-in-a-more-apple-approved-way/
  2. Removed sudo from the dseditgroup command as this will be run as root from a mgmt platform like Addigy.
  3. Removed exit 0 as it's redundant if dseditgroup succeeds.
  4. Wrapped $(user) in double quotes to prevent globbing problems (username's shouldn't have spaces or special characters, but better safe than sorry.).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment