
Untitled
By: a guest on
May 10th, 2012 | syntax:
None | size: 1.17 KB | hits: 15 | expires: Never
#! /bin/sh
. /etc/rc.conf
. /etc/rc.d/functions
#change this. too bad emacs daemon can't really work in mutli-user mode. for now.
USERNAME=volh
DESC="Run the emacs daemon."
NAME=emacs
#change this
DAEMON=/usr/bin/$NAME
DAEMON_ARGS="--daemon"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/rc.d/$NAME
#change this
EMACSCLIENT=/usr/bin/emacsclient
#EVALEXIT="(progn (setq kill-emacs-hook 'nil) (kill-emacs))"
# This one will save buffers in any case, without prompt(as save-buffers-kill-emacs will unconditionally do).
EVALEXIT="(progn (save-some-buffers t t)(kill-emacs))"
# This will save the desktop, but not the buffers themselves
#EVALEXIT="(progn (desktop-save-in-desktop-dir)(kill-emacs))"
case "$1" in
start)
stat_busy "Starting Emacs"
su $USERNAME -c "$DAEMON $DAEMON_ARGS" > /dev/null && (add_daemon emacs; stat_done) || stat_fail
;;
stop)
stat_busy "Stopping Emacs"
su $USERNAME -c "$EMACSCLIENT --eval \"$EVALEXIT\"" && ( rm_daemon emacs; stat_done ) || stat_fail
;;
restart|force-reload)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac