Skip to main content

Set Elon's latest tweet as your desktop wallpaper

If you have an Ubuntu box, you can use a script to to set your wallpaper's to Elon's Latest Tweet.

Here is how you setup:
  1. Install required packages.
  2. Download - an OAuth based twitter client implemented completely as a bash script.
  3. Get Token keys for from your Twitter account and save it in the config file. You need this for OAuth that uses.
  4. Get a free account on and fetch your API keys. This service allows you to generate screenshot of any supplied URL - you can use this service to to fetch PNGs's of Elon's tweets. We do screenshots because aren't just interested in tweet's text but also any images that Elon chooses to attach with his tweets.
  5. In the batch script ( appended below, configure the pages2images API key
  6. Setup the batch script ( as a cron job which runs once every minute.
You can set this script up on a Raspberry Pi running Raspbian connected to your TV as well. Its always nice to have some inspiration trickling in while you work.

Here is how my desktop looks like
Here's how to go about putting the pieces together:
  1. Open a terminal window and install the required software on your ubuntu box:
    sudo apt-get install jq imagemagick pngcrush nkf
  2. Clone and place and tweet.client.key in your home directory
  3. While logged into Twitter, visit and create a new app and generate the required Token and Keys and place them in tweet.client.key
  4. Mark as executable:
    sudo chmod +x
  5. Register on and get your API key
  6. Create a new script called in your home folder and copy and paste the code snippet appended below.
  7. Edit and insert the pages2image API key at the appropriate location.
  8. Mark as executable:
  9. Set the script to run once every minute:
    crontab -e
    and insert the following line:
    * * * * * bash ~/
The script will run once every minute and will check if there is any new tweet from Elon since last check. If there is, it will submit the URL for screenshot generation and exit. When the script is run again at the next consecutive minute, it will fetch the image, crop it and set it up as wallpaper. If Elon has put up a new tweet, the URL of this new tweet is submitted for screenshot and the script exits. In such situation, you will miss out the 2nd tweet if the time difference between 1st and 3rd tweet is less than 2 minutes - this can be fixed in the script, but it seemed to be a bit much. Thank God Elon doesn't go crazy on twitter. All the tweets are saved in the Pictures folder.

Tweet screenshots are saved in Pictures folder
This is what the cropped tweet looks like

This is what the cropped tweet looks like