Written by Pete Corey on Dec 24, 2014.

My new bspwm setup currently doesn’t have a pretty GTK theme installed, so the menu in Sublime Text looks fairly unattractive. With my workflow, whenever I open Sublime Text (subl .), the menu is always shown, regardless of if I hid it during my last session. So what’s the solution to hiding the menu at startup? Find a plugin, of course! Oh, there are no plugins that do this? Write a plugin, of course!

My current bspwm setup

Building the Plugin

Unfortunately, I’ve never written a Sublime Text plugin. Thankfully there are many resources to help out a person in my situation. This post explained how to create a new Sublime Text plugin. This one showed how to run code when Sublime Text is started. And finally, this guy gave me the command I needed to execute to toggle the menu visibility. After testing everything out, I researched how to submit the plugin to package control, and made my pull request. The final result is available via package control, on github, and the incredibly simple code is below:

import sublime
import sublime_plugin


def plugin_loaded():
    window = sublime.active_window()
    window.run_command("toggle_menu")

Problems…

Unfortunately, the plugin has its issues. As mentioned here, with some workflows, Sublime Text will remember the state of the menu’s visibility and the toggle_menu command issued by my plugin will show the menu instead of hiding it. As far as I know, there is no way to either detect if the menu is visible before issuing the toggle, or sending some kind of “set visibility” command rather than a toggle. I’ve opened an issue about this on the project’s github. If you have a solution or any feedback about it, please leave a pull request/comment.