forked from cha63506/jss-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser-picture-change
More file actions
40 lines (40 loc) · 1.39 KB
/
user-picture-change
File metadata and controls
40 lines (40 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
#### Change the logged in users picture.
#### Run at login.
#### https://jamfnation.jamfsoftware.com/discussion.html?id=4332&postid=47631
# Goes good with a smart group based on this Extension Attribute
# https://github.com/quedayone/jamf-pro-scripts/blob/master/user-picture-report.sh
#### Will Pierce
#### August 11, 2014
#### Updated May 11, 2017
###Get the currently logged in user, in a more Apple approved way
user=`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");'`
#
# Full path to the icon / Picture you want to use
userPicture="/Library/User Pictures/changeME.png"
#
# Check if the Picture exists
echo
echo "Checking for:" $userPicture ". . ."
#
if [ -f "$userPicture" ]
# If exists then do this
then
echo
echo "found:" $userPicture
echo
echo "Changeing user icon to: " $userPicture
sudo -u $user dscl . delete /Users/$user jpegphoto
sudo -u $user dscl . delete /Users/$user Picture
dscl . create /Users/$user Picture "$userPicture"
else
# If does NOT exist then this this
echo
echo "Did NOT find:" $userPicture
fi
# print out the current use picture
echo
echo "$user" "Current user picture is:"
dscl . -read /Users/$user Picture | tail -1 | sed 's/^[ \t]*//'
echo
exit 0