This post was originaly published on 2022-09-27.
Updated 2022-09-28, to include the improved script.
It’s been a year, since I figured out the hack that finally let me use my Compose key in Emacs.1
Without it, I am unable to type any kind of quotation marks or umlauts in emacs.
A year in, and I’m tired of restarting the service everytime the machine comes on.
The computer can do that for me.
So I whipped up this tiny bash script
|
|
It just arbitrarily checks for the Emacs service’s PID
and then if it’s lesser than or equal to 10000, it goes ahead and restarts the service.
This is just some superstitious thing I did, because when I was troubleshooting all those months ago, I assumed that if Emacs started at an ID
in the low thousands, it must not have been loading something and restarting it to get a higher process ID
meant what ever it needed must have loaded.
I learnt a couple of things doing it this way too.
- The output of a bash command is a string.
- I use
$(( some_numerical_string ))
to convert said string into an integer :
meanspass
in bash-speak
What I ought to do is to check for the existence of a PID
and if there is one, to then go ahead and restart emacs. I’ll do that some other time. Because right now, I put this script into my system startup and it just works.
Update 2022-09-28
I obviously am incapable, of leaving well enough alone.
As I was in the bath this morning, it struck me that I was restarting the service using systemctl restart …
So I could just check for the exit status of a systemctl status
command, and then depending on what I got, do something. If it was running, I could just restart it.
I checked on the command line and sure enough, if a service is running, the exit status is 0
and if it isn’t, the status is 3
.2
So … then I monkeyed with the script to this
|
|
If the emacs service is running, restart it, else do nothing.
This ought to quiet the monkey brain for a while.
I hope 🙂
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.