[bin] Put bin files in .local/bin

This commit is contained in:
2026-02-10 12:12:11 -05:00
parent c50d88ce26
commit d1eb0f5b3d
45 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,24 @@
#!/usr/bin/env python3
import os
import subprocess
from datetime import datetime
import requests
today = datetime.today().strftime("%Y-%m-%d")
home = os.path.expanduser("~")
target_path = f"{home}/var/media/backgrounds/unsplash/{today}.jpg"
# If the file for today already exists, just exit
if os.path.isfile(target_path):
print(f"Unsplash image for {today} already exists, skipping download")
exit()
root = "https://source.unsplash.com"
iotd_uri = f"{root}/random"
img = requests.get(iotd_uri, stream=True)
handle = open(target_path, "wb")
for chunk in img.iter_content(chunk_size=512):
if chunk: # filter out keep-alive new chunks
handle.write(chunk)