Support multi screen setups

This adds support for setups with multiple screen by adding
an option to select the screen that should be captured.

Some abstracted functions were moved to a separate library for
reusability and readability.