Start Emacs daemon as a systemd service
This commit is contained in:
parent
f1a55c3030
commit
769211e956
3 changed files with 40 additions and 0 deletions
13
systemd/.config/systemd/user/emacs.service
Normal file
13
systemd/.config/systemd/user/emacs.service
Normal file
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=Emacs: the extensible, self-documenting text editor
|
||||
After=save-environment-variables@emacs.service
|
||||
Requires=save-environment-variables@emacs.service
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart=/usr/bin/emacs --daemon
|
||||
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=Save specific environment variables
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/home/chelys/usr/bin/save-environment-variables %h/.config/systemd/user/%i.service.d/env.conf PATH XDG_CONFIG_HOME XDG_DATA_HOME
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
18
systemd/usr/bin/save-environment-variables
Executable file
18
systemd/usr/bin/save-environment-variables
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
output=$1
|
||||
shift
|
||||
|
||||
source $HOME/.profile
|
||||
|
||||
# Make sure the output directory exists.
|
||||
[[ -d "$(dirname $output)" ]] || mkdir -p "$(dirname $output)"
|
||||
|
||||
echo "[Service]" > "$output"
|
||||
|
||||
# Write down all the environment variables.
|
||||
for env in $@; do
|
||||
echo "Environment=\"${env}=${(P)env}\""
|
||||
done >> "$output"
|
||||
|
||||
systemctl --user daemon-reload
|
Loading…
Reference in a new issue