basementjack Posted July 3, 2016 Share Posted July 3, 2016 Hi, How can I create a workflow that would display the current time in the alfred search box when I type in the keyword time? I emailed support and they said to come here and ask.... - Jack Link to comment
vitor Posted July 3, 2016 Share Posted July 3, 2016 See this post. The user there wanted something like what you want (but yours is even simpler). The workflow I made there is no longer available, but the instructions are there. Link to comment
basementjack Posted July 4, 2016 Author Share Posted July 4, 2016 Thanks Vitor. I tried what I saw in the picture, but no luck. I think my script block is ok. I have "tell application Alfred 3 to search show_time and I see the words "show_time" pop up in Alfred when i hit the assigned keystroke, so that part is working. The next line does a command-shift left arrow, selecting all the text. I don't need that so I removed it. What I'm not understanding is, how do I get the actual time to display, in the screenshots on that post it looks like the person who asked the question got a region to display right under alfred - how is that done? Also in the filter, I see where it /might/ be pulling the time command from the command line, but since I'm not seeing any output, I'm not sure if that's working. Thanks Vitor! Link to comment
basementjack Posted July 4, 2016 Author Share Posted July 4, 2016 Edit, never mind, I had Argument required in the filter, taking that off worked. I renamed a few things to 'time' and now I see the time as one of the many search results that match 'time' Ideally I'd like it on top, but Alfred seems to prioritize based on most used so the 2nd time I did it, the time was at the top. I'll fool around in the workflow system to see if I can find an option to force a result to the top. Thanks again Vitor! Link to comment
deanishe Posted July 7, 2016 Share Posted July 7, 2016 You can get the current time with the shell command date "+%H:%M:%S" and you can tell Alfred to display some text in its results list by passing it JSON from a Script Filter. So, create a Script Filter with the keyword "time" and No Argument. Then put this in the Script box (leave Language set to /bin/bash): t=$(date "+%H:%M:%S") cat <<EOS { "items": [ {"title": "$t"} ] } EOS That will return one result to Alfred, containing the current time. You're always likely to have an issue with other results using a common word like "time" as the keyword. I generally prefix my keywords with ".", which will exclude all of Alfred's default results. For this Script Filter, I might use ".t" instead of "time". Link to comment
basementjack Posted July 7, 2016 Author Share Posted July 7, 2016 Thanks Deanishe, the . thing is a great idea! Link to comment
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