instead of passing things to the environment, substitute $pid and $window inline...