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
18 changes: 18 additions & 0 deletions build/office-suite/scripts/desktop_entry_install_smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ mkdir -p "$HOME"

DESKTOP_FILE="$XDG_DATA_HOME/applications/sourceos-office.desktop"
BIN_FILE="$HOME/.local/bin/sourceos-office-open"
CLOUD_FILE="$HOME/.local/bin/office_cloud_handoff.sh"
SEARCH_FILE="$HOME/.local/bin/office_search_handoff.sh"
SEARCH_OPEN_FILE="$HOME/.local/bin/office_search_open.sh"
MIME_FILE="$XDG_CONFIG_HOME/mimeapps.list"

[[ -f "$DESKTOP_FILE" ]] || {
Expand All @@ -26,6 +29,21 @@ MIME_FILE="$XDG_CONFIG_HOME/mimeapps.list"
exit 1
}

[[ -x "$CLOUD_FILE" ]] || {
echo "desktop entry install smoke failed: missing cloud handoff helper" >&2
exit 1
}

[[ -x "$SEARCH_FILE" ]] || {
echo "desktop entry install smoke failed: missing search handoff helper" >&2
exit 1
}

[[ -x "$SEARCH_OPEN_FILE" ]] || {
echo "desktop entry install smoke failed: missing search open helper" >&2
exit 1
}

[[ -f "$MIME_FILE" ]] || {
echo "desktop entry install smoke failed: missing MIME defaults" >&2
exit 1
Expand Down
7 changes: 6 additions & 1 deletion build/office-suite/scripts/install_office_desktop_entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
DESKTOP_SRC="$ROOT/build/office-suite/desktop/sourceos-office.desktop"
BIN_SRC="$ROOT/build/office-suite/scripts/office_open.sh"
CLOUD_SRC="$ROOT/build/office-suite/scripts/office_cloud_handoff.sh"
SEARCH_SRC="$ROOT/build/office-suite/scripts/office_search_handoff.sh"
SEARCH_OPEN_SRC="$ROOT/build/office-suite/scripts/office_search_open.sh"
APP_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/applications"
BIN_DIR="$HOME/.local/bin"

mkdir -p "$APP_DIR" "$BIN_DIR"
cp "$DESKTOP_SRC" "$APP_DIR/sourceos-office.desktop"
cp "$BIN_SRC" "$BIN_DIR/sourceos-office-open"
cp "$CLOUD_SRC" "$BIN_DIR/office_cloud_handoff.sh"
chmod +x "$BIN_DIR/sourceos-office-open" "$BIN_DIR/office_cloud_handoff.sh"
cp "$SEARCH_SRC" "$BIN_DIR/office_search_handoff.sh"
cp "$SEARCH_OPEN_SRC" "$BIN_DIR/office_search_open.sh"
chmod +x "$BIN_DIR/sourceos-office-open" "$BIN_DIR/office_cloud_handoff.sh" "$BIN_DIR/office_search_handoff.sh" "$BIN_DIR/office_search_open.sh"

"$ROOT/build/office-suite/scripts/install_office_mime_defaults.sh" >/dev/null

echo "installed desktop entry to $APP_DIR/sourceos-office.desktop"
echo "installed launcher helper to $BIN_DIR/sourceos-office-open"
echo "installed cloud handoff helper to $BIN_DIR/office_cloud_handoff.sh"
echo "installed search helpers to $BIN_DIR"
echo "installed office MIME defaults"
46 changes: 46 additions & 0 deletions build/office-suite/scripts/office_search_open.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
set -euo pipefail

if [[ $# -lt 1 ]]; then
echo "usage: $0 <query>" >&2
exit 1
fi

QUERY="$1"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"

if [[ -x "$SCRIPT_DIR/office_search_handoff.sh" ]]; then
SEARCH_HELPER="$SCRIPT_DIR/office_search_handoff.sh"
elif [[ -x "$ROOT/build/office-suite/scripts/office_search_handoff.sh" ]]; then
SEARCH_HELPER="$ROOT/build/office-suite/scripts/office_search_handoff.sh"
else
echo "office_search_handoff.sh not found" >&2
exit 1
fi

if [[ -x "$SCRIPT_DIR/sourceos-office-open" ]]; then
OPEN_HELPER="$SCRIPT_DIR/sourceos-office-open"
elif [[ -x "$SCRIPT_DIR/office_open.sh" ]]; then
OPEN_HELPER="$SCRIPT_DIR/office_open.sh"
elif [[ -x "$ROOT/build/office-suite/scripts/office_open.sh" ]]; then
OPEN_HELPER="$ROOT/build/office-suite/scripts/office_open.sh"
else
echo "office open helper not found" >&2
exit 1
fi

SEARCH_OUT="$($SEARCH_HELPER "$QUERY" 2>/dev/null || true)"
FIRST_PATH="$(printf '%s\n' "$SEARCH_OUT" | head -n 1)"

if [[ -z "$FIRST_PATH" ]]; then
echo "no search results" >&2
exit 3
fi

if [[ ! -f "$FIRST_PATH" ]]; then
echo "$FIRST_PATH"
exit 0
fi

"$OPEN_HELPER" "$FIRST_PATH"