The Line of Duty and Vigil actor became fascinated by the story of Connolly after visiting the prison where he was executed during a recent trip to Ireland.
The Greenock-born star said being a Scot made him ideal to portray Connolly, who was one of the leaders of the 1916 Easter Rising.
Compston, 37, revealed his ambition during an appearance on RTE show Ask Me Anything following his visit to Kilmainham Gaol, where Connolly was shot dead by a firing squad.
He said: “It was somewhere I had always wanted to go, that period of history fascinates me.
“I may be a bit young for it at the moment but to play James Connolly would be a dream role for me.
“I think people forget or people don’t know he was Scottish.
“Just going there and being in that environment, the history just seeps out of the walls.”
Born of Irish immigrant parents in Edinburgh in 1868, Connolly left school when he was eleven to work with his brother at the Edinburgh Evening News as a printer’s ‘devil’, the boy who cleaned the inky rollers.
In 1893, he became involved with the Independent Labour Party formed by Keir Hardie.
He moved to Dublin where he founded the Irish Socialist Republican Party, becoming right-hand man to legendary trade unionist James Larkin.
The best-known period of his life came after 1914 and the creation of his socialist militia, the Irish Citizen Army.
Connolly was a key figure in the Easter Rising against British rule in Dublin.
He was tied to a chair when he was executed, aged 47, as he was unable to stand after being badly injured in the fighting.
Today, you have to look hard to find Connolly commemorated in Edinburgh, down in the Cowgate, where he was born.
Back then, the Cowgate was known as “Little Ireland”, and was one of the poorest slums in the city.
The plaque that marks Connolly’s birth can be found on a pillar of the arch of George IV Bridge, next to a row of Cowgate pubs.
Meanwhile, the Martin Compston-starring submarine thriller Vigil helped drive iPlayer to its best summer ratings on record, the BBC has announced.
During the 2021 third quarter, between July to September, programmes were streamed 1.5 billion times on the streaming service, up 20% on the same period last year.
The first episode of Vigil, a six-part drama series which also starred Suranne Jones, Rose Leslie, Paterson Joseph and Shaun Evans, was iPlayer’s most streamed programme, excluding the news, with nearly 6.8 million streams during this period.
It was also the third most watched series overall on iPlayer from July to September, with more than 26.5 million streams.
The show, made by World Productions, the company behind Line Of Duty, was the highest rated new drama since Bodyguard, also made by World Productions, in 2018.
Set and filmed in Scotland, Vigil came to a nail-biting conclusion on September 26.