mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 21:54:00 +01:00
transcribe.sh 473 -> 39, setup_activitywatch.sh 457 -> 102 and setup_wireguard_ssh.sh 464 -> 136. enforce_vbox_hosts.sh is reverted: its seam landed inside a heredoc and the resulting lib had an unterminated here-document. That is the worst failure yet, because shellcheck reported it only as SC1094 on the caller - which reads like a nicety, not a file that will not parse. The verifier now runs bash -n over every lib before linting the entry and names the offending file; proven by corrupting a copy and restoring it. Also guarded a cd before `git clone ... .`, which would otherwise have cloned an AUR repo into the caller's directory. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
76 lines
2.0 KiB
Bash
Executable File
76 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# ActivityWatch install, both packaged and manual.
|
|
#
|
|
# Sourced by setup_activitywatch.sh; split out to keep it under the 250-line
|
|
# cap. Sourced rather than run, so it inherits the caller's strict mode
|
|
# and the variables defined above the source line.
|
|
|
|
# Function to install ActivityWatch
|
|
install_activitywatch() {
|
|
echo ""
|
|
echo "2. Installing ActivityWatch..."
|
|
echo "============================="
|
|
|
|
# Check if we need sudo for installation
|
|
check_sudo "install"
|
|
|
|
echo "Installing activitywatch-bin from AUR..."
|
|
|
|
# Check if an AUR helper is available
|
|
local aur_helpers=("yay" "paru" "makepkg")
|
|
local helper_found=""
|
|
|
|
for helper in "${aur_helpers[@]}"; do
|
|
if command -v "$helper" &>/dev/null; then
|
|
helper_found="$helper"
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [[ -n $helper_found && $helper_found != "makepkg" ]]; then
|
|
echo "Using AUR helper: $helper_found"
|
|
if [[ $EUID -eq 0 ]]; then
|
|
# Running as root, need to install as user
|
|
sudo -u "$ACTUAL_USER" "$helper_found" -S --noconfirm activitywatch-bin
|
|
else
|
|
"$helper_found" -S --noconfirm activitywatch-bin
|
|
fi
|
|
else
|
|
echo "No AUR helper found. Installing manually with makepkg..."
|
|
install_activitywatch_manual
|
|
fi
|
|
|
|
echo "✓ ActivityWatch installation completed"
|
|
}
|
|
|
|
# Function to manually install ActivityWatch via makepkg
|
|
install_activitywatch_manual() {
|
|
local temp_dir="/tmp/activitywatch-install"
|
|
local original_user="$ACTUAL_USER"
|
|
|
|
# Create temp directory
|
|
mkdir -p "$temp_dir"
|
|
# Guarded: the next command is `git clone ... .`, which would otherwise
|
|
# clone into whatever directory the caller happened to be in.
|
|
cd "$temp_dir" || {
|
|
print_error "Cannot enter $temp_dir"
|
|
return 1
|
|
}
|
|
|
|
# Download PKGBUILD
|
|
if command -v git &>/dev/null; then
|
|
sudo -u "$original_user" git clone https://aur.archlinux.org/activitywatch-bin.git .
|
|
else
|
|
echo "Installing git..."
|
|
pacman -S --noconfirm git
|
|
sudo -u "$original_user" git clone https://aur.archlinux.org/activitywatch-bin.git .
|
|
fi
|
|
|
|
# Build and install package
|
|
sudo -u "$original_user" makepkg -si --noconfirm
|
|
|
|
# Cleanup
|
|
cd /
|
|
rm -rf "$temp_dir"
|
|
}
|