Ubuntu – emacs starting maximised

emacsUbuntu

I want a keyboard shortcut to open emacs in a maximised window. I tried emacs --fullscreen, but that is full screen rather than maximised window… That is, the emacs window covers ubuntu menu bars. emacs -fw gets a full width window and emacs -fh gets a full height window, but if you put both options, it only reads the second one. At the moment, I just have another keyboard shortcut for maximising a window. Is there a way to get emacs to start maximised?

Ubuntu 9.10, emacs 22, if that makes a difference.

Best Answer

I have this in my .emacs, which I then bind to a key:

(defun my-frame-toggle ()
  "Maximize/Restore Emacs frame using 'wmctrl'."
  (interactive)
  (shell-command "wmctrl -r :ACTIVE: -btoggle,maximized_vert,maximized_horz"))

(global-set-key [(control f4)] 'my-frame-toggle)

You can then hit CtrlF4 and toggle between regular and full-screen (but not covering the Ubuntu menu bar and bar at the bottom of the screen whose name I'm blanking on at the moment). To start up that way simply invoke it:

$ emacs -e "my-frame-toggle"
Related Question