-
Notifications
You must be signed in to change notification settings - Fork 0
/
changeThemeCommand.py
36 lines (30 loc) · 1.1 KB
/
changeThemeCommand.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sublime, sublime_plugin, functools
import os,time
class SwitchthemeCommand(sublime_plugin.TextCommand):
def findThemesInPath(self, themesName, path, go):
files = os.listdir(path)
for f in files:
if os.path.isfile(path + '/' + f):
if str(f).endswith('tmTheme'):
themesName.append(path + '/' + f)
else:
if go:
self.findThemesInPath(themesName, path + '/' + f, False)
def getThemesName(self):
themes = []
packages_path = sublime.packages_path()
self.findThemesInPath(themes, packages_path, True)
themesName = []
for themeName in themes:
themesName.append(themeName.replace(packages_path, 'Packages'))
return themesName
def changeColorful(self, themesName):
s = sublime.load_settings("Preferences.sublime-settings")
currentTheme = s.get('color_scheme')
index = themesName.index(currentTheme)
newTheme = themesName[(index+1)%len(themesName)]
s.set('color_scheme', newTheme)
sublime.save_settings("Preferences.sublime-settings")
#callback = functools.partial(self.changeColorful(themesName))
def run(self, edit):
self.changeColorful(self.getThemesName())