When I was on salary I worked as an electrical engineer rather than solely a programmer, but the environment was similar. I think I probably averaged a solid... 4-5 hours of high-quality work a day. And I honestly felt like that was pretty good most of the time; I was quite productive compared to many colleagues. I certainly did have the standard difficulties though. Days when I just couldn't seem to get started until 4pm when it was almost time to go home, so I'd end up having to choose between leaving after 8 hours without having accomplished much, or skipping the gym, working through the evening, etc. Either way I'd feel vaguely guilty.

Now I run a (very) small software company and do everything I can to avoid these issues. My brief experience as a salaried employee was invaluable. (It makes me wonder how people who start companies right out of school ever manage to become effective managers.) I certainly don't want to run a company where my best employees are producing at about 50%. I've found that (much like the OP), when I switched to working for myself, my own productivity immediately shot up - but how can I help create a similar environment for my employees?

The main thing in my opinion, as you'll regularly hear, is to focus on results, rather than hours. If it's a traditional office, as long as people are able to make meetings, they should be free to come and go as they please. One major issue I would have at my previous job was that I was expected to be there at 9am every morning. (Theoretically there were flex hours until 10am, but there was a sense that you were slacking coming in at 10, even if you stayed later than everyone else.) That meant if 5pm rolled around and I was really in the groove, I was torn between riding that productive wave and ... leaving, because if they're going to expect me to come in at the same time regardless, why should I stay late?

Similarly, I would occasionally have work that I could do at home, and would in fact have ideas about work at home and want to work. (As an electrical engineer this wasn't as common as a software engineer, but I probably could have done 20%-40% of my work from home.) But again, there was mixed motivation, because I wouldn't get any credit for that time, regardless of how much I accomplished.

So, as a manager, focusing on time spent has to be the absolute worst thing you can do for employee morale. However, what I didn't realize until I became a manager/owner was just how hard it is to be 100% results-oriented, especially when everyone is working remotely. Having a technical background myself, it's a bit easier, since I'm at least in a good position to evaluate the quality, and to some extent, the quantity of work produced. But even so, it can be very hard to not think about whether people are working "enough", especially when you can't physically see the work happening. I will occasionally find myself worrying when I don't see any commits or status updates or anything from a given employee over the course of a day or two, even though I have full confidence in them. And I think that's natural. Plus, it's a lot of work staying on top of the details of what people are doing, to the extent you have to, to be "results-oriented". It seems that most, or at least many, managers deal with this by just constantly "checking in". They just pop in (physically or virtually via chat or whatever), ostensibly to see what you're doing, help out if necessary, etc., but they don't really know what's going on, so there's no substance to the conversation - it's really just to see that you're there. There are even those services that take a picture every 30 seconds or whatever, theoretically to foster a team atmosphere, but it looks a lot to me like something to prove you have your butt in your chair. It is simply impossible to create good work by forcing someone to be physically present for a given number of hours, but it's a difficult thing to avoid. (Although I have found that some people appreciate those random check-ins that drove me crazy, so I try to identify when that's the case. If so, I will try to IM them occasionally, but I try to say something useful when I do, and pick times when it's unlikely to interrupt flow.)

And it's made more difficult by the fact that you can't go too far the other way either. If you simply give 100% freedom and rely on your employees to keep you up to date, the work done might be of high quality, but it will slow to a glacial pace. People do need some amount of structure and goals to remain productive - just not pointless structure. That's the part I've struggled most with, since my main concern was the opposite type of bad management, which I'd been exposed to most in the past. For quite some time I avoided weekly meetings, since they felt like a waste of time given that we can easily communicate by email and chat. Turns out a brief weekly meeting (usually around 30 minutes) to get everyone in sync is immensely helpful in moving things along. Similarly keeping track of everything in a project tracker like Pivotal helps a ton. And paradoxically, these types of enforced structure allow for greater freedom, since they alleviate that stress of not knowing what your employees are doing. And hopefully they help on the employee's side too, since there are explicit goals and expectations to keep one motivated, along with the flexibility to pursue them in the most efficient way.

Honestly, I'm sure there are still days when my employees get a solid 2 hours of work in. Few people can work at 100% capacity, 40 hours a week, week after week indefinitely. As a manager I figure I have to accept that, while providing the environment and the tools to help minimize those days as much as possible. (Providing sufficient vacation is another important factor there imo.) Of course, I still wonder what I could do better, so if anyone has thoughts (or disagreements!) I'd be happy to hear them!