This simple script allows you to keep track of your sales on Envato market (CodeCanyon, Themeforeset, AudioJungle, etc).

It’ll fetch the current sales count on first use, so that it’ll alert you of how many new sales you have, every time you call the command:

~/get-envato-sales samiel

We’ll make it work independently, whenever we open the terminal, so that it shows a notification bubble in our Ubuntu desktop.

Create a new file at ~/get-envato-sales

#!/usr/bin/env sh

user="$1"

if [ -z "$user" ]; then
    echo "You must provide a username."
    return
fi

sales=`curl -s https://codecanyon.net/user/$user \
    | grep AuthorSales \
    | egrep -o 'AuthorSales:.*\"' \
    | egrep -o ':.+"' \
    | sed 's/://; s/"//; s/,//'`

if ! [ -z "$sales" ]; then
    if [ -f ~/$user.envato-sales ]; then
        oldSales=`head -1 ~/$user.envato-sales`
        diff=`awk "BEGIN {print ($sales-$oldSales)}"`

        if [ "$diff" -gt 0 ]; then
            msg="You got $diff new sales on Envato market! Yay :)"
            if ! [ "$diff" -gt 1 ]; then
                msg=`echo $msg | sed 's/sales/sale/'`
            fi
            notify-send "Envato Sales (@$user)" "$msg"
        fi
    fi

    echo $sales > ~/$user.envato-sales
fi

Save the file, next make it executable:

chmod +x ~/get-envato-sales

Now add the following entry to your ~/.bashrc file:

~/get-envato-sales samiel > /dev/null 2>&1 &

Make sure to replace samiel with your own Envato username.

Here’s a preview of the notifications bubble:

Fetching Envato Sales Automatically on Linux

Digital Ocean

Cheap Cloud SSD Hosting

Get a VPS now starting at $5/m, fast and perfect for WordPress and PHP applications

Sign Up with $10 Credit