Display AdSense Earnings In Conky

Updated 09/24/2026

The script has been updated to use Google's OAuth login method.


Get the script and config file

The PHP script needs PHP 8 or newer with curl.

AdSense earnings shown in Conky

In Google Cloud Console, create or select a project and enable the AdSense Management API.

Set up the Google Auth Platform consent screen and add the https://www.googleapis.com/auth/adsense.readonly scope.

Under Clients, create an OAuth client of type Desktop app and download its JSON. That downloaded JSON is your config file.

Put the JSON in the same directory as the script and name it adsense-config.json. Make it readable only by your user (file mode 600). Keep it off any public website.

For ongoing use, set the OAuth app's publishing status to In production. In Testing, Google's refresh token expires after seven days.


Run it

On the computer that runs Conky, authorize once. Open the URL printed by the script in a browser on that same computer and sign in with your AdSense Google account. The script adds the token and selected account to adsense-config.json.

php /path/to/adsense.php --authorize

Check today's and this month's estimated earnings:

php /path/to/adsense.php

Then put this line in your Conky text section, using your script's full path:

${texeci 900 /usr/bin/php /path/to/adsense.php}

Download

AdSense PHP script