On a rare occasion that I have slept in an actual campground, I stopped on my way home to sleep one night and laid my bedroll out on the back of my truckbed (same flatbed, though years before I met my wife). I was woke up to noise and a bear was in the dumpster maybe 30 yards away. I grabbed some rocks and started hucking them and finally got good smack on the side of the dumpster and he popped half his body up all shocked at the sound, then climbed out.
I actually had to climb off my truck again and get more rocks as I had run out and get some more rocks to chunk the bear. I was a crappy rock thrower and kept missing him in the dark, but finally connected and the rolly polly little pig went scooting off into the dark.
That same campground I had pegged a bear before with rocks when I stopped for the night one time. Small black bears, and the Forest Service at the time was still just using regular dumpsters. The first time though, I had a very cute girl with me who was from Florida and thought I was crazy, was positive we would be eaten alive by a "killer bear" . Same deal. Noisy trash eating dumpster divers.
After I shoed off the noisy little bear and crawled back under the covers I discovered that she thought that was some "Jeremiah Johnson" stuff and she proceeded to attack me like she was a bear!