Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.5: Change login panel background' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: Change login panel background
Authored by: morespace54 on Nov 15, '07 12:40:01PM
Here my upadated Applescript version to do just that.

Thanks so much to stormen for the "hard work"... ;)
http://www.macosxhints.com/article.php?story=20070610164328933

It's for 10.5 only (as there is no default "DesktopPicture" key in apple.com.loginwindow file in Leopard).




[code]
(*
----------------------------------------
Created by Stormen (Stormen81 AT gmail DOT com) on June 14, 2007
Modified by morespace on November 15, 2007 (for Mac OS 10.5)
----------------------------------------
*)



-- Get current loged in user
tell application "System Events" to set c_user to name of current user


-- Restore default pic or choose a new one
set my_result to display dialog ¬
¬
"Would you like to change the Login Background or restore the default one" with icon 1 buttons {"Restore", "Change"} default button 2

if button returned of my_result is "Restore" then
set chosen_pic to true
set my_choice to "Restore"
else
set chosen_pic to choose file with prompt "Please select a Background Image for the Login Window:" without invisibles

-- set the image path
set image_path to quoted form of (POSIX path of (chosen_pic as alias))
set ThePic to image_path
set my_choice to "Change"
end if




-- set the shell script for the user
if my_choice is "Restore" then
set myScript_s to " sudo defaults delete /Library/Preferences/com.apple.loginwindow \\DesktopPicture"
else
set myScript_s to "sudo defaults write /Library/Preferences/com.apple.loginwindow \\DesktopPicture " & ThePic
end if


-- user must enter the root password for the shell
set inpwd to display dialog "Enter Root password " default answer "" with icon 2 with hidden answer

if inpwd is not false then
-- set the user password
set pwd to text returned of inpwd
-- run the shell command
do shell script myScript_s password pwd with administrator privileges
--end if
end if



--Log Out prompt
set my_result to display dialog "Done!" & return & "Would you like to Log Out immediately?" with icon 2 buttons {"Cancel", "Log Out"} default button 2

if button returned of my_result is "Log Out" then
tell application "System Events"
keystroke "q" using command down & shift down & option down -- Log Out

end tell
end if

[/code]


There must be a zillion ways to make this more compact or more elegant but it works for me.

[ Reply to This | # ]