lionroot Posted November 9, 2018 Posted November 9, 2018 Hello, I've searched for a bit but have been unable to find how I create a counter. For instance, each day a new counter starts, and anytime I invoke my process, one is added to the daily counter. At the end of the day I intend to store the counter in a google sheet (this is about habit formation). Thanks!
vitor Posted November 9, 2018 Posted November 9, 2018 Welcome @lionroot, You explanation is quite bare. It’s quite difficult to understand what you want. Please describe what you’d like your Workflow to accomplish and how to run it, in steps (1. Call Alfred; 2. Type “something”; 3. This happens). Also, keep in mind that by design Alfred needs you to tell it to do things for them to happen, it does not start tasks without them being invoked.
dfay Posted November 9, 2018 Posted November 9, 2018 (edited) I used to use a workflow which had a counter stored in a file. Here'e the AppleScript I used to read/update it. -- get the counter value and increment it set theID to (do shell script "cat ~/Dropbox/texts/nv/_counter.txt") set n to (theID as number) + 1 do shell script ("echo \"" & (n as string) & "\" > ~/Dropbox/texts/nv/_counter.txt") you'd just need to add code to check the date and reset it if it has changed since the last run. I'd personally use Hazel for that but either way you'd test based on the file modification date and if it's before the current date, reset the contents of _counter.txt to 1. Likewise the end of the day task (as Vitor implies) is probably better handled by Hazel. But that could depend on whether the update to the spreadsheet really needs to be done nightly or whether it could be done at the next run, even if that's a day or two later. Edited November 9, 2018 by dfay
lionroot Posted November 10, 2018 Author Posted November 10, 2018 Thanks guys! 1 - Call Aflred 2 - Type "habit" (I'll change the word based on which habit I'm tracking) 3 - Habit retrieves the stored value from a file (or starts at 0 for a new day), and increases the value by 1, then displays what count I'm at, and plays an audio clip (I'll put in like a Legend of Zelda award noise because I'm a gamer) 4 - Habit counter stores the value in a text script, at the end of the day, a new habit with the date is started at 0 5 - I open the file, and look at it the next day, and record the value in my google sheets to help me track the habit
deanishe Posted November 10, 2018 Posted November 10, 2018 17 hours ago, dfay said: I used to use a workflow which had a counter stored in a file. These days, you could use Alfred's configuration API to store the counter(s) in info.plist. That way, Alfred would retrieve the values for you and provide them as environment variables.
dfay Posted November 10, 2018 Posted November 10, 2018 Yes that was written under Alfred 2 I believe...
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