Skip to content

Commit dae132a

Browse files
committed
Pglet v0.2.0 support
- Requires Pglet v0.2.0 - ARM architectures support - PGLET_TICKER to enable event ticker
1 parent e5d9d31 commit dae132a

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

pglet.sh

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Constants
2-
PGLET_VER="0.1.12" # Pglet version required by this script
2+
PGLET_VER="0.2.0" # Pglet version required by this script
33

44
# Default session variables:
55
PGLET_EXE="" # full path to Pglet executable
@@ -40,6 +40,10 @@ function pglet_page() {
4040
pargs+=(--no-window)
4141
fi
4242

43+
if [[ "$PGLET_TICKER" != "" ]]; then
44+
pargs+=(--ticker $PGLET_TICKER)
45+
fi
46+
4347
# execute pglet and get page connection ID
4448
local page_results=`$PGLET_EXE "${pargs[@]}"`
4549
IFS=' ' read -r PGLET_CONNECTION_ID PGLET_PAGE_URL <<< "$page_results"
@@ -86,6 +90,10 @@ function pglet_app() {
8690
pargs+=(--no-window)
8791
fi
8892

93+
if [[ "$PGLET_TICKER" != "" ]]; then
94+
pargs+=(--ticker $PGLET_TICKER)
95+
fi
96+
8997
# reset vars
9098
PGLET_PAGE_URL=""
9199

@@ -120,7 +128,7 @@ function pglet_send() {
120128
echo "$cmd" > "$conn_id"
121129

122130
# take result if command doesn't end with "f" (fire-and-forget)
123-
if [[ "$cmd" =~ ^[[:space:]]*[A-Za-z]+f ]]; then
131+
if [[ "$cmd" =~ \s*\w*f ]]; then
124132
return
125133
fi
126134

@@ -202,7 +210,7 @@ function pglet_wait_event() {
202210
local conn_id=$PGLET_CONNECTION_ID
203211
fi
204212

205-
IFS=' ' read PGLET_EVENT_TARGET PGLET_EVENT_NAME PGLET_EVENT_DATA < "$conn_id.events"
213+
read PGLET_EVENT_TARGET PGLET_EVENT_NAME PGLET_EVENT_DATA < "$conn_id.events"
206214
}
207215

208216
function pglet_dispatch_events() {
@@ -228,19 +236,32 @@ function pglet_dispatch_events() {
228236
}
229237

230238
function __pglet_install() {
231-
if [ "$(uname -m)" != "x86_64" ]; then
232-
echo "Error: Unsupported architecture $(uname -m). Only x64 binaries are available." 1>&2
233-
exit 1
234-
fi
235239

236240
if [ "$OS" = "Windows_NT" ]; then
237241
echo "Error: Bash for Windows is not supported." 1>&2
238242
exit 1
243+
fi
244+
245+
platform=$(uname -s)
246+
if [[ $platform == Darwin ]]; then
247+
platform="darwin"
248+
elif [[ $platform == Linux ]]; then
249+
platform="linux"
250+
else
251+
echo "Error: Unsupported platform $platform." 1>&2
252+
exit 1
253+
fi
254+
255+
arch=$(uname -m)
256+
if [[ $arch == x86_64 ]] || [[ $arch == amd64 ]]; then
257+
arch="amd64"
258+
elif [[ $arch == arm64 ]] || [[ $arch == aarch64 ]]; then
259+
arch="arm64"
260+
elif [[ $arch == arm ]] || [[ $arch == armv7l ]]; then
261+
arch="arm"
239262
else
240-
case $(uname -s) in
241-
Darwin) target="darwin-amd64.tar.gz" ;;
242-
*) target="linux-amd64.tar.gz" ;;
243-
esac
263+
echo "Error: Unsupported architecture $arch." 1>&2
264+
exit 1
244265
fi
245266

246267
# check if pglet.exe is in PATH already (development mode)
@@ -271,13 +292,11 @@ function __pglet_install() {
271292
mkdir -p "$pglet_bin"
272293
fi
273294

274-
local pglet_url="https://github.com/pglet/pglet/releases/download/v${ver}/pglet-${target}"
295+
local pglet_url="https://github.com/pglet/pglet/releases/download/v${ver}/pglet-${ver}-${platform}-${arch}.tar.gz"
275296
local tempTar="$HOME/.pglet/pglet.tar.gz"
276297
curl -fsSL $pglet_url -o $tempTar
277298
tar zxf $tempTar -C $pglet_bin
278299
rm $tempTar
279-
280-
#echo "OK"
281300
fi
282301
}
283302

0 commit comments

Comments
 (0)