found how to get active app and it's pid.

no error handling yet,

and still need to found out how to use "grep" to filter the log.