How to add weapon sway to my fps character?

i want the arm of my character to sway slightly i the direction that the mouse is moving, and when the mouse stops moving, it sways back to the original position.

any help will be appreciated.
thanks!