Put tool-bar-mode statement behind a when statement that checks whether or not emacs is running in a GUI.