Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions raycast/ferry-to-space-1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,13 @@
set -euo pipefail

space=1
script_dir="${0:A:h}"
project_dir="${script_dir:h}"

if [[ -n "${FERRY_BINARY:-}" ]]; then
binary_path="$FERRY_BINARY"
elif binary_path="$(command -v ferry 2>/dev/null)" && [[ -x "$binary_path" ]]; then
:
else
binary_path=""
for candidate in \
"/opt/homebrew/bin/ferry" \
"/usr/local/bin/ferry" \
"$HOME/.local/bin/ferry" \
"$project_dir/build/ferry"; do
if [[ -x "$candidate" ]]; then
binary_path="$candidate"
break
fi
done
fi
# Raycast runs scripts with a minimal PATH, so also search the usual install
# locations and this checkout's build/ directory, after the inherited PATH.
path+=(/opt/homebrew/bin /usr/local/bin "$HOME/.local/bin" "${0:A:h:h}/build")
binary_path="${FERRY_BINARY:-$(whence -p ferry || true)}"

if [[ -z "$binary_path" || ! -x "$binary_path" ]]; then
if [[ ! -x "$binary_path" ]]; then
print -u2 "ferry binary not found. Install it with: brew install softmaxe/tap/ferry"
exit 127
fi
Expand Down
25 changes: 5 additions & 20 deletions raycast/ferry-to-space-2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,13 @@
set -euo pipefail

space=2
script_dir="${0:A:h}"
project_dir="${script_dir:h}"

if [[ -n "${FERRY_BINARY:-}" ]]; then
binary_path="$FERRY_BINARY"
elif binary_path="$(command -v ferry 2>/dev/null)" && [[ -x "$binary_path" ]]; then
:
else
binary_path=""
for candidate in \
"/opt/homebrew/bin/ferry" \
"/usr/local/bin/ferry" \
"$HOME/.local/bin/ferry" \
"$project_dir/build/ferry"; do
if [[ -x "$candidate" ]]; then
binary_path="$candidate"
break
fi
done
fi
# Raycast runs scripts with a minimal PATH, so also search the usual install
# locations and this checkout's build/ directory, after the inherited PATH.
path+=(/opt/homebrew/bin /usr/local/bin "$HOME/.local/bin" "${0:A:h:h}/build")
binary_path="${FERRY_BINARY:-$(whence -p ferry || true)}"

if [[ -z "$binary_path" || ! -x "$binary_path" ]]; then
if [[ ! -x "$binary_path" ]]; then
print -u2 "ferry binary not found. Install it with: brew install softmaxe/tap/ferry"
exit 127
fi
Expand Down
25 changes: 5 additions & 20 deletions raycast/ferry-to-space-3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,13 @@
set -euo pipefail

space=3
script_dir="${0:A:h}"
project_dir="${script_dir:h}"

if [[ -n "${FERRY_BINARY:-}" ]]; then
binary_path="$FERRY_BINARY"
elif binary_path="$(command -v ferry 2>/dev/null)" && [[ -x "$binary_path" ]]; then
:
else
binary_path=""
for candidate in \
"/opt/homebrew/bin/ferry" \
"/usr/local/bin/ferry" \
"$HOME/.local/bin/ferry" \
"$project_dir/build/ferry"; do
if [[ -x "$candidate" ]]; then
binary_path="$candidate"
break
fi
done
fi
# Raycast runs scripts with a minimal PATH, so also search the usual install
# locations and this checkout's build/ directory, after the inherited PATH.
path+=(/opt/homebrew/bin /usr/local/bin "$HOME/.local/bin" "${0:A:h:h}/build")
binary_path="${FERRY_BINARY:-$(whence -p ferry || true)}"

if [[ -z "$binary_path" || ! -x "$binary_path" ]]; then
if [[ ! -x "$binary_path" ]]; then
print -u2 "ferry binary not found. Install it with: brew install softmaxe/tap/ferry"
exit 127
fi
Expand Down
25 changes: 5 additions & 20 deletions raycast/ferry-to-space-4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,13 @@
set -euo pipefail

space=4
script_dir="${0:A:h}"
project_dir="${script_dir:h}"

if [[ -n "${FERRY_BINARY:-}" ]]; then
binary_path="$FERRY_BINARY"
elif binary_path="$(command -v ferry 2>/dev/null)" && [[ -x "$binary_path" ]]; then
:
else
binary_path=""
for candidate in \
"/opt/homebrew/bin/ferry" \
"/usr/local/bin/ferry" \
"$HOME/.local/bin/ferry" \
"$project_dir/build/ferry"; do
if [[ -x "$candidate" ]]; then
binary_path="$candidate"
break
fi
done
fi
# Raycast runs scripts with a minimal PATH, so also search the usual install
# locations and this checkout's build/ directory, after the inherited PATH.
path+=(/opt/homebrew/bin /usr/local/bin "$HOME/.local/bin" "${0:A:h:h}/build")
binary_path="${FERRY_BINARY:-$(whence -p ferry || true)}"

if [[ -z "$binary_path" || ! -x "$binary_path" ]]; then
if [[ ! -x "$binary_path" ]]; then
print -u2 "ferry binary not found. Install it with: brew install softmaxe/tap/ferry"
exit 127
fi
Expand Down
25 changes: 5 additions & 20 deletions raycast/ferry-to-space-5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,13 @@
set -euo pipefail

space=5
script_dir="${0:A:h}"
project_dir="${script_dir:h}"

if [[ -n "${FERRY_BINARY:-}" ]]; then
binary_path="$FERRY_BINARY"
elif binary_path="$(command -v ferry 2>/dev/null)" && [[ -x "$binary_path" ]]; then
:
else
binary_path=""
for candidate in \
"/opt/homebrew/bin/ferry" \
"/usr/local/bin/ferry" \
"$HOME/.local/bin/ferry" \
"$project_dir/build/ferry"; do
if [[ -x "$candidate" ]]; then
binary_path="$candidate"
break
fi
done
fi
# Raycast runs scripts with a minimal PATH, so also search the usual install
# locations and this checkout's build/ directory, after the inherited PATH.
path+=(/opt/homebrew/bin /usr/local/bin "$HOME/.local/bin" "${0:A:h:h}/build")
binary_path="${FERRY_BINARY:-$(whence -p ferry || true)}"

if [[ -z "$binary_path" || ! -x "$binary_path" ]]; then
if [[ ! -x "$binary_path" ]]; then
print -u2 "ferry binary not found. Install it with: brew install softmaxe/tap/ferry"
exit 127
fi
Expand Down
7 changes: 3 additions & 4 deletions src/ferry.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@

typedef int64_t (*bridged_operation_fn)(void *operation);

static bool g_verbose;

static void fail(int code, const char *fmt, ...) __attribute__((noreturn, format(printf, 2, 3)));
static void fail(int code, const char *fmt, ...)
{
Expand Down Expand Up @@ -324,6 +322,7 @@ int main(int argc, char **argv)
@autoreleasepool {
uint64_t start = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
bool follow = true;
bool verbose = false;
uint32_t wid = 0;
int index = 0;

Expand All @@ -339,7 +338,7 @@ int main(int argc, char **argv)
} else if (strcmp(arg, "--no-follow") == 0) {
follow = false;
} else if (strcmp(arg, "--verbose") == 0) {
g_verbose = true;
verbose = true;
} else if (strcmp(arg, "--window") == 0 && i + 1 < argc) {
wid = (uint32_t) parse_positive(argv[++i], UINT32_MAX);
if (!wid) fail(2, "invalid window id '%s'", argv[i]);
Expand Down Expand Up @@ -429,7 +428,7 @@ int main(int argc, char **argv)
if (follow) focus_window(&psn, wid, window_ref);
if (window_ref) CFRelease(window_ref);

if (g_verbose) {
if (verbose) {
printf("window %u (via %s) -> space %d (id %llu): %s in %.1f ms, %s, total %.1f ms\n",
wid, source, index, (unsigned long long) dst_sid,
moved ? "moved" : "already there", move_ms,
Expand Down
6 changes: 4 additions & 2 deletions tests/follow.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
extern CFArrayRef SLSCopySpacesForWindows(int cid, int selector, CFArrayRef windows);
extern int SLSSpaceGetType(int cid, uint64_t sid);

#define SPACE_TYPE_FULLSCREEN 4

static void pump(double seconds)
{
NSDate *end = [NSDate dateWithTimeIntervalSinceNow:seconds];
Expand Down Expand Up @@ -102,14 +104,14 @@ int main(int argc, char **argv)
++index;
uint64_t sid = [space[@"id64"] unsignedLongLongValue];
if (sid == src) src_index = index;
else if (current && !dst && SLSSpaceGetType(cid, sid) != 4) {
else if (current && !dst && SLSSpaceGetType(cid, sid) != SPACE_TYPE_FULLSCREEN) {
dst = sid;
dst_index = index;
}
}
}
if (displays) CFRelease(displays);
if (!src_index || !dst_index || SLSSpaceGetType(cid, src) == 4) {
if (!src_index || !dst_index || SLSSpaceGetType(cid, src) == SPACE_TYPE_FULLSCREEN) {
fputs("SKIP: test-follow requires two normal Spaces on the active display\n", stderr);
return 77;
}
Expand Down
Loading