I want to force emacs to be activated, be bought to frond and 'steal' focus in certain circumstances. E.g when I finish a org-Pomodoro or during an important appointment reminder.
Now, I'm looking for a 'native' way to do so, just to reduce external dependencies. (just Linux is ok for me, cross-platform would be better).
Is this technically possible from inside emacs?
[edit] Solution:
If using the GUI, this works well:
(x-focus-frame nil)
[For historical reasons...] I have tried:
Frame visibility (doesn't work)
(make-frame-visible)
And also:
(make-frame-invisible)
(make-frame-visible)
But these seem to only work if Emacs is already activated.
Frame raising (doesn't work)
Lowering frame seems to actually hide emacs.
(lower-frame)
But raising the frame from a timer doesn't. I.e, nothing happens.
(raise-frame)
It seems there is a missing 'activate-emacs' before raising it.
[NOTE on external solution]
Currently, as a (workaround/solution?) I use a bit of elisp:
(call-process "activateEmacs")
And the respective bash script: (you may need to install xdotool on your system first)
#!/bin/sh
sleep 0.5
xdotool search --onlyvisible --class emacs windowactivate