gregneagle / pycreateuserpkg

Python tool to create macOS packages that create user accounts
Other
292 stars 44 forks source link

Feature request: Specify path to user picture #4

Open ejordansc opened 7 years ago

ejordansc commented 7 years ago

Would be convenient to be able to specify the path to an image that will be used as the user picture, similar to dscl . append /Users/foo picture "/path/to/image.png" or the -picture parameter in sysadminctl.

Thanks for considering!

gregneagle commented 7 years ago

Would accept a PR...

ramuntcho commented 7 years ago

Hi,

I wanted to ask the same thing. Here, in Geneva (Switzerland), we used CreateUserPkg for years to create users in our AutoDMG image for public schools. I test your script and it's working very well... but without the image.

What does it mean "a PR" (question from a french guy !!!)

Christian

gregneagle commented 7 years ago

A PR is a Pull Request. It means that if someone wanted to work on and contribute this functionality, I'd accept it.

@ejordansc @ramuntcho If you want a High Sierra-compatible version of CreateUserPkg, may I point you to https://github.com/gregneagle/CreateUserPkg ?

ramuntcho commented 7 years ago

Thanks for the quick answer. Unfortunately, I do not have the knowledge to do such a work :-((

There is actually no build of this new CreateUserPkg, right ?

gregneagle commented 7 years ago

No. You'd need to use Xcode and build it yourself.

ramuntcho commented 7 years ago

Ok, thanks. I have done it.

Lollaskates commented 5 years ago

This is actually super easy to bolt on with the way @gregneagle already designed this. In createuserpkg.py:

the new photo argument takes a path to a picture.

Dragao75 commented 5 years ago

I can confirm this works! Many thanks!

This is actually super easy to bolt on with the way @gregneagle already designed this. In createuserpkg.py:

  • add an import to the top:
from Foundation import NSData
  • add an additional optional arg:
    optional_user_options.add_option(
        '--photo', '-P', help='User photo. Path to jpeg file. Optional.')
  • add to the user_plist conditional section around L122
    if options.photo:
        try:
            user_data['image_data'] = NSData.dataWithContentsOfFile_(options.photo)
        except:
            print >> sys.stderr, "Could not convert provided photo NSData! (--photo)"

the new photo argument takes a path to a picture.