Jump to content

Switch theme with hotkey/keyword ?


Recommended Posts

Theoretically, you could write a workflow that would do it by altering Alfred's preferences plist. But, currently, no.

 

(I'm assuming that you mean switching to a new Alfred theme).

 

Ya, switching to a different Alfred Theme.  I have an applescript to toggle Dark Mode in Yosemite ... thought it would be neat to also switch the theme in Alfred at the same time.

Link to comment

Well, you'll probably want to write it with a script filter. You'll need to grab the plists for the installed themes (I forget exactly where they are, but you can find the information by poking around in the file system), and then you'll need to get the set one. Then, on the argument, just change the current theme value for Alfred in the preferences plist. If I remember correctly, it stores the theme identifier based on the UID. Theoretically, when you replace that value in the plist, then the theme should switch.

Link to comment

Well, you'll probably want to write it with a script filter. You'll need to grab the plists for the installed themes (I forget exactly where they are, but you can find the information by poking around in the file system), and then you'll need to get the set one. Then, on the argument, just change the current theme value for Alfred in the preferences plist. If I remember correctly, it stores the theme identifier based on the UID. Theoretically, when you replace that value in the plist, then the theme should switch.

 

Crap ... it doesn't switch ... I mean, I can change the value in the prefs.plist, but Alfred will not update to the new theme automatically.

Link to comment

Crap ... it doesn't switch ... I mean, I can change the value in the prefs.plist, but Alfred will not update to the new theme automatically.

 

Are you using the correct preferences plist? With Yosemite, all the preferences paths changed. The new environmental variables help give you the correct path to it because it does look seemingly random.

 

@bcc2k, have you checked into my rewrite of the flux workflow?

Link to comment

Are you using the correct preferences plist? With Yosemite, all the preferences paths changed. The new environmental variables help give you the correct path to it because it does look seemingly random.

 

I have the correct plist ... but I only know a bit about terminal and bash ... so perhaps a 'defaults write' is not the correct way of changing the theme?

Link to comment

@bcc2k, have you checked into my rewrite of the flux workflow?

 

 

Yeah, it's awesome, but I'm talking about the feature where flux automatically starts Yosemite's dark mode after sun set. The problem is that Alfred doesn't change its theme accordingly. I couldn't find something like this in your workflow either, so I created an apple script that switches the Alfred theme. Unfortunately it's not as transparent as a direct API call, but for me at least, it's sufficient.

 

This script activates themes with the names "OS X Yosemite Auto" and "OS X Yosemite Dark Auto" depending on the dark mode state.

 

http://pastebin.com/YuH1r5Q8

 

I tested this Apple Script with the DarkMode workflow and it worked for me.

Next step is to call this script whenever flux starts DarkMode.

 

Edit:

Wait a second, with "rewrite" do you mean this workflow, right?

Edited by bcc2k
Link to comment

I have the correct plist ... but I only know a bit about terminal and bash ... so perhaps a 'defaults write' is not the correct way of changing the theme?

 

I'm not sure if `defaults write` would do it. You might look into `PlistBuddy` (`/usr/libexec/PlistBuddy`). The way you can test it would be to just run the command and see if the correct value in the preferences plist is updated. If it is and Alfred doesn't change, then it won't quite work.

Link to comment

Wait a second, with "rewrite" do you mean this workflow, right?

 

Yes, that's the one that I mean. Benzi wrote the original one, but it stopped working with an update for f.lux, and there were quite a few people asking to get a new copy, so I just redid it and posted it there. I think the "mood lighting" (I forget exactly what I called it) setting was my favorite to code. It's the one that makes your computer into a sort of "candle" with the screen brightness flickering. In a dark room, it actually does look a bit like candlelight, but the feature is totally impractical and was there just to satisfy my own whims. I know that it doesn't do what you want, but if you're a flux user, then it is probably helpful.

 

The problem with the applescript is that it opens up Alfred Preferences, which might be necessary, but it sucks from a UX standpoint. If Rodger can get his method working, then it'll be a much better way so that people won't need to see the Alfred Preferences window pop up.

Link to comment

I'm not sure if `defaults write` would do it. You might look into `PlistBuddy` (`/usr/libexec/PlistBuddy`). The way you can test it would be to just run the command and see if the correct value in the preferences plist is updated. If it is and Alfred doesn't change, then it won't quite work.

 

The correct value IS entered with a 'defaults write', but Alfred won't update the theme until I restart him.

 

And just to be thorough: Yes, I used not only 'defaults', but 'plistbuddy' as well.  BOTH can easily modify the value for 'theme' in the plist, and when I open Alfred the correct theme is actually selected in the appearance panel, just that, the theme won't take affect until Alfred reloads.

Edited by RodgerWW
Link to comment

The correct value IS entered with a 'defaults write', but Alfred won't update the theme until I restart him.

 

And just to be thorough: Yes, I used not only 'defaults', but 'plistbuddy' as well.  BOTH can easily modify the value for 'theme' in the plist, and when I open Alfred the correct theme is actually selected in the appearance panel, just that, the theme won't take affect until Alfred reloads.

 

... feature request?

Link to comment

I think the "mood lighting" (I forget exactly what I called it) setting was my favorite to code. It's the one that makes your computer into a sort of "candle" with the screen brightness flickering. In a dark room, it actually does look a bit like candlelight, but the feature is totally impractical and was there just to satisfy my own whims. I know that it doesn't do what you want, but if you're a flux user, then it is probably helpful.

 

The problem with the applescript is that it opens up Alfred Preferences, which might be necessary, but it sucks from a UX standpoint. If Rodger can get his method working, then it'll be a much better way so that people won't need to see the Alfred Preferences window pop up.

 

I tried the mood lighting mode yesterday and I must say I really like it and my girl friend too, btw :)

I know that the applescript is ugly and I hope that Andrew provides a better way to change the theme (feature request has been created). For me it was my first apple script, so I don't mind if it's a throw-away. I just wanted to try it out.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...