-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_arch.sh
More file actions
executable file
·269 lines (225 loc) · 7.54 KB
/
Copy pathsetup_arch.sh
File metadata and controls
executable file
·269 lines (225 loc) · 7.54 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#!/bin/bash
#
# FasterWhisper Setup Script for Arch Linux
# Optimized for Hyprland + RTX 3050 Ti Mobile
#
set -e # Exit on any error
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Configuration
CONDA_ENV="fasterwhisper"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
INSTALL_DIR="$HOME/.local/bin"
# Logging functions
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if running on Arch Linux
check_arch_linux() {
if [[ ! -f /etc/arch-release ]]; then
log_error "This script is designed for Arch Linux"
exit 1
fi
log_success "Arch Linux detected"
}
# Check system requirements
check_requirements() {
log_info "Checking system requirements..."
# Check conda
if ! command -v conda &> /dev/null; then
log_error "Conda not found. Please install Miniconda or Anaconda first"
log_info "Download from: https://docs.conda.io/en/latest/miniconda.html"
exit 1
fi
log_success "Conda found: $(conda --version)"
# Check CUDA
if command -v nvidia-smi &> /dev/null; then
log_success "NVIDIA GPU detected:"
nvidia-smi --query-gpu=name,memory.total --format=csv,noheader,nounits | head -1
else
log_warning "NVIDIA drivers not found. GPU acceleration will not be available"
fi
# Check PipeWire
if command -v pactl &> /dev/null; then
log_success "PipeWire/PulseAudio found"
else
log_error "PipeWire/PulseAudio not found. Please install pipewire-pulse"
exit 1
fi
# Check Hyprland
if [[ "$XDG_CURRENT_DESKTOP" == "Hyprland" ]]; then
log_success "Hyprland detected - enhanced integration available"
else
log_warning "Hyprland not detected - some features may be unavailable"
fi
}
# Install system dependencies
install_system_deps() {
log_info "Checking system dependencies..."
local packages=(
"cuda" # CUDA support
"pipewire-pulse" # Audio
"libnotify" # Notifications
"wl-clipboard" # Wayland clipboard
"python-pip" # Python package manager
)
local missing_packages=()
for package in "${packages[@]}"; do
if ! pacman -Qi "$package" &> /dev/null; then
missing_packages+=("$package")
fi
done
if [[ ${#missing_packages[@]} -gt 0 ]]; then
log_info "Installing missing packages: ${missing_packages[*]}"
log_warning "This requires sudo privileges"
if sudo pacman -S --needed --noconfirm "${missing_packages[@]}"; then
log_success "System packages installed successfully"
else
log_error "Failed to install system packages"
exit 1
fi
else
log_success "All system dependencies are already installed"
fi
}
# Create conda environment
create_conda_env() {
log_info "Setting up conda environment..."
# Check if environment already exists
if conda env list | grep -q "^$CONDA_ENV "; then
log_warning "Environment '$CONDA_ENV' already exists"
read -p "Do you want to remove and recreate it? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
log_info "Removing existing environment..."
conda env remove -n "$CONDA_ENV" -y
else
log_info "Skipping environment creation"
return 0
fi
fi
# Create environment from YAML file
if [[ -f "$SCRIPT_DIR/environment.yml" ]]; then
log_info "Creating environment from environment.yml..."
conda env create -f "$SCRIPT_DIR/environment.yml"
log_success "Conda environment '$CONDA_ENV' created successfully"
else
log_error "environment.yml not found in $SCRIPT_DIR"
exit 1
fi
}
# Install global command
install_global_command() {
log_info "Installing global 'trs' command..."
# Create install directory if it doesn't exist
mkdir -p "$INSTALL_DIR"
# Copy and make executable
if cp "$SCRIPT_DIR/trs" "$INSTALL_DIR/trs"; then
chmod +x "$INSTALL_DIR/trs"
log_success "Global command 'trs' installed to $INSTALL_DIR"
else
log_error "Failed to install global command"
exit 1
fi
# Check if install directory is in PATH
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
log_warning "$INSTALL_DIR is not in your PATH"
log_info "Add this to your shell profile (.bashrc, .zshrc, etc.):"
echo "export PATH=\"\$PATH:$INSTALL_DIR\""
else
log_success "$INSTALL_DIR is already in PATH"
fi
}
# Test installation
test_installation() {
log_info "Testing installation..."
# Test conda environment
if conda activate "$CONDA_ENV" 2>/dev/null && python -c "import faster_whisper; print('✓ faster-whisper imported successfully')" 2>/dev/null; then
conda deactivate
log_success "Python environment test passed"
else
log_error "Python environment test failed"
return 1
fi
# Test global command
if command -v trs &> /dev/null; then
log_success "Global 'trs' command is available"
else
log_warning "Global 'trs' command not found in PATH"
fi
# Test audio sources
local audio_sources=$(pactl list sources | grep -c "Name:")
if [[ $audio_sources -gt 0 ]]; then
log_success "Found $audio_sources audio sources"
else
log_warning "No audio sources found"
fi
}
# Setup Hyprland integration
setup_hyprland() {
if [[ "$XDG_CURRENT_DESKTOP" != "Hyprland" ]]; then
log_info "Skipping Hyprland integration (not running Hyprland)"
return 0
fi
log_info "Setting up Hyprland integration..."
local hypr_config_dir="$HOME/.config/hypr"
if [[ ! -d "$hypr_config_dir" ]]; then
log_warning "Hyprland config directory not found: $hypr_config_dir"
return 0
fi
log_info "Hyprland config files are available in: $SCRIPT_DIR/hyprland/"
log_info "To enable keybinds, add this to your hyprland.conf:"
echo "source = $SCRIPT_DIR/hyprland/keybinds.conf"
log_info "To enable window rules, add this to your hyprland.conf:"
echo "source = $SCRIPT_DIR/hyprland/window_rules.conf"
}
# Main installation function
main() {
log_info "FasterWhisper Setup for Arch Linux + RTX 3050 Ti"
log_info "=============================================="
echo
check_arch_linux
check_requirements
echo
install_system_deps
echo
create_conda_env
echo
install_global_command
echo
test_installation
echo
setup_hyprland
echo
log_success "Installation completed successfully!"
echo
log_info "Quick start:"
log_info " 1. Run 'trs' from anywhere to start transcription"
log_info " 2. Use 'trs --help' for more options"
log_info " 3. Use 'trs --config' to view current settings"
echo
log_info "Hyprland users:"
log_info " - Super+T: Start transcription"
log_info " - Super+Shift+T: Start as daemon"
log_info " - Super+Ctrl+T: Stop daemon"
echo
log_info "For troubleshooting, check:"
log_info " - Audio sources: trs --test"
log_info " - Configuration: ~/.config/fasterwhisper/config.json"
log_info " - Log files: ~/.config/fasterwhisper/"
}
# Run main function
main "$@"