{"id":18013085,"url":"https://github.com/miccal/bing-wallpaper-applescript","last_synced_at":"2026-03-11T23:02:57.298Z","repository":{"id":103433179,"uuid":"427379350","full_name":"miccal/bing-wallpaper-applescript","owner":"miccal","description":"Set the Bing image of the day using any choice of a valid market code as your desktop wallpaper using AppleScript and the Shortcuts.app.","archived":false,"fork":false,"pushed_at":"2025-11-11T10:53:39.000Z","size":166,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-11T12:20:03.644Z","etag":null,"topics":["applescript","bing","curl","grep","sed"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miccal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-11-12T14:00:28.000Z","updated_at":"2025-11-11T10:53:44.000Z","dependencies_parsed_at":"2025-06-12T10:38:17.891Z","dependency_job_id":null,"html_url":"https://github.com/miccal/bing-wallpaper-applescript","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/miccal/bing-wallpaper-applescript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miccal%2Fbing-wallpaper-applescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miccal%2Fbing-wallpaper-applescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miccal%2Fbing-wallpaper-applescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miccal%2Fbing-wallpaper-applescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miccal","download_url":"https://codeload.github.com/miccal/bing-wallpaper-applescript/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miccal%2Fbing-wallpaper-applescript/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30406400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T22:36:59.286Z","status":"ssl_error","status_checked_at":"2026-03-11T22:36:57.544Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["applescript","bing","curl","grep","sed"],"created_at":"2024-10-30T03:19:48.136Z","updated_at":"2026-03-11T23:02:57.290Z","avatar_url":"https://github.com/miccal.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Set The Bing Image Of The Day As Your Desktop Wallpaper\n\nThis AppleScript fetches the Bing image of the day using any choice of a valid market code and sets it as your desktop wallpaper.\n\nThe AppleScript may then be added to the `Shortcuts.app` in macOS and run from the Menu Bar.\n\nUsing the Japanese market code `ja-JP` as an example, the direct download link for the Bing image of the day can be found from\n\n`http://www.bing.com/HPImageArchive.aspx?format=js\u0026uhd=1\u0026idx=0\u0026n=1\u0026mkt=ja-JP`\n\nwhere:\n\n* `format` can take the values `js` (short for `json`), `hp` (short for `html`), `xml` (the default) and `rss`;\n* `uhd` (for pictures in ultra high definition) can take the values `0` and `1`, with `0` meaning fetch the standard full high definition resolution version of the image (normally a resolution of 1920x1080) and `1` meaning fetch the ultra high definition resolution version of the image (which can vary from a minimum resolution of 1920x1080 -- for example, the image obtained in the example below is 5349×3009);\n* Note that other modes are `fhd` (for pictures in full HD), `mbl` (for vertical screens like a mobile phone) and `mrk` (for pictures with the Bing logo watermark); \n* `idx` is the number days previous to the present day, with `0` meaning the present day;\n* `n` is the number of images to fetch previous to the day given by `idx`, with `1` meaning fetch the one image for day `idx`; and\n* `mkt` is the market code. There are currently a total of 38 market codes as listed [here](https://learn.microsoft.com/en-us/previous-versions/bing/search-apis/bing-web-search/reference/market-codes), and at present (November 2025) only the market codes `de-DE`, `en-CA`, `en-GB`, `en-IN`, `en-US`, `es-ES`, `fr-CA`, `fr-FR`, `it-IT`, `ja-JP`, `ko-KR` (sometimes), `no-NO` (sometimes), `pt-BR` and `zh-CN` have their own localised versions. Other market codes are set as being the “Rest of the World” (with the generic market code `ROW`).\n\n## Details\n\nThe AppleScript basically works by first downloading the Bing image of the day and saving it to `~/Downloads/bing_image_of_the_day.jpg`, then setting this image as the desktop wallpaper.\n\nAgain using the Japanese market code `ja-JP` as an example, the Bing image of the day can be downloaded with the following one-liner CLI command\n```\ncurl --silent \"http://www.bing.com/$(curl --silent \"http://www.bing.com/HPImageArchive.aspx?format=js\u0026uhd=1\u0026idx=0\u0026n=1\u0026mkt=ja-JP\" | grep --only-matching \"\\\"url\\\":\\\"\\/.*\\.jpg\" | sed 's/\"url\":\"\\///g')\" \u003e ~/Downloads/bing_image_of_the_day.jpg\n```\n\n\u0026nbsp;\n\nLet's unpack what this one-liner CLI command does ...\n\n### Step 1\n\nThe command\n\n```\ncurl --silent \"http://www.bing.com/HPImageArchive.aspx?format=js\u0026uhd=1\u0026idx=0\u0026n=1\u0026mkt=ja-JP\"\n```\n\noutputs the information for the current image of the day, like so:\n\n`{\"images\":[{\"startdate\":\"20211120\",\"fullstartdate\":\"202111201500\",\"enddate\":\"20211121\",\"url\":\"/th?id=OHR.ElephantGiving_JA-JP6387498046_UHD.jpg\u0026rf=LaDigue_UHD.jpg\u0026pid=hp\u0026w=1920\u0026h=1080\u0026rs=1\u0026c=4\",\"urlbase\":\"/th?id=OHR.ElephantGiving_JA-JP6387498046\",\"copyright\":\"アフリカゾウの家族, ケニア （© Yva Momatiuk and John Eastcott/Minden Pictures）\",\"copyrightlink\":\"https://www.bing.com/search?q=%E3%82%A2%E3%83%95%E3%83%AA%E3%82%AB%E3%82%BE%E3%82%A6+%E5%AE%B6%E6%97%8F\u0026form=hpcapt\u0026filters=HpDate%3a%2220211120_1500%22\",\"title\":\"今日は「家族の日」\",\"quiz\":\"/search?q=Bing+homepage+quiz\u0026filters=WQOskey:%22HPQuiz_20211120_ElephantGiving%22\u0026FORM=HPQUIZ\",\"wp\":true,\"hsh\":\"1870702a47d30be6d7aee03f41b36604\",\"drk\":1,\"top\":1,\"bot\":1,\"hs\":[]}],\"tooltips\":{\"loading\":\"読み込み中...\",\"previous\":\"前の画像へ\",\"next\":\"次の画像へ\",\"walle\":\"この画像を壁紙としてダウンロードすることはできません。\",\"walls\":\"この画像をダウンロードできます。画像の用途は壁紙に限定されています。\"}}`\n\n### Step 2\n\nThe next part, namely\n\n`grep --only-matching \"\\\"url\\\":\\\"\\/.*\\.jpg\"`\n\nthen pulls out relevant part of the `url` location from the previous output, so that the command\n\n```\ncurl --silent \"http://www.bing.com/HPImageArchive.aspx?format=js\u0026uhd=1\u0026idx=0\u0026n=1\u0026mkt=ja-JP\" | grep --only-matching \"\\\"url\\\":\\\"\\/.*\\.jpg\"\n```\n\noutputs\n\n`\"url\":\"/th?id=OHR.ElephantGiving_JA-JP6387498046_UHD.jpg\u0026rf=LaDigue_UHD.jpg`\n\n### Step 3\n\nThe next part, namely\n\n`sed 's/\"url\":\"\\///g'`\n\nthen removes the `\"url\":\"/` part of the previous output, so that the command\n\n```\ncurl --silent \"http://www.bing.com/HPImageArchive.aspx?format=js\u0026uhd=1\u0026idx=0\u0026n=1\u0026mkt=ja-JP\" | grep --only-matching \"\\\"url\\\":\\\"\\/.*\\.jpg\" | sed 's/\"url\":\"\\///g'\n```\n\noutputs\n\n`th?id=OHR.ElephantGiving_JA-JP6387498046_UHD.jpg\u0026rf=LaDigue_UHD.jpg`\n\n### Step 4\n\nWe then have the required direct download link, namely\n\n`http://www.bing.com/th?id=OHR.ElephantGiving_JA-JP6387498046_UHD.jpg\u0026rf=LaDigue_UHD.jpg`\n\nand the last step is to download the image and save it as `~/Downloads/bing_image_of_the_day.jpg`, which is accomplished with the final one-liner CLI command shown above, and the resultant image is illustrated below:\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"2000\" alt=\"th\" src=\"https://user-images.githubusercontent.com/6127163/142742880-4e556123-1983-4c70-aa05-64e16654063e.jpeg\"\u003e\n\u003c/p\u003e\n\nNote that the `\u0026rf=LaDigue_UHD.jpg` part of the direct download link is a \"fallback\" image if the actual image `ElephantGiving_JA-JP6387498046_UHD.jpg` is not available. So if the downloaded image is the one illustrated below, something is wrong!\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"2000\" alt=\"th\" src=\"https://user-images.githubusercontent.com/6127163/142700897-71e19683-b2e5-4e06-8083-56f332d0716a.png\"\u003e\n\u003c/p\u003e\n\nTo use this one-liner CLI command in AppleScript, it is necessary to escape some characters (namely the `\"`'s and `\\`'s). The following is an AppleScript that sends this one-liner CLI command to `Terminal.app`:\n```\ntell application \"Terminal\"\n\tdo script \"curl --silent \\\"http://www.bing.com/$(curl --silent \\\"http://www.bing.com/HPImageArchive.aspx?format=js\u0026uhd=1\u0026idx=0\u0026n=1\u0026mkt=ja-JP\\\" | grep --only-matching \\\"\\\\\\\"url\\\\\\\":\\\\\\\"\\\\/.*\\\\.jpg\\\" | sed 's/\\\"url\\\":\\\"\\\\///g')\\\" \u003e ~/Downloads/bing_image_of_the_day.jpg\" in front window\nend tell\n```\n\n## The Full AppleScript\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"2000\" alt=\"Screen Shot 2021-11-20 at 07 17 02\" src=\"https://user-images.githubusercontent.com/6127163/142703032-e562914c-f3d7-427b-abe4-e8b9d0c99fd0.png\"\u003e\n\u003c/p\u003e\n\n\u0026nbsp;\n\nLet's unpack what this AppleScript does ...\n\n### Step 1\n\nThe first part of the AppleScript, namely\n\n```\nset market_code_choices to {\"da-DK, Denmark, Danish\", \"de-AT, Austria, German\", \"de-CH, Switzerland, German\", \"de-DE, Germany, German\", \"en-AU, Australia, English\", \"en-CA, Canada, English\", \"en-GB, United Kingdom, English\", \"en-ID, Indonesia, English\", \"en-IN, India, English\", \"en-MY, Malaysia, English\", \"en-NZ, New Zealand, English\", \"en-PH, Republic of the Philippines, English\", \"en-US, United States, English\", \"en-ZA, South Africa, English\", \"es-AR, Argentina, Spanish\", \"es-CL, Chile, Spanish\", \"es-ES, Spain, Spanish\", \"es-MX, Mexico, Spanish\", \"es-US, United States, Spanish\", \"fi-FI, Finland, Finnish\", \"fr-BE, Belgium, French\", \"fr-CA, Canada, French\", \"fr-CH, Switzerland, French\", \"fr-FR, France, French\", \"it-IT, Italy, Italian\", \"ja-JP, Japan, Japanese\", \"ko-KR, Korea, Korean\", \"nl-BE, Belgium, Dutch\", \"nl-NL, Netherlands, Dutch\", \"no-NO, Norway, Norwegian\", \"pl-PL, Poland, Polish\", \"pt-BR, Brazil, Portuguese\", \"ru-RU, Russia, Russian\", \"sv-SE, Sweden, Swedish\", \"tr-TR, Turkey, Turkish\", \"zh-CN, Peoples Republic of China, Chinese\", \"zh-HK, Hong Kong SAR, Traditional Chinese\", \"zh-TW, Taiwan, Traditional Chinese\"}\n\nset market_code to choose from list market_code_choices with prompt \"Market code (Code, Country/Region, Language):\" default items {\"ja-JP, Japan, Japanese\"}\n\nif market_code is false then return\n```\n\nopens up a list of valid market codes for selection:\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"500\" alt=\"Screen Shot 2021-11-12 at 23 11 59\" src=\"https://user-images.githubusercontent.com/6127163/141489460-d1d774b5-e71e-41e3-bdf2-0b758796e911.png\"\u003e\n\u003c/p\u003e\n\nand selecting `Cancel` exits the AppleScript.\n\nFor the above example, the market code `ja-JP` is selected and the variable `market_code` is then set to `ja-JP, Japan, Japanese`.\n\n### Step 2\n\nThe next part of the AppleScript\n\n```\ntell application \"System Events\"\n\ttell every desktop\n\t\tset picture to \"~/Downloads/no_image.jpg\"\n\tend tell\nend tell\n```\n\njust removes the current wallpaper image.\n\n### Step 3\n\nThe next part of the AppleScript\n\n```\ntell application \"Terminal\"\n\tdo script \"curl --silent \\\"http://www.bing.com/$(curl --silent \\\"http://www.bing.com/HPImageArchive.aspx?format=js\u0026uhd=1\u0026idx=0\u0026n=1\u0026mkt=$(echo \" \u0026 market_code \u0026 \" | grep --extended-regexp --only-matching \\\"[a-z]{2}-[A-Z]{2}\\\")\\\" | grep --only-matching \\\"\\\\\\\"url\\\\\\\":\\\\\\\"\\\\/.*\\\\.jpg\\\" | sed 's/\\\"url\\\":\\\"\\\\///g')\\\" \u003e ~/Downloads/bing_image_of_the_day.jpg\" in front window\nend tell\n```\n\nthen sends the one-liner CLI command to `Terminal.app`, where the (suitably escaped for AppleScript) command\n\n`echo \" \u0026 market_code \u0026 \" | grep --extended-regexp --only-matching \\\"[a-z]{2}-[A-Z]{2}\\\"`\n\njust pulls out the market code from the `market_code` variable.\n\nFor example, the CLI command\n\n```\necho ja-JP, Japan, Japanese | grep --extended-regexp --only-matching \"[a-z]{2}-[A-Z]{2}\"\n```\n\nsimply outputs\n\n`ja-JP`\n\n### Step 4\n\nThe next part of the AppleScript\n\n```\ntell application \"System Events\"\n\ttell every desktop\n\t\tset picture to \"~/Downloads/bing_image_of_the_day.jpg\"\n\tend tell\nend tell\n```\n\nthen sets the downloaded image `~/Downloads/bing_image_of_the_day.jpg` as the desktop wallpaper.\n\n### Step 5\n\nThe final part of the AppleScript\n\n```\ntell application \"Terminal\"\n\tdo script \"curl --silent \\\"http://www.bing.com/HPImageArchive.aspx?format=js\u0026uhd=1\u0026idx=0\u0026n=1\u0026mkt=$(echo \" \u0026 market_code \u0026 \" | grep --extended-regexp --only-matching \\\"[a-z]{2}-[A-Z]{2}\\\")\\\" | grep --only-matching \\\"\\\\\\\"url\\\\\\\":\\\\\\\"\\\\/.*\\\\.jpg\\\" | sed 's/\\\"url\\\":\\\"\\\\/th?id=OHR\\\\.//g' | sed 's/\\\\.jpg.*//g'\" in front window\nend tell\n```\n\nprovides a simple check of the file name, market code and image resolution obtained by the one-liner CLI command.\n\nFor example, the CLI command\n\n```\ncurl --silent \"http://www.bing.com/HPImageArchive.aspx?format=js\u0026uhd=1\u0026idx=0\u0026n=1\u0026mkt=$(echo ja-JP, Japan, Japanese | grep --extended-regexp --only-matching \"[a-z]{2}-[A-Z]{2}\")\" | grep --only-matching \"\\\"url\\\":\\\"\\/.*\\.jpg\" | sed 's/\"url\":\"\\/th?id=OHR\\.//g' | sed 's/\\.jpg.*//g'\n```\n\nsimply outputs\n\n`ElephantGiving_JA-JP6387498046_UHD`\n\n## Adding the AppleScript to the `Shortcuts.app`\n\nIn the `Shortcuts.app`, create a new Shortcut\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"200\" alt=\"Screen Shot 2021-11-12 at 23 32 08\" src=\"https://user-images.githubusercontent.com/6127163/141492985-18725826-7081-448d-ae2d-3d45fe127e37.png\"\u003e\n\u003c/p\u003e\n\nthat performs a `Run AppleScript` action with the above AppleScript code\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"800\" alt=\"Screen Shot 2021-11-12 at 23 32 47\" src=\"https://user-images.githubusercontent.com/6127163/141493216-f8233ca0-5825-42f9-a70a-284839c6759e.png\"\u003e\n\u003c/p\u003e\n\nthat may then be run from the Menu Bar\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"500\" alt=\"Screen Shot 2021-11-12 at 23 32 55\" src=\"https://user-images.githubusercontent.com/6127163/141493274-393e6b87-4d0b-4d25-b4f6-27a254cc24ad.png\"\u003e\n\u003c/p\u003e\n\n## License\n\nDo What The Fuck You Want To Public License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiccal%2Fbing-wallpaper-applescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiccal%2Fbing-wallpaper-applescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiccal%2Fbing-wallpaper-applescript/lists"}