├── LICENSE ├── Makefile ├── Mount Network Share.alfredworkflow ├── README.md ├── screenshot-unmount.png ├── screenshot.png ├── src ├── 6B492BDF-9554-4B32-9FC7-70299B4F6CF0.png ├── eject.png ├── icon.png ├── info.plist └── update.json └── workflow.json /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 by Patrick Stadler 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | zip -j9 --filesync Mount\ Network\ Share.alfredworkflow src/* -------------------------------------------------------------------------------- /Mount Network Share.alfredworkflow: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pstadler/alfred-mount/f0fef48ac23d6e070e0b253c43ce39c7b59cac2c/Mount Network Share.alfredworkflow -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mount Network Shares with Alfred 2 | 3 | > Connect to your network shares with ease. 4 | 5 | Available shares will **be automatically discovered** and listed within Alfred. 6 | 7 | ![Screenshot of "Mount Network Shares with Alfred"](screenshot.png) 8 | 9 | ![Screenshot of "Mount Network Shares with Alfred"](screenshot-unmount.png) 10 | 11 | [Download](Mount%20Network%20Share.alfredworkflow?raw=true) 12 | -------------------------------------------------------------------------------- /screenshot-unmount.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pstadler/alfred-mount/f0fef48ac23d6e070e0b253c43ce39c7b59cac2c/screenshot-unmount.png -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pstadler/alfred-mount/f0fef48ac23d6e070e0b253c43ce39c7b59cac2c/screenshot.png -------------------------------------------------------------------------------- /src/6B492BDF-9554-4B32-9FC7-70299B4F6CF0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pstadler/alfred-mount/f0fef48ac23d6e070e0b253c43ce39c7b59cac2c/src/6B492BDF-9554-4B32-9FC7-70299B4F6CF0.png -------------------------------------------------------------------------------- /src/eject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pstadler/alfred-mount/f0fef48ac23d6e070e0b253c43ce39c7b59cac2c/src/eject.png -------------------------------------------------------------------------------- /src/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pstadler/alfred-mount/f0fef48ac23d6e070e0b253c43ce39c7b59cac2c/src/icon.png -------------------------------------------------------------------------------- /src/info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bundleid 6 | pstadler/alfred-mount 7 | connections 8 | 9 | 5C4A76F4-0175-48DE-AA23-7F7F70AB8659 10 | 11 | 6B492BDF-9554-4B32-9FC7-70299B4F6CF0 12 | 13 | 14 | destinationuid 15 | 3BABCA7A-880C-45B6-A4CC-03B301CB4991 16 | modifiers 17 | 0 18 | modifiersubtext 19 | 20 | 21 | 22 | C3BD5BCD-E58A-491B-93B0-951192C4BAC9 23 | 24 | 25 | destinationuid 26 | 5C4A76F4-0175-48DE-AA23-7F7F70AB8659 27 | modifiers 28 | 0 29 | modifiersubtext 30 | 31 | 32 | 33 | 34 | createdby 35 | Patrick Stadler 36 | description 37 | Mount a network share with automatic discovery 38 | disabled 39 | 40 | name 41 | Mount Network Share 42 | objects 43 | 44 | 45 | config 46 | 47 | argumenttype 48 | 2 49 | escaping 50 | 63 51 | keyword 52 | unmount 53 | runningsubtext 54 | Find mounted shares... 55 | script 56 | #!/bin/bash 57 | 58 | out='' 59 | while read -r line; do 60 | local_path=$(echo $line | sed 's/^.* on \(.*\) (.*/\1/g') 61 | remote=$(echo $line | sed 's/^.*@\(.*\) on .*/\1/g') 62 | host=$(echo $remote | cut -f1 -d '/') 63 | share=$(echo $remote | cut -f2 -d '/') 64 | 65 | out+="<item arg=\"$local_path\" uid=\"$remote\" valid=\"yes\">\ 66 | <title>$share</title>\ 67 | <subtitle>$local_path — on $host</subtitle>\ 68 | <icon>eject.png</icon>\ 69 | </item>" 70 | done < <(mount | grep '^//') 71 | 72 | echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><items>$out</items>" 73 | subtext 74 | Disconnect a network share 75 | title 76 | Unmount Network Share 77 | type 78 | 0 79 | withspace 80 | 81 | 82 | type 83 | alfred.workflow.input.scriptfilter 84 | uid 85 | 6B492BDF-9554-4B32-9FC7-70299B4F6CF0 86 | 87 | 88 | config 89 | 90 | argumenttype 91 | 1 92 | escaping 93 | 63 94 | keyword 95 | mount 96 | runningsubtext 97 | Discovering shares... 98 | script 99 | #!/bin/bash 100 | shopt -s nocasematch 101 | 102 | query="{query}" 103 | 104 | HOSTNAME=`hostname` 105 | 106 | function escape_hostname { 107 | echo $(echo "$@" | sed 's/(.*)$//g;s/[^a-zA-Z0-9 -_]//g;s/[ _]/-/g') 108 | } 109 | 110 | trap '{ 111 | mounted_volumes=$(mount) 112 | for host in $(printf "%s\n" "${hosts[@]}" | sort -u); do 113 | # password=$(security find-internet-password -l "$host" -w) 114 | while read -r line; do 115 | if [[ "$line" == *Disk* ]]; then 116 | share=$(echo $line | tr -s " " | sed "s/ Disk.*$//g;s/[^a-zA-Z0-9 -_]//g;s/ _/-/g") 117 | if [[ $mounted_volumes != *"$host"*"$share"* && ($share =~ "$query" || -z "$query") ]]; then 118 | out+="<item arg=\"$host/$share\" uid=\"$host/$share\" valid=\"yes\">\ 119 | <title>$share</title>\ 120 | <subtitle>on $host</subtitle>\ 121 | <icon>icon.png</icon>\ 122 | </item>" 123 | fi 124 | fi 125 | done < <(smbutil view -g //@$(echo $host | sed "s/\.local$//g") 2> /dev/null) # strip .local for faster resolution 126 | done 127 | # shares=`` 128 | if [ -z "$out" ]; then 129 | out="<item arg=\"$query\" uid=\"$query\" valid=\"yes\">\ 130 | <title>Connect to...</title>\ 131 | <subtitle>Enter path to network share: &lt;host&gt;/&lt;share&gt;</subtitle>\ 132 | <icon>icon.png</icon>\ 133 | </item>" 134 | fi 135 | echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><items>$out</items>" 136 | }' EXIT 137 | 138 | hosts=(); i=0 139 | while read -r line; do 140 | i=`expr $i + 1` 141 | 142 | if [ $i -lt 5 ]; then continue; fi # skip the header lines 143 | 144 | name=$(echo "$line" | tr -s ' ' | sed 's/^.*_afpovertcp\._tcp\. //g') 145 | domain=$(echo $line | tr -s ' ' | cut -d ' ' -f 5) 146 | domain="${domain%?}" 147 | hostname="$(escape_hostname $name).$domain" 148 | 149 | if [[ "$hostname" != "$HOSTNAME" ]]; then 150 | hosts+=("$hostname") 151 | fi 152 | 153 | if [ $(echo $line | cut -d ' ' -f 3) -ne '3' ]; then break; fi # break if no more items will follow 154 | 155 | done < <((sleep 0.5; kill -13 0) & # kill quickly if trapped 156 | dns-sd -B _afpovertcp._tcp) 157 | 158 | # silently kill subprocess 159 | kill -13 0 160 | exit 0 161 | subtext 162 | Connect a network share 163 | title 164 | Mount Network Share 165 | type 166 | 0 167 | withspace 168 | 169 | 170 | type 171 | alfred.workflow.input.scriptfilter 172 | uid 173 | C3BD5BCD-E58A-491B-93B0-951192C4BAC9 174 | 175 | 176 | config 177 | 178 | applescript 179 | on alfred_script(q) 180 | try 181 | mount volume "afp://" & q 182 | on error 183 | mount volume "smb://" & q 184 | end try 185 | end alfred_script 186 | cachescript 187 | 188 | 189 | type 190 | alfred.workflow.action.applescript 191 | uid 192 | 5C4A76F4-0175-48DE-AA23-7F7F70AB8659 193 | 194 | 195 | config 196 | 197 | applescript 198 | on alfred_script(q) 199 | do shell script "umount " & q 200 | end alfred_script 201 | cachescript 202 | 203 | 204 | type 205 | alfred.workflow.action.applescript 206 | uid 207 | 3BABCA7A-880C-45B6-A4CC-03B301CB4991 208 | 209 | 210 | readme 211 | 212 | uidata 213 | 214 | 3BABCA7A-880C-45B6-A4CC-03B301CB4991 215 | 216 | ypos 217 | 130 218 | 219 | 5C4A76F4-0175-48DE-AA23-7F7F70AB8659 220 | 221 | ypos 222 | 10 223 | 224 | 6B492BDF-9554-4B32-9FC7-70299B4F6CF0 225 | 226 | ypos 227 | 130 228 | 229 | C3BD5BCD-E58A-491B-93B0-951192C4BAC9 230 | 231 | ypos 232 | 10 233 | 234 | 235 | webaddress 236 | http://github.com/pstadler/alfred-mount 237 | 238 | 239 | -------------------------------------------------------------------------------- /src/update.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1.0, 3 | "remote_json": "https://raw.github.com/pstadler/alfred-mount/master/workflow.json" 4 | } -------------------------------------------------------------------------------- /workflow.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1.0, 3 | "download_uri": "https://raw.github.com/pstadler/alfred-mount/master/Mount%20Network%20Share.alfredworkflow", 4 | "description": "Alleyoop support." 5 | } --------------------------------------------------------------------------------