Created
October 18, 2022 13:06
-
-
Save dsumin/294450fcfee07b719bc6686e641cdc21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/osascript | |
# Required parameters: | |
# @raycast.schemaVersion 1 | |
# @raycast.title Set Selection as Desktop Picture | |
# @raycast.mode silent | |
# @raycast.packageName System | |
# | |
# Optional parameters: | |
# @raycast.icon 🖼️ | |
# | |
# Documentation: | |
# @raycast.description Set selected item in Finder as Desktop Picture | |
# @raycast.author Dmitry Sumin | |
# @raycast.authorURL https://github.com/dsumin | |
tell application "Finder" | |
-- get Finder selected items | |
set selectedFiles to selection | |
end tell | |
if count of selectedFiles > 1 then | |
error "Too many files were selected in the Finder!" | |
end if | |
set pictureFile to item 1 of selectedFiles | |
set the fileExtension to the name extension of pictureFile | |
-- check that a JPG file is selected | |
if fileExtension = "jpg" or fileExtension = "jpeg" | |
-- Set as Desktop Picture | |
tell application "Finder" | |
set desktop picture to pictureFile | |
end tell | |
else | |
error "Selected item is not a jpeg file" | |
end if | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment