Is it legal to embed a miner in another open source program for benifit of the programmer? So say I am writing an open source program, or any program really, and I embed a Bitcoin miner in the code, so that when people run my program, they would be earning Bitcoins for me. 

Would this be legal? 

Would I get sued for doing this? 

The reason why this is important is because I love free and open source software, the only problem being that this doesn't pay the bills. I fully intend to at least inform the users of my program that there is a Bitcoin miner embedded in the program, if not also make a non-miner version available.
Well, lets look at the outcomes for the user:


your user burns hundreds of times their normal power usage mining, thousands of dollars of their money goes into their power bill
your user potentially ruins their hardware (Mac hardware will die, there's no question of that)
your users computer becomes sluggish and unresponsive
their virus protection removes the miner, as they're almost always marked as malware


The outcomes for you:


you make a couple of cents a day
you look like a complete dirtbag to your users


Doesn't seem worthwhile to me. Just ask them for donations if you really think your software deserves financing.