DEV Community

Luis Ángel Méndez Gort
Luis Ángel Méndez Gort

Posted on

2

New wallpapers every day

There a lot of good wallpapers for free in the Internet, however I have found that the applications to get them automatically in Linux are quite disappointing. Because of that I made the following script.

#r "nuget: FsHttp"
#r "nuget: Fli"

open FsHttp
open Fli

let API_KEY = "<YOUR_UNSPLASH_API_KEY>"

type Urls = { full: string }

type UnsplashBody = { id: string; urls: Urls }
let wallpaper = "/YOUR/WALLPAPERS/wallpaper.jpeg"

let random () =
    http {
        GET "https://api.unsplash.com/photos/random?orientation=landscape&query=landscape"
        Authorization $"Client-ID {API_KEY}"
        header "Accept-Version" "v1"
    }
    |> Request.send
    |> Response.deserializeJson<UnsplashBody>
    |> _.urls.full

http {
    GET(random ())
    Authorization $"Client-ID {API_KEY}"
    header "Accept-Version" "v1"
}
|> Request.send
|> Response.toBytes
|> fun bs -> System.IO.File.WriteAllBytes(wallpaper, bs)


cli {
    Exec "<COMMAND>"
    Arguments [ "<TO>"; "<SET>"; wallpaper ]
}
|> fun o -> printfn $"%A{o}"
Enter fullscreen mode Exit fullscreen mode

You can run it with dotnet fsi wallpaper.fsx assuming you saved the above code in wallpaper.fsx

To improve the experience you could use it in a cron job.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay