running emacs in full-screen mode

Sometimes it's nice to run emacs in full-screen mode; for example if you don't want to be distracted by your pretty desktop wallpaper etc. When we're using the X-Window system, we can ask the wmctrl-program to make our window full-screen by adding the following to .emacs:
(defun djcb-full-screen-toggle ()
"toggle full-screen mode"
(interactive)
(shell-command "wmctrl -r :ACTIVE: -btoggle,fullscreen"))

This requires the wmctrl program, for which there is (hopefully) a package in your distribution.

We can make a keybinding for this to, say, F11, which is the same one that e.g. FireFox use:

(global-set-key (kbd "<f11>")  'djcb-full-screen-toggle)

Note that instead of shell-command we could use the djcb-shell-command-maybe function instead, and get a warning if wmctrl is not installed.

No comments:

Post a Comment

Followers

Popular Posts