Add hooks for user actions on "mode" switch

Signed-off-by: Mattias Andrée <maandree@operamail.com>
Merge branch hooks into ma and resolve merge conflicts

Signed-off-by: Mattias Andrée <maandree@operamail.com>