Thursday, July 4, 2024

terminal – Shortcuts – Run Shell Script – error with unix socket

Shortcuts app can not seem to discuss on to a unix socket. I get this error, “Error: Customized { type: NotFound, error: “no socket discovered” }
when configured to execute:

/usr/native/bin/alacritty --socket $(lsof -U | awk '/^alacritty.*var/folders/ {print $NF}') msg create-window

Nevertheless, if I spawn a subprocess to execute the command, every part works high-quality; the method on the opposite finish of the socket responds as anticipated. Utilizing ps I can see that my new alacritty window is a baby means of the PID listening on the opposite finish of the socket.

I am utilizing MacOS Shortcuts app to RunShellScript (in bash) of:

/usr/native/bin/alacritty -e /usr/native/bin/alacritty-new-window

the place alacritty-new-window is:

#!/usr/native/bin/bash

# use `head` to seek out first;  in any other case, would possibly see the intermediate shortcuts course of
# i.e. keep away from: /var/folders/7q/ktkg02v12sg111x1kqtbsg2w0000gp/T/com.apple.shortcuts.mac-helper//Alacritty-40370.sock
ALACRITTY_SOCKET=$(lsof -U | awk '/^alacritty.*var/folders/ {print $NF}' | head -1)
echo ${ALACRITTY_SOCKET}
/usr/native/bin/alacritty --socket ${ALACRITTY_SOCKET} msg create-window

If I’ve the RunShellScript simply echo the socket (i.e. echo $(lsof -U | awk '/^alacritty.*var/folders/ {print $NF}'), ths provides me the anticipated output of:
/var/folders/7q/ktkg02v12sg111x1kqtbsg2w0000gp/T/Alacritty-16780.sock

If I modify the RunShellScript to ls $(lsof -U | awk '/^alacritty.*var/folders/ {print $NF}') I see the socket I need:

srwxr-xr-x  1 person  employees  0 Feb 18 22:59 /var/folders/7q/ktkg02v12sg111x1kqtbsg2w0000gp/T/Alacritty-16780.sock

checking with a fast whoami, Shortcuts finds my person title.

So, I can see the socket. I am the proprietor of the socket.

I modified System Settings->Privateness & Safety->Full Disk Entry enabling entry for each Shortcuts and Finder, however there was no perceptible impact; I bought the identical error.

For completeness, I attempted an alternate executor (bash as a substitute of alacritty) with /usr/native/bin/bash -c /usr/native/bin/alacritty-new-window, and nonetheless had the error.

utilizing Shortcuts, I can see a unix socket. A subprocess can use that socket, however Shortcuts itself will get a socket error.

Can anybody assist me perceive what is going on on?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles