Jump to content

rice.shawn

Member
  • Posts

    973
  • Joined

  • Last visited

  • Days Won

    57

Everything posted by rice.shawn

  1. If I had the extra time to code it for you, then I would, but unfortunately, I'm way too swamped at the moment.
  2. You might have more options depending on what kind of server the remote files are on. You might be able to tap into native search utilities there or use the "locate" command from command line, although, this might mean that you'd need to update the database each time, which has a funky command in OSX (it isn't just "updatedb" like it is on most linux systems). For instance, you could write something that would go to the base directory and run "ls -RAl" and then parse the output for you. It depends on the directory structure as to the amount of output that you get, so, that might be intense. That command lists the directory recursively with each item on a single line. Here is example output from part of a directory in a drupal installation: ./sites/topos/themes/garland: total 104 drwxr-xr-x 2 www-data root 4096 Sep 9 23:22 color -rw-r--r-- 1 www-data root 814 Aug 7 22:04 comment.tpl.php -rw-r--r-- 1 www-data root 1320 Aug 7 22:04 fix-ie.css -rw-r--r-- 1 www-data root 1162 Aug 7 22:04 fix-ie-rtl.css -rw-r--r-- 1 www-data root 409 Aug 7 22:17 garland.info drwxr-xr-x 2 www-data root 4096 Sep 9 23:22 images -rw-r--r-- 1 www-data root 5116 Aug 7 22:04 logo.png -rw-r--r-- 1 www-data root 2749 Aug 7 22:04 maintenance-page.tpl.php -rw-r--r-- 1 www-data root 992 Aug 7 22:04 node.tpl.php -rw-r--r-- 1 www-data root 2914 Aug 7 22:04 page.tpl.php -rw-r--r-- 1 www-data root 1047 Aug 7 22:04 print.css -rw-r--r-- 1 www-data root 10950 Aug 7 22:04 screenshot.png -rw-r--r-- 1 www-data root 20786 Aug 7 22:04 style.css -rw-r--r-- 1 www-data root 4967 Aug 7 22:04 style-rtl.css -rw-r--r-- 1 www-data root 4451 Aug 7 22:04 template.php -rw-r--r-- 1 www-data root 753 Aug 7 22:04 theme-settings.php ./sites/topos/themes/garland/color: total 48 -rw-r--r-- 1 www-data root 20894 Aug 7 22:04 base.png -rw-r--r-- 1 www-data root 5959 Aug 7 22:04 color.inc -rw-r--r-- 1 www-data root 922 Aug 7 22:04 preview.css -rw-r--r-- 1 www-data root 9965 Aug 7 22:04 preview.png You could parse those well enough with a few regular expressions. If you're really ambitious, then you could always create something that would index the filename on the server and then cache it in a sqlite3 database. You'd have to manually update the database (although, if you're using something that reacts to events, then you could have this run each time the drive connects). If you cache it in a database, then the search would take less time. Or, there might be other tools that do these things already that I don't know about. I know that this might seem intimidating for someone who isn't as familiar with the terminal, but it might be a good project to do to learn more. Shawn
  3. Here you go: https://github.com/shawnrice/one-off-experiments/raw/master/tt.alfredworkflow
  4. I'll post one in a bit. I have a bunch of other stuff to do on a timeline within the next few hours. But if you're interested in dealing with transmission, then why not just use a bash script that controls transmission? It looks like it has a full way to script it integrated (https://trac.transmissionbt.com/wiki/Scripts). Then, if you want, you could automatically invoke an applescript through viscosity that is triggered when it disconnects (poke around: https://www.sparklabs.com/support/running_applescripts_when_conn/). Use the applescript to trigger another transmission script that will start them back up. Then, your Alfred workflow would just invoke that script to shutdown transmission, which could also then execute another script in serial to startup Viscosity. I'll post a workflow later tonight with the abstracted workflow from above.
  5. This works just fine and dandy for me with all iterations of programs open/closed (although I have to open safari to test the if statement at one point). It works file with the action -> execute script and "osascript" selected. It also works fine with NSApplescript (as long as you put it between the templated alfred run and end alfred tags). Granted, they are launched in the background (is that not what you're looking for?). Further thoughts: I'm running 10.8.4, with Alfred v2.0.7 (205). I don't think that there would be any other possible variables that would matter... Lastly... why, if you're trying to control Transmission would you want to activate TextEdit? I don't get it.
  6. Incidentally, the modified code below works just fine in Alfred's osascript -- tell application "System Events" if (name of processes) contains "Safari" then set is_running to true else set is_running to false end if end tell if is_running is true then tell application "TextEdit" to activate end if if is_running is false then tell application "Preview" to activate end if
  7. osascript doesn't have the ability to use dialogs and other events like that. I did find a way around that once, however, (and I forgot how), by calling a script file from a bash shell invoking osascript. At least it was something like that.
  8. There are only a few resources that you can count on being loaded on every Mac. Alfred does a pretty good job covering the standard ones. I'm sure, however, that you could write a bridge from a bash env to another one fairly easily -- if you have the need. However, there would be less of a demand for those environments because they're quite often not standard on all Macs. Adding extra environments that are not always available would bloat Alfred, which isn't that great. You should be able to do most everything that you need from a bash environment anyway.
  9. You could also background the server startup commands. It would give you fewer windows. Then, if you wanted, you could make another workflow (or add on to that one with a new keyword/argument) that would just kill the rails and postgres server. To delay, look into the "sleep" command. So, just have it sleep for like two seconds. I haven't opened the workflow, so I don't know which language you did it in, but for most, it's pretty much something like 'sleep(2);' or 'sleep 200' depending on whether the function interprets it as milliseconds or seconds. Lastly, you could open the Sublime Text 2 with Applescript and then script the menus with System Events. You'd have to wait a second and not touch the computer while it blows through the menu commands for you... but it is possible.
  10. I saw some 404's, so I updated the link here. --- Just create a keyword trigger; then put in a script action that uses bash, then just paste that in there. Make sure that when you use the keyword trigger (not a script filter), that you select "no argument." Otherwise, it will do something waiting for an argument. Doublecheck the bash syntax by opening it in a terminal. The other possible problem that you might be running into is a permissions one. Make sure that your regular user can execute that command. Otherwise, put a sudo in front of it. If you want to make sure you don't need a password, then add a line to your sudoers file that lets you execute that command passwordless. If you need more, then download this workflow (https://github.com/shawnrice/alfred2-dhcp-toggle/blob/master/workflows/dhcp-toggle.alfredworkflow?raw=true) and see how it works. Shawn
  11. You probably need to do this with a script filter. Look more into how those work to see if that gives you what you need.
  12. Sorry about the delay. So, the bash environment works differently than the rest of the system. It looks like the solution to your problem may be here: http://tomayko.com/writings/os-x-network-location-support-from-the-command-line. I can't really test it out because I don't use the proxy. If this works, then you can script it a bit better and just invoke the script to start the proxy and to disable it. Hope that helps.
  13. I might be able to help a bit more if I can know more about your proxy setup. Anything you can tell me to help me troubleshoot? One test that you could do would be to plop the following code into a file, run 'php myfile.php' and see if there is a difference in the output when you're on the proxy and when you're not: <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://api.wunderground.com/api/67350ed2995fb73f/conditions/q/NY/11211.json'); curl_exec($ch); print_r($ch); curl_close($ch); ?> It should put out quite a bit of json, so if it just gives you a bunch of text rather than an error message, then we'll know something.
  14. Here's yet another one (EventScripts): it seems a bit more polished. http://www.mousedown.net/mouseware/EventScripts.html ($3 in the App Store). Of course, it's probably easiest to just to trigger it from Alfred instead of worrying about an automated event change.
  15. It looks like you could also look into crankd (here's a link: http://grahamgilbert.com/blog/2013/07/12/using-crankd-to-react-to-network-events/) for the automation part.
  16. From what I can tell, the proxy settings are a sort of system-wide thing that bash (and probably php, ruby, etc... when run from bash) don't play well with automatically. One thing you could do to try to fix it, however, is to look into the command tool "networksetup." With that, you can control quite a few things about your network preferences, including some proxy settings. If you can figure out exactly which commands you'll need to use to set your proxy, then you can just make your own workflow so that you can change things. Then you'd just switch the proxy whenever you wanted to with a quick command. Alternately, you could use the same script that you would use for Alfred and automate it with Griffin's Proxi (here's a review about it: http://reviews.cnet.com/8301-13727_7-57368606-263/how-to-trigger-os-x-system-events-with-griffin-proxi/) so that whenever you connected to a certain network, it would change the proxy settings. Hope that some of that helps.
  17. Also, look at the Egg Timer workflow that's somewhere on this forum. It can show you a script could give you updates. If you have growl installed, then your bash script could just execute a command like growlnotify -n "My App" -m "Hello world" randomly at intervals to keep you updated. At the end, the script can launch an applescript via the command line to open the tab via chrome. --OR-- I'm not sure if you are looking to have the script progress open in a Chrome tab. If that's the case, then you'd just generate the initial report (via bash writing a markdown or html file), and, in the html file, use some javascript to set a refresh interval on the page. If you just have the bash script rewriting the html page (or markdown), then it should refresh on the interval. I'm not sure that answers your question. If it doesn't, then could you tell me more about what Jekyll Watch does?
  18. This seems like a cool idea. I've been experimenting with workflows that have configuration options, and I've been doing so with Applescript dialogs, which, even though they are ugly, work well enough for simple configurations. I'm playing with another one that includes an automator web hud and a python pop-up web server that can handle more advanced configurations through more of a web interface. It's been fun.
  19. Updated to include notifications. Pushed new files to github. Same download links.
  20. DHCP Toggle Find it on: Packal: DHCP Toggle Github: DHCP Toggle Repository Short Description Set your DHCP Settings via Alfred. Long Description DHCP Toggle allows you to alter your DHCP settings between a manual and an automatic configuration. When you set an automatic configuration, which is normal, your computer will receive an IP address directly from the router that you’re connected to. If you choose manual, you have the option of setting your own IP address. If the router’s IP address is 10.0.1.1, then you’ll be able to get an IP with a prefix of 10.0.1 and a suffix between 2 and 255. If the IP address is already used, then you’ll have to try again. DHCP Toggle will also set your router address to the IP prefix that you use, followed by 1, which is always reserved for the router. You can use this when your Internet connection is weak, or if a router is clogged, or if, for some random reason, the router doesn’t like you connecting with an automatic IP address (the original need for this workflow). Commands dhcp <arg> Available arguments: None: defaults to your default IP prefix + random number 2–255 Switch to auto: auto IP Address: 10.0.1.192 Number: 2–255, i.e. 32 Configure c Configuration Default Prefix You can set a default prefix, the first three numbers of an IP address, which will be given precedence over the other available prefixes. If you just type a three-digit number (between 2–255), then it will set your IP address to DEFAULTIP.NUMBER. IP Prefixes You can set a list of prefixes that you commonly use, and those will appear in the script filter to choose easily. If no prefixes file is found, then the following list will be populated: 10.0.0 10.0.1 192.168.0 192.168.1 192.168.2 192.1.10 You can add and remove from this list from the configuration option. Passwordless Execution (sudo) If you would prefer to use this workflow without a password, you can select the option to add a record to your sudoers file. The script will add the line $USER ALL=NOPASSWD:/usr/sbin/networksetup to your /etc/sudoers file, where $USER is your username; so, the $USER will now be able to execute the command networksetup without needing to enter a password. The script checks the syntax with visudo to make sure that it doesn’t bork your /etc/sudoers file. So, it’s safe. Demo Credit Thanks for version 2.0 goes to Pryley (Github | Alfred Forum) who opened a pull request for the added features and contributed some code. Issues Please report coding issues on the Github issue queue. Other support should be posted on the Alfred Forum thread.
  21. I don't have a copy of it and don't use subversion (I do like git), so I can't write the workflow for you, but perhaps you might outline what features you'd want to have in the workflow so that whichever kind soul takes up this endeavor knows what sorts of things need to be done.
  22. I'll add it to my queue. If no one has written it before I get to it, then I'll have a try with it.
  23. Moved to Manhattan? Using Time Warner with an Ubee Modem? That's your problem (fn**#@#$ TW). If you complain enough, then you can possibly get them to replace the Ubee modem. A neighbor of mine get a Motorola Surfboard, and he says it's working much better now. Good luck.
  24. Hack: Alter the workflow scripts so that they issue the system command "open -a Safari http://www.urlfromargument.com" For instance, if using php, then the syntax would be something like $url = $urlfromargument; $cmd = 'open -a Safari ' . $url; shell_exec($cmd); The url needs to have 'http://' in it.
  25. Oh... good use: if you use ctrl+space to launch alfred, then assign option+space as the hotkey for that applescript.
×
×
  • Create New...