Skip to content

Instantly share code, notes, and snippets.

@forkloop
Last active December 3, 2024 11:20
Show Gist options
  • Select an option

  • Save forkloop/163739904e4d4647ce04 to your computer and use it in GitHub Desktop.

Select an option

Save forkloop/163739904e4d4647ce04 to your computer and use it in GitHub Desktop.
Set desktop background to given a picture URL
#!/usr/bin/osascript
on run(argv)
if count of argv is equal to 0 then
set msg to "Usage\n\tset_bg URI"
return msg
end if
set uri to item 1 of argv
set dest to do shell script "echo /tmp/$(date +%Y%m%d%H%M%S).jpg"
set cmd to "curl -L " & uri & " > " & dest
do shell script cmd
tell application "Finder"
set desktop picture to POSIX file dest
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment