Oh well, oh my xe2x80xa6 question almost included the answer. Still needs some testing (I've just set it up now), using tasker which has a Greenify plugin:
- Condition:
- Event xe2x80xba Display xe2x80xba Display Off
- Task:
- Task xe2x80xba Wait: 20 s (just in case)
- Task xe2x80xba Anchor: (Name, optional step)
- Plugin xe2x80xba Greenify xe2x80xba Hibernate: Pick the app
- Task xe2x80xba Wait: 30 min (or however long you want to have the app hibernated)
- Plugin xe2x80xba Greenify xe2x80xba Wakeup: Pick the app againxc2xb9
- Task xe2x80xba Goto: Action Number, 2
- Exit Task:
- Plugin xe2x80xba Greenify xe2x80xba Wakeup: Pick the app againxc2xb9
Note: That's how I would set it up. Had to skip the exit task as Tasker won't let me add one. So that's the crux here: I have to trust Tasker to restore the "previous state" correctly. If that doesn't work, I'll have to create a second profile for Event xe2x80xba Display: Display On (which would, being an EVENT, fire when the display will be turned on xe2x80x93 it's not a state) and have a single task to do what otherwise the exit task would do.
Note 2: In order for this to work, you need to add the "target app" to Greenify's hibernation list first (i.e. tell Greenify it should hibernate it when turning the display off). If you don't do that, it won't ever be hibernated at all.
xc2xb9 if your app doesn't react on the wake-up command, see Xavier's answer for an alternative shell command to try