-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·98 lines (82 loc) · 2.46 KB
/
install.sh
File metadata and controls
executable file
·98 lines (82 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env bash
set -euo pipefail
REPO="${KEYBOARD_CLEAN_REPO:-eliophan/KeyboardClean}"
REF="${KEYBOARD_CLEAN_REF:-main}"
BASE_URL="https://raw.githubusercontent.com/${REPO}/${REF}"
INSTALL_DIR="${KEYBOARD_CLEAN_INSTALL_DIR:-$HOME/.local/bin}"
download() {
local url="$1"
local out="$2"
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$url" -o "$out"
return
fi
if command -v wget >/dev/null 2>&1; then
wget -qO "$out" "$url"
return
fi
echo "Neither curl nor wget is installed." >&2
exit 1
}
download_macos_binary() {
local out="$1"
local asset_url="https://github.com/${REPO}/releases/latest/download/keyboard-clean-macos"
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$asset_url" -o "$out" && return 0
return 1
fi
if command -v wget >/dev/null 2>&1; then
wget -qO "$out" "$asset_url" && return 0
return 1
fi
return 1
}
print_path_hint() {
case ":$PATH:" in
*":$INSTALL_DIR:"*) ;;
*)
echo
echo "Add this to your shell profile to use keyboard-clean directly:"
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
;;
esac
}
mkdir -p "$INSTALL_DIR"
case "$(uname -s)" in
Darwin)
bin_file="$INSTALL_DIR/keyboard-clean"
if download_macos_binary "$bin_file"; then
chmod +x "$bin_file"
echo "Installed keyboard-clean prebuilt binary to $INSTALL_DIR (macOS mode)."
else
echo "Prebuilt binary not found. Falling back to local build..."
if ! command -v swiftc >/dev/null 2>&1; then
echo "swiftc is required for fallback build. Install Xcode Command Line Tools first." >&2
exit 1
fi
tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT
src_file="$tmp_dir/main.swift"
download "$BASE_URL/Sources/keyboard-clean/main.swift" "$src_file"
swiftc -O -framework ApplicationServices "$src_file" -o "$bin_file"
chmod +x "$bin_file"
echo "Installed keyboard-clean to $INSTALL_DIR using local Swift build (macOS mode)."
fi
print_path_hint
;;
Linux)
cmd_file="$INSTALL_DIR/keyboard-clean"
download "$BASE_URL/scripts/keyboard-clean-linux" "$cmd_file"
chmod +x "$cmd_file"
echo "Installed keyboard-clean to $INSTALL_DIR (Linux mode)."
echo "Note: Requires X11 and xinput at runtime."
print_path_hint
;;
*)
echo "Unsupported OS for install.sh: $(uname -s)" >&2
echo "For Windows, use install.ps1 instead." >&2
exit 1
;;
esac
echo
echo "Run: keyboard-clean 60"