aviaryan Posted August 31, 2017 Posted August 31, 2017 Alfred - CLC This workflow adds a powerful calculator right in your Alfred bar. Installing Install insect brew install insect # or npm install -g insect Then download CLC workflow file and double click to open it with Alfred. Using clc [expression] Example expressions sqrt(1.4^2 + 1.5^2) * cos(pi/3)^2 2 min + 30 s 40 kg * 9.8 m/s^2 * 150 cm 60 mph -> m/s 6 Mbit/s * 1.5 h -> GB # sum of the first ten squares sum(k^2, k, 1, 10) NOTE: Since this workflow uses insect for the calculations, please see its README for more possible types of expressions. Screenshots GitHub: https://github.com/aviaryan/alfred-clc Download: https://github.com/aviaryan/alfred-clc/raw/master/clc.alfredworkflow Packal: http://www.packal.org/workflow/clc
xilopaint Posted August 31, 2017 Posted August 31, 2017 (edited) Is it not possible to bundle the workflow with insect? Edited September 1, 2017 by xilopaint
aviaryan Posted September 1, 2017 Author Posted September 1, 2017 10 hours ago, xilopaint said: Is not possible to bundle the workflow with insect? The only way insect is installed is by first installing NodeJS and then installing insect globally using npm (same thing happens under the hood using homebrew). I don't think it would be a good idea to bundle it with the workflow.
xilopaint Posted September 1, 2017 Posted September 1, 2017 (edited) Not working for me: [2017-09-01 02:49:16][STDERR: input.scriptfilter] /Users/xxx/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.1831759F-4FB8-40C5-B097-A5D3D126312C/run.sh:12: command not found: insect Edited September 1, 2017 by xilopaint
aviaryan Posted September 1, 2017 Author Posted September 1, 2017 8 minutes ago, xilopaint said: Not working for me: [2017-09-01 02:49:16][STDERR: input.scriptfilter] /Users/xxx/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.1831759F-4FB8-40C5-B097-A5D3D126312C/run.sh:12: command not found: insect Please see https://github.com/aviaryan/alfred-clc/issues/1. There is a possible fix there. I think applying it should fix your problem. I will update the workflow soon.
xilopaint Posted September 1, 2017 Posted September 1, 2017 It works, but the calculator is a bit slow. Any chance to speed up?
deanishe Posted September 1, 2017 Posted September 1, 2017 That seems an excessively complex solution. Can't you just use /usr/local/bin/insect? FWIW, whether or not your shell can find insect isn't super helpful. Alfred doesn't use your shell's environment. The best solution is to bundle the dependencies in your workflow. This isn't a perfect solution with Node-based workflows, as you still have to install Node, but the workflow will at least "Just Work" for people who have Node installed without them having to install an extra bunch of stuff just for your workflow. On every Mac they have. Also, installing dependencies globally is a fundamentally bad idea, and should be avoided if possible. xilopaint and aviaryan 2
aviaryan Posted September 1, 2017 Author Posted September 1, 2017 (edited) 12 minutes ago, xilopaint said: It works, but the calculator is a bit slow. Any chance to speed up? I think it is slow because of the multiple computations that are being sent to it while you type. I will try to do something to improve this. 10 minutes ago, deanishe said: That seems an excessively complex solution. Can't you just use /usr/local/bin/insect? I remember it didn't work out earlier for some reason (hence a lot of comments in the run.sh script). I will try it again now. EDIT - It didn't work with #!/bin/bash. Works with zsh. 10 minutes ago, deanishe said: The best solution is to bundle the dependencies in your workflow. This isn't a perfect solution with Node-based workflows, as you still have to install Node, but the workflow will at least "Just Work" for people who have Node installed without them having to install an extra bunch of stuff just for your workflow. On every Mac they have. If you can point me towards an example workflow, that would be awesome. ? Edited September 1, 2017 by aviaryan
deanishe Posted September 1, 2017 Posted September 1, 2017 I'm afraid I don't know of an example. I generally avoid Node workflows due to the inevitable external dependency on Node. But npm defaults to local installations, so if you just use npm "normally", you can call your program with ./node_modules/.bin/program_name Re using /usr/local/bin/insect vs changing PATH, using a full path won't work if the shebang isn't also a full path. In that case, this should be sufficient: export PATH=$PATH:/usr/local/bin
aviaryan Posted September 4, 2017 Author Posted September 4, 2017 On 9/1/2017 at 0:11 PM, deanishe said: But npm defaults to local installations, so if you just use npm "normally", you can call your program with ./node_modules/.bin/program_name That is a good idea. Will try it out in the next version. ?
aviaryan Posted September 6, 2017 Author Posted September 6, 2017 On 9/1/2017 at 11:49 AM, xilopaint said: It works, but the calculator is a bit slow. Any chance to speed up? Try out the latest release. It has a slight but noticeable speed improvement. xilopaint 1
craw Posted September 28, 2021 Posted September 28, 2021 Very cool, works fine on this Big Sur machine and speed on this machine is fine. Great work thanks for doing this.
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