Tuesday, September 27, 2022

#1 2022-06-15 06:47:30 pm

Titanium
Member
From:: ~/Desktop
Registered: 2005-08-22
Posts: 86
Website

Change the image of the Login window

Hello,

AppleScriptObjC app in Xcode...
I will change the image of the Login window.
This image is named lockscreen.png located in the /Library/Caches/Desktop Pictures/UUID_User (for example DA6D67A6-8E07-43D3-90E1-CE558271D864) folder.

For the actual user, no problem.

Applescript:

set adminShortName to short user name of (system info)
set uuiduser to do shell script "dscl . -read /Users/" & adminShortName & " GeneratedUID | awk '{print $2}'"
set newImageLogin to choose file default location ((path to desktop pictures folder from system domain) as alias)
set newImageLogin to (POSIX path of newImageLogin)
set newImagePath to "/Library/Caches/'Desktop Pictures'/" & uuiduser & "/lockscreen.png"
do shell script "rm -rf /Library/Caches/'Desktop Pictures'/" & uuiduser & "/lockscreen.png" with administrator privileges
do shell script "cp " & quoted form of newImageLogin & space & newImagePath

With many users, I don't know how make that for all users.

I can see the folder names of each user...

Applescript:

set listlockscreen to list folder (text 1 thru -2 of boot volume of (system info)) & ":Library:Caches:Desktop Pictures:"

... but after...? hmm


iMac 27" 3,6 Ghz - MacBook Pro 14" M1 - MacOS  Monterey
https://www.titanium-software.fr

Offline

 

#2 2022-06-16 01:53:09 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11774
Website

Re: Change the image of the Login window

AppleScriptObjC is not needed.

list folder accepts also POSIX paths so it's pretty easy to copy the pictures in a repeat loop.
It's not needed either to remove the file, cp overwrites an existing file.

Applescript:


set userUUIDs to list folder "/Library/Caches/Desktop Pictures"
set newImageLogin to POSIX path of (choose file default location path to desktop pictures folder from system domain)
repeat with uuiduser in userUUIDs
   set newImagePath "/Library/Caches/Desktop Pictures/" & uuiduser & "/lockscreen.png"
   do shell script "cp " & quoted form of newImageLogin & space & quoted form of newImagePath with administrator privileges
end repeat


regards

Stefan

Offline

 

#3 2022-06-17 09:03:23 am

Titanium
Member
From:: ~/Desktop
Registered: 2005-08-22
Posts: 86
Website

Re: Change the image of the Login window

Thanks a lot Stefan!! smile

It's necessary to delete the file before, because I lock the file (with the chflags command). cp cannot overwrite a locked file. ;-)


iMac 27" 3,6 Ghz - MacBook Pro 14" M1 - MacOS  Monterey
https://www.titanium-software.fr

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)