This is actually a difficult problem, because there are two kinds of slackers: (1) the kind that work less but produce roughly the same as, or sometimes even more than, everyone else (i.e., smart but lazy), and (2) the kind that don't work or produce.
Dealing with (2) is absolutely the manager's job and such a person should be fired if attempts to identify and fix an underlying problem fail.
But (1) is really difficult. We have one of those right now, let's call him Bill. Our manager is hesitant to do anything about him, because the manager wants to incentivize productivity, not butt-in-chair time (we're all salaried, with no set hours). But Bill comes in 4 hours a day, seemingly works 1 of them, and spends the other 3 trying to distract everyone else with off-topic conversations. If he comes in at all.
Amazingly Bill does get work done, somehow. But it is terrible for morale. Worse, some of the junior members are starting to think they can get away with the same thing Bill is doing, and they can't. As the senior dev, the "big brother" to our manager's "dad", it falls to me to do something about it, but I have no idea what, if anything.
Manager fears that if he rewards finishing tasks quickly with more work, it will also harm morale and productivity. And there is a decent argument to be made for that. Having experienced that firsthand, it is highly irritating and incentivizes people to work slowly.
Additionally, in reply to GP, a manager that has great technical skills (10) and good managerial skills (1-9) must be as rare as a unicorn. Even a manager who started with good technical chops inevitably will lose them over time when they are an Outlook jockey all day. OTOH, I have seen plenty of otherwise decent managers who think their technical chops are good when they aren't. Pretty much the whole premise of Dilbert. The best realistic alternative seems to be managers who know their technical limits, delegate, and seek advice from their subordinates.