Sublime Forum

Material Theme - dynamic folder rename

#1

Hi all,
i need a little help with python on my Material Theme. I need to add a set of alternatives file_type icons (monochrome) but i don’t want to build another package that override the default colored icons. I’m not a python developer and it would be nice if a pydev can help me with that.

My idea is to make two folders, called icons and icons_mono. The python script should rename the correct folder to icons (since ST read the file icons from the icons folder) when the command is launched.

If i run the Material Theme: monochrome file icons the script should rename the icons folder to icons_colored and icons_mono folder to icons.

0 Likes

#2

You’ll need to add a .no-sublime-package file in the top level directory of your package. What you describe above won’t work with a zipped package.

You can target the package folder via sublime.packages_path() plus the name of your package as on PackageControl (Material Theme).


Compare the use of *.tmPreferences at sublimehq/Packages#131. You could put all icon files in one subfolder (colored and monochrome) and then change the target as defined in your files in the subfolder preferences depending upon a file in the User folder. Using that method would even allow you to continue to use a zipped package, as the file you are changing would be in the User folder, not part of your package.

0 Likes

#3

How i can do that?

0 Likes

#4

@Equinusocio:

Sorry for the late reply.


Rethinking my second suggestion from above… not sure it’s gonna work or makes sense.

It only makes sense when injecting substrings dynamically into completions and snippets. Because you’re targeting TextMate meta files (*.tmPreferences), I believe changing them via Python directly is the easiest way to go.


Step 1:

The way it works for your theme right now is that you have a list of files in ./icons/ named like file_type_ext.png where ext is the extension.

Step 2:

Sublime Text searches in a ./icons/ subfolder relative to your themes. If you wouldn’t want the default strict naming scheme forced by Sublime Text for the file names in that subfolder, you could remap using a *.tmPreferences file. There you could either redundantly target the same default file name in the ./icons/ subfolder or use another name.

Compare github.com/Briles/gruvbox and the ./icons/ and ./prefs/ subfolders there. Also notice that by default you apply file type icons to files with certain extensions, you can further specify the scope in the *.tmPreferences files here to fine-tune the desired behaviour…

Btw, you had removed this in e493311

Step 3:

You can add a .no-sublime-package file to the top level directory of your package and then change the file name targets in the *.tmPreferences dynamically via a Python file and search-and-replace the values of the plist variable icon.


You’ll need:

  • icons pack colored
  • icons pack b/w
  • one set (!!!) of tmPreferences files for the icons
  • a python file to change the contents in the tmPreferences files
  • .no-sublime-package file in the root

Related issue:

What about wbond/package_control_channel#5852? It seems you are trying too many approaches simultaneously here.

Maybe you and @oivva change the icons there to have a white foreground with transparent background only, so you can tint them within the themes separately? You could keep the current default colors with a default tint for each of the icons…

0 Likes

#5

From material theme 4 i Will use only the @oivva package. His package pick png icons from the default icons folder, so i think that the only solution is to rename the icons folder on the fly, with a py command.

0 Likes