A lot of libraries I've seen in universities have mechanized sliding shelves. They have sensors to ensure that if something is in between them, they won't close. Still though, it's easy to imagine someone getting crushed by their bed because a sleepy programmer made an off-by-one error at 4am. Guess I should probably go to bed...