Figuring out my webapps problem yesterday made me ask myself if I could somehow repurpose that little
xdotool script to solve another niche itch that I had.
Spoiler alert: It did.
Which brings me to the hiccough. I launch EmacsClient and a window (frame) does indeed launch, but it just … stays there in the background.
Repeated attempts to launch EmacsClient are to no avail.
The pesky little windows just pile up in their corner.
Ergo, this little bit of Bash/xdotool shenanigans …
#!/usr/bin/env bash export EMACSWINID=$(xdotool search "\*scratch\*" | tail -n1) if [ $EMACSWINID ]; then xdotool windowactivate $EMACSWINID else sh -c 'emacsclient --create-frame --no-wait --alternate-editor="" && export EMACSWINID=$(xdotool search "\*scratch\*" | tail -n1) && xdotool windowactivate $EMACSWINID' fi
- Check to see if an Emacs scratch buffer is open. If it is, switch to it.
- Otherwise, just launch EmacsClient, get the id of the scratch buffer window (frame) and raise it, so that I can work on it. In peace.
Cue: sounds of relief, in the background
Feedback on this post? Mail me at email@example.com
P.S. Subscribe to my mailing list!
Forward these posts and letters to your friends and get them to subscribe!
P.P.S. Feed my insatiable reading habit.
Frames, in Emacs parlance ↩︎