The most simple solution to your actual problem -- avoiding the tool bar -- is to customize tool-bar-mode
to nil
.
Alternatively you can also put (setq tool-bar-mode nil)
into your init file.
The problem with window-system
in emacs daemon is that the virtual frame of the emacs daemon is not connected to any display. Since the init file runs in the daemon window-system
is nil.
Furthermore, you shouldn't use windows-system
as bool variable. Use display-graphic-p
instead. See the last section of the windows-systems doc.
The server creates display frames for clients on demand (with option --create-frame
).
Therefore, after-make-frame-functions
is the right place to hook in if you want to tweak your graphical frames generated by an emacs daemon. In the following I give you an example:
(defun my-frame-tweaks (&optional frame)
"My personal frame tweaks."
(unless frame
(setq frame (selected-frame)))
(when frame
(with-selected-frame frame
(when (display-graphic-p)
(tool-bar-mode -1)))))
;; For the case that the init file runs after the frame has been created.
;; Call of emacs without --daemon option.
(my-frame-tweaks)
;; For the case that the init file runs before the frame is created.
;; Call of emacs with --daemon option.
(add-hook 'after-make-frame-functions #'my-frame-tweaks t)