Home Download Buy Blog Forum Support

Automatic Theme Selection for ST2 on Mac

Automatic Theme Selection for ST2 on Mac

Postby reclusivemonkey on Mon Aug 05, 2013 6:58 pm

After playing around with http://www.ifttt.com the other day I thought it would be pretty cool if I could set the Sublime Text 2 depending on the time of day. For example, at sunset I would like to have the Solarised (Dark) theme, and then at sunrise have the Solarized (Light) theme.

**CAVEAT: try this at your own risk!** I've tested it out and it works fine for me but as you can tell from my script, I'm certainly no expert. Any suggested improvements are welcome.

1. Set up an IFTTT rule for sunset; https://ifttt.com/recipes/109559. Simply put I just use the weather trigger for sunset and then use a dropbox action to add a file to my IFTTT/Daylight folder called sunset.txt with 'Dark' in there. Do the same for sunrise with 'Light'
2. Add an automator folder action on your Dropbox/IFTTT/Daylight folder of the type 'shell script' with the following code in;

Code: Select all

   CURRENTSETTING=`grep tmTheme ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/Preferences.sublime-settings | awk -F'[(|)]' '{print $2}'`
   sed -i '.bak' 's/('$CURRENTSETTING').tmTheme/('$NEXTSETTING').tmTheme/' '/Users/luke/Library/Application Support/Sublime Text 2/Packages/User/Preferences.sublime-settings'

3. That's it!

Note: this doesn't change syntax specific theme settings but I am sure it could be expanded to do so.
Posts: 2
Joined: Sun Aug 12, 2012 7:56 am

Return to Ideas and Feature Requests

Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests