RodgerWW Posted November 6, 2014 Posted November 6, 2014 IS it possible to switch a theme based on a hotkey or keyword? I am having a hard time finding this info in the forums,
rice.shawn Posted November 6, 2014 Posted November 6, 2014 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).
RodgerWW Posted November 6, 2014 Author Posted November 6, 2014 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.
rice.shawn Posted November 6, 2014 Posted November 6, 2014 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.
RodgerWW Posted November 7, 2014 Author Posted November 7, 2014 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.
bcc2k Posted November 8, 2014 Posted November 8, 2014 +1 on that. I just found this thread but already created a feature suggestion: Auto-change theme on dark mode because of flux
rice.shawn Posted November 9, 2014 Posted November 9, 2014 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?
RodgerWW Posted November 9, 2014 Author Posted November 9, 2014 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?
bcc2k Posted November 10, 2014 Posted November 10, 2014 (edited) @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 November 10, 2014 by bcc2k
rice.shawn Posted November 10, 2014 Posted November 10, 2014 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.
rice.shawn Posted November 10, 2014 Posted November 10, 2014 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.
RodgerWW Posted November 10, 2014 Author Posted November 10, 2014 (edited) 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 November 10, 2014 by RodgerWW
rice.shawn Posted November 10, 2014 Posted November 10, 2014 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?
bcc2k Posted November 10, 2014 Posted November 10, 2014 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.
Andrew Posted November 10, 2014 Posted November 10, 2014 I'll be adding in the ability to switch themes based on name in the next Alfred release: http://www.alfredforum.com/topic/5138-change-the-alfred-theme-within-a-workflow/#entry31375 In the case of duplicates, it will set it to the first matching name in the list. I didn't do this by UID for now as these aren't revealed in Alfred's UI.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now