Sublime Forum

[Beta] ThemeChanger [ideas needed]

#1

[size=200][Beta] ThemeChanger for Sublime Text 2[/size]

[size=120]Introduction:[/size]
I always used to switch my color scheme depending on the amount of sunlight, because looking at a dark screen in a light environment or vice versa gives me eye strains. When developing I’m always focussed on the project and I always found myself changing the color scheme way to late when I was already feeling my eyes a little. So I made a simple bash script that switched my user preferences around 7:30 and 19:30, this didn’t work so well because every times I changed some settings. I forgot to do it in the backup files causing me to lose my settings. So I started developing this plugin. I think that every developer that uses Sublime Text 2 for most of their day should try this out to see the difference.

[size=120]Repository:[/size]
Beta: Github

[size=120]Want to help?[/size]

  • I’m currently looking for ideas to improve the plugin. Leave a comment with your suggestion.

  • The plugin is still in beta and since the plugin is quite a background plugin I need beta testers to find bugs and performance issues

  • If you would like to contribute to the plugin by developing, go over to the github page. I’ll always accept great pulls!

[size=120]Status[/size]
Version: Beta 0.2

[size=120]Bugs:[/size]

  • One report of the plugin deleting settings

[size=120]Changelog:[/size]
0.2

  • Rebuild the way settings are loaded, causing better performance. (Thanks to facelessuser)

  • Changed the timeformat to (H:i or H:i:s) for a better user experience (Thanks to facelessuser as well)

  • Solved issues depending on client

0.1.2

  • Big bugfix, used to reset preferences

  • README.md fix - Duplication of lines due to being inexperienced with git

0.1.1

  • Now checks what theme is should be on boot

  • Minor bugfixes

  • Updated README

0.1:

  • First working version

  • Changed status to beta

0 Likes

#2

I haven’t used the plugin because I have written my own, but I want to encourage someone to release an officially supported one (I have too many plugins right now as is and am not looking to release another one right now).

I did want to give some suggestions that may or may not help you. Feel free to disregard any of my suggestions :smile:.

  1. I can’t really see people needing per second resolution for theme changing. Probably hour and minute is enough.
  2. Also, I think it would be nice if you could just allow the time to be configured in a simple manner like this:
    [pre=#2D2D2D] {
    “theme”: “Packages/Color Scheme - Default/Monokai Bright.tmTheme”,
    “time”: “08:30”
    },
    {
    “theme”: “Packages/User/Color Scheme/Tomorrow-Night-Eighties.tmTheme”,
    “time”: “17:30”
    }[/pre]

Even though the theme file is not defining seconds, it is easy to convert this to a time object with in python, and even convert it to just seconds (which is what I do as well). Here is an example:
[pre=#2D2D2D] 1 from datetime import datetime, timedelta

12 def total_seconds(t):
13 return (t.microseconds + (t.seconds + t.days * 24 * 3600) * 10 ** 6) / 10 ** 6

22 def translate_time(t):
23 # Translate a string from format “H:M” into seconds
24 tm = time.strptime(t + “:00”, ‘%H:%M:%S’)
25 return total_seconds(timedelta(hours=tm.tm_hour, minutes=tm.tm_min, seconds=tm.tm_sec))[/pre]

  1. Also, I see you are having a settings file reload issue. This is not a bug in ST2. There is a simple solution provided in the API. You can use add_on_change to define an function to run when the settings file changes. You just give it a pointer to the function or a lambda.
    [pre=#2D2D2D] 8 # Init the settings object
    9 SETTINGS = sublime.load_settings(‘ThemeScheduler.sublime-settings’)

153 # Reset the theme scheduler object if the settings file has changed
154 SETTINGS.add_on_change(‘reload’, ThemeScheduler.init)[/pre]

Maybe these suggestions will help, anyways, good luck with your plugin.

0 Likes

#3

Thanks for the suggestions.
I’m quite new to python and the ST2 API so at least thanks for suggestion 3, this is a way more efficient way than I’m using right now!

And to combine suggestion 1 and 2. I like to give people full control over the time so I’ll include seconds, but you have a valid point that using the way you format time is more user friendly.So I’ll make it that you can decide whether you want to define it with (08:30:15) or without (08:30) seconds.

I’m quite busy at the moment but I’ll commit the changes to the plugin either today or tomorrow :smiley:

Thanks again for these great suggestions!

0 Likes

#4

[size=200]Update![/size]
[size=150]Version Beta 0.2[/size]

[size=120]What’s changed?[/size]

  • Rebuild the way settings are loaded, causing better performance. (Thanks to facelessuser)

  • Changed the timeformat to (H:i or H:i:s) for a better user experience (Thanks to facelessuser as well)

  • Solved issues depending on client

0 Likes