shell 每天获取必应背景图并设置为mac桌面

  1 #!/bin/bash
  2 # 提取壁纸图片URL
  3 url=$(expr "$(curl https://www4.bing.com/ |grep g_img)" : ".*g_img={url: "(.*)",id.*")
  4 # 去除url中的斜杠“”
  5 url="http://cn.bing.com${url//\/}"
  6 # 提取图片名称
  7 filename=$(expr "$url" : ".*/(.*)")
  8 # 本地图片地址-当前用户下缺省图片目录
  9 localpath="/data/Pictures/$filename"
 10 # 下载图片至本地
 11 curl --connect-timeout 2 -m 5 -o $localpath  $url
 12 # 调用Finder应用切换桌面壁纸
 13 osascript -e "tell application "Finder" to set desktop picture to POSIX file "$localpath""
原文地址:https://www.cnblogs.com/oceanL/p/9373271.html