"The Serenity Prayer" is attributed to Niebuhr. After initial use in 1941, Alcohol Anonymous embraced the prayer as their own. But it didn't start in the firm that you or we're all familiar with.
Wikipedia explains,
In June 1941, the prayer was published in an obituary in the New York Herald Tribune, and from here became known by the first Alcoholics Anonymous group. The organisation embraced it and spread it widely.[1] It was initially known within the group as "The AA prayer", but by the late 1940s, was known as "the serenity prayer."[1][12]
In 2016, Gary North offered a different prayer and a different way to achieve Serenity or contentment.
He writes,
The serenity prayer is recommended by Alcoholics Anonymous.
God grant me the serenity
to accept the things I cannot change;
courage to change the things I can;
and wisdom to know the difference.
It is attributed to Reinhold Niebuhr. If he wrote it, then it is the only theologically accurate thing he ever wrote.
The prayer is for serenity. This is another way of praying for contentment. The Apostle Paul wrote:
Not that I speak in respect of want: for I have learned, in whatsoever state I am, therewith to be content. I know both how to be abased, and I know how to abound: every where and in all things I am instructed both to be full and to be hungry, both to abound and to suffer need. I can do all things through Christ which strengtheneth me. Notwithstanding ye have well done, that ye did communicate with my affliction (Philippians 4:11-14).
This is the correct mental attitude.
The best way to gain contentment is to become productive. When you are productive in what you are doing, you tend to get in a zone. Outside influences do not bother you. You lose track of time.