For anybody who’s ever been annoyed by some idiot texting near them in a dark theater, seeing justice done is sweet. But never more colorfully or symbolically so than at a recent performance of the off-Broadway play “Freud’s Last Session,” in which one transgressor was reprimanded by the father of modern psychology himself.

“There was a lady texting in the front row,” says actor Martin Rayner, who plays Sigmund Freud in the show, which is at New World Stages.

“It’s very distracting, especially in such a small theater. I decided at some point I had had enough of it, and I turned to her and said, ‘Stop texting!’ and carried on. She was stunned. I think my partner onstage was stunned, too, because I stuck it in the middle of a line!

“It got a cheer,” Rayner recalls.

“I think a lot of audiences hate those people sitting next to them texting.”

That moment of triumph seems indicative of a growing resentment of the boorish, entitled smartphone addicts who seem to pop up at every movie or live performance these days. The common wisdom in years past has been to simply ignore such bad behavior, or accept it as an unfortunate side effect of our perma-online culture.

Lately, though, fed-up patrons and performers are pushing back — such as conductor Alan Gilbert of the New York Philharmonic, who recently stopped the orchestra in the midst of a climactic moment in a Mahler symphony when an iPhone marimba ringtone sounded in the front row.

“Are you finished?” he asked. The tone went on. “Fine, we’ll wait.” When it finally stopped, Gilbert apologized to the rest of the audience, saying he usually ignores such things, but that “this was so egregious that I could not allow it.”

And a recent viral video from a violin concert in Prague shows another way of fighting back: When a cellphone rings, the annoyed violinist deftly picks up the tune and plays a few bars of it before switching back to the concerto.

Most of the time, though, we must content ourselves with an impotent whispered request — often ignored — or else face the daunting challenge of causing an even bigger public disruption than the phone hog.

“One of the great ironies of manners is that the people who enforce them often have worse manners than the initial violators,” says Henry Alford, author of the new etiquette book “Would It Kill You To Stop Doing That?”

Nevertheless, Alford is all in favor of combating the scourge of smartphone rudeness sweeping the nation. For inspiration, look to high-profile stage performers such as Hugh Jackman, Patti LuPone and Kevin Spacey, all of whom have stopped mid-show to chastise techno-rudeness. In May, Frances McDormand was at a pivotal moment in her Tony-winning performance in “Good People” when a cellphone rang — and its owner answered it. McDormand reportedly stopped, put her arm around her co-star and said, “Let’s wait.” Which she did, until the oblivious patron realized what she’d done and stashed the phone.

Occasionally, someone will take it to the next level. When hairdresser Wyatt Raymond took his visiting niece to a movie in Times Square, he says, “about five minutes into the movie, you hear someone talking on her cellphone. The guy in front of me stands up, looks for the person, sees her, and reaches over and closes her phone. She gets up and starts shouting, ‘You don’t do that! You don’t touch someone’s phone!’

“He waves her away and she picks up her very large soda and throws it at him. It didn’t actually hit him — it hit the guy next to him. Who grabs his soda and throws it at her!”

When all involved parties had been escorted into the lobby, the rest of the audience simply laughed it off, Raymond reports. But not all moviegoers are so forgiving.

“I think it’s really the theater’s responsibility. They should warn people on the first offense, and then on the second offense they should pull the person out by the ear and kick them in the ass, hard!” says one Manhattan movie publicist, who asked to remain anonymous.

The likelihood of having to deal with these disruptions in a movie for which you’ve paid upwards of $14, he suggests, is largely to blame for this year’s plummeting ticket sales ($500 million less than the previous year, and a 16-year low for the industry, reports Hollywood.com). “Why pay all that money to go to the movies when you can wait a couple of months to watch in the comfort of your own home?” says the publicist, whose livelihood depends on people not doing that.

So why aren’t more movie theaters following the example of the Alamo Drafthouse theaters in Texas, which famously boot patrons for texting or talking? This summer, they made one indignant woman’s angry voice mail into a public service announcement for the chain: “I’ve texted in all the other theaters in Austin, and no one ever gave a f - - k!” she rants in the spot, which concludes with a message: “Thanks for not coming back to the Alamo, texter!”

The viral video has obviously struck a chord with the public: it’s got nearly 2.5 million hits on YouTube. “We probably kick out about 100 people a year from our 10 locations,” says Alamo owner Tim League.

A spokesman for the AMC chain assures The Post that New York cinema managers “do periodically check auditoriums to make sure there’s no distracting texting going on,” though anyone who’s been to a show in Times Square lately may take issue with that assertion.

A spokeswoman for the Clearview Cinemas chain in New York, meanwhile, didn’t respond to our request for comment.

Broadway theaters and fine arts performance spaces always make announcements asking patrons to turn off their phones, but even this explicit instruction doesn’t seem to get through to everyone. At Lincoln Center Theater, “before the show begins and during intermission the ushers walk up and down the aisles asking everyone to be sure to turn off their electronic devices,” says spokesman Philip Rinaldi.

But many theater owners seem oblivious to just how deeply most patrons despise those little lap-lights. Exhibit A: the plan to have a block of “tweet seats” in select Broadway shows. The director of promotions for the current revival of “Godspell” has said the production intends to try out this idea.

The very thought makes Stephen Bienskie’s blood run cold.

The actor, who plays Buffalo Bill in the off-Broadway show “Silence! The Musical,” says he’s always stunned when patrons whip out their phones mid-performance, whether to text, talk or take pics.

Although Bienskie says he’s been known to stop mid-line and wait for a phone to stop ringing, there are some moments when it’s simply not possible to break character and yell at violators.

“I get to the end of the number and I reveal myself,” says Bienskie, who is seminude for a few seconds during the show, “and I see about 10 cellphones come up in the audience. How do you combat that?”

Still, Bienskie thinks the tide may be turning.

“People are starting to speak up,” he says.

“Audience members get as outraged as we do, and think nothing of turning to someone and saying, in so many words, to turn their phone off and have some respect. People will actually jump on them pretty quickly.”