How to make emacsclient uses differnt themes in terminal and X window?

Sometimes I use emacsclient -t -a '' in xterm, and sometimes I use emacsclient -c as a GUI application. What annoys me is that the font settings and color-theme are initialized when emacs server starts up so the window-system test doesn't take effect.

So are there any functions that I can make use of to let the emacsclient choose the face settings?

Thanks.


Solution 1:

try to follow this post, they are talking about a similar issue.

here are the snippets from the post (I didnt try it myself though):

  ;; last t is for NO-ENABLE
  (load-theme 'tango t t)
  (load-theme 'tango-dark t t)

  (defun mb/pick-color-theme (frame)
    (select-frame frame)
    (if (window-system frame)
        (progn  
          (disable-theme 'tango-dark) ; in case it was active
          (enable-theme 'tango))
      (progn  
        (disable-theme 'tango) ; in case it was active
        (enable-theme 'tango-dark))))
  (add-hook 'after-make-frame-functions 'mb/pick-color-theme)

  ;; For when started with emacs or emacs -nw rather than emacs --daemon
  (if window-system
      (enable-theme 'tango)
    (enable-theme 'tango-dark))

if all goes well, it should look like: this

Solution 2:

As mentioned at https://www.emacswiki.org/emacs/CustomizingFaces

"If you want different color schemes for different displays, you can customize this as well. In the customize buffer, click the [State] button and choose “Show all display specs”. Now you can use different specs for different displays."