Search the Community
Showing results for tags 'loop'.
-
I have a workflow (download it here: https://cl.ly/3C0n0e1n3W2N) that works and allows me to select some text like "12345" and use a hotkey to launch a URL of https://example.com/issues/{query} -> https://example.com/issues/12345 However, I want to enhance it to be able to support selecting text like "12345,281928", do the hotkey, then open two browser tabs: {query} -> A = 12345 B = 281928 1: open https://example.com/issues/12345 2: also open https://example.com/issues/281928 last one? then we're all done. I know PHP well so I could do explode( ',' {query} ), but I'm not sure how to use {query} (is it usable in a PHP script?) and I'm not sure how to tell it to loop through all the items in the array. If Alfred can't use PHP to do this, that's fine, but I'm not well versed in bash, AppleScript, and the rest. Thanks for any help!
-
I have a workflow that is listening for spotify ads (so i can mute them). I have a while loop listening. When it finds an ad (a track with < 35 second duration), it sends a notification - but not an alfred style post notification; just the default applescript-like notification. Here's the code: Note: osascript -e "display notification \"Muting ad for $sleepDuration seconds\" with title \"Mute Spotify Ads\"" This is what I'd like to replace with an alfred Post Notification. vol=`osascript -e 'tell application "Spotify" to sound volume as integer'`; while : do state=`osascript -e 'tell application "Spotify" to player state as string'`; sleepDuration=1 if [ $state = "playing" ]; then duration=`osascript -e 'tell application "Spotify" to duration of current track as string'`; duration=$(echo "$duration / 1000" | bc); if [ $duration -le 35 ]; then position=`osascript -e 'tell application "Spotify" to player position as string'`; position=$(echo "$position" | bc); sleepDuration=$(echo "$duration - $position" | bc); osascript -e "tell application \"Spotify\" to set sound volume to 1"; if [ $sleepDuration -le 0 ]; then sleepDuration=1; else osascript -e "display notification \"Muting ad for $sleepDuration seconds\" with title \"Mute Spotify Ads\"" sleep $sleepDuration; osascript -e "tell application \"Spotify\" to set sound volume to $vol"; sleepDuration=1; fi else osascript -e "tell application \"Spotify\" to set sound volume to $vol"; sleepDuration=1; fi sleep $sleepDuration; else break; fi done osascript -e "tell application \"Spotify\" to set sound volume to $vol";
- 2 replies
-
- notification
- bash
-
(and 2 more)
Tagged with:
-
Hi folks, I manage to create the following script in php that's working. The aim is to extract and use multiple parameters from a single {query}. Here's a simplified example: $query = explode(' ', '{query}'); $elemA = $query[0]; $elemB = $query[1]; $elemC = $query[2]; echo "{$elemA}{$elemB}{$elemC}"; I would like to do the same in bash but cannot manage to get it work. Here's my try: This one is working outside Alfred, directly for my Terminal. Basically, it also automatically detect any space as a separator. query="{query}" i=1 for param in $query; do case $i in 1) elemA=$param;; 2) elemB=$param;; 3) elemC=$param;; esac i=$[i+1] done echo "${elemA}${elemB}${elemC}" From all my tries, I've not been able to enter the "for" loop statement… Would you have any idea? Thanks in advance, Cheers, Édouard.
-
I created a workflow that uses the keyword 'test' to launch a NSAppleScript process that displays Alfred with the text 'test ' & the entered query, thus allowing a loop. If I hold enter, the loop will continue for several seconds until it finally uses a fallback search (which did not have a query). When I open Alfred again, he looks like this: The workflow was merely a stress test for Alfred; I can't imagine any place this would be an actual issue. There was no Console output. Alfred v2.0 (141) on OS X 10.8.2. Replicated: yes
-
- loop
- NSAppleScript
-
(and 1 more)
Tagged with: