cshargextcap icon indicating copy to clipboard operation
cshargextcap copied to clipboard

packetfix-hander: don't hardcode Wireshark.app installation path into the apple script

Open maslovalex opened this issue 11 months ago • 5 comments

Current packetfix-handler expects Wireshark to be installed under /Applications/ which is not always the case, e.g. macports installs it under the /Applications/MacPorts/

Couldn't find the sources of AppleScript to make a PR :) so, here are the changes to make it a bit better than it is:

do shell script "/Applications/Wireshark.app/Contents/MacOS/Wireshark -k -i packetflix -o gui.window_title:\"" & title & "\" -o extcap.packetflix.url:\"" & thisURL & "\""

to something like

set wiresharkBundleId to id of application "Wireshark"
set theWorkspace to current application's NSWorkspace's sharedWorkspace()
set wiresharkPath to ((theWorkspace's URLForApplicationWithBundleIdentifier:wiresharkBundleId)'s |path|()) as text
	
do shell script wiresharkPath & "/Contents/MacOS/Wireshark -k -i packetflix -o gui.window_title:\"" & title & "\" -o extcap.packetflix.url:\"" & thisURL & "\""

This is not my solution, btw, just found a nice one from https://www.macscripter.net/t/determining-path-to-application-without-using-path-to-command/73645/5

maslovalex avatar Apr 03 '24 04:04 maslovalex