58 lines
2 KiB
Bash
Executable file
58 lines
2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
# Cores para output
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m' # Sem cor
|
|
|
|
echo -e "${BLUE}==========================================${NC}"
|
|
echo -e "${BLUE} GameSir Controller Keepalive Installer ${NC}"
|
|
echo -e "${BLUE}==========================================${NC}"
|
|
|
|
# Verificar compilador C (gcc ou clang)
|
|
COMPILER=""
|
|
if command -v gcc &> /dev/null; then
|
|
COMPILER="gcc"
|
|
elif command -v clang &> /dev/null; then
|
|
COMPILER="clang"
|
|
else
|
|
echo -e "${RED}[ERRO] Compilador C (gcc ou clang) não foi encontrado.${NC}"
|
|
echo -e "${RED}Por favor, instale com: sudo pacman -S gcc make (no Arch/CachyOS)${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
BIN_DIR="$HOME/.local/bin"
|
|
SYSTEMD_USER_DIR="$HOME/.config/systemd/user"
|
|
|
|
echo -e "${YELLOW}[*] Compilando executável nativo em C ($COMPILER)...${NC}"
|
|
make -C "$SCRIPT_DIR" CC="$COMPILER"
|
|
|
|
echo -e "${YELLOW}[*] Criando diretórios necessários...${NC}"
|
|
mkdir -p "$BIN_DIR"
|
|
mkdir -p "$SYSTEMD_USER_DIR"
|
|
|
|
echo -e "${YELLOW}[*] Instalando binário em $BIN_DIR...${NC}"
|
|
install -m 755 "$SCRIPT_DIR/gamesir-keepalive" "$BIN_DIR/gamesir-keepalive"
|
|
|
|
# Remover versão antiga em python caso exista
|
|
rm -f "$BIN_DIR/gamesir-keepalive.py"
|
|
|
|
echo -e "${YELLOW}[*] Instalando arquivo de serviço do systemd em $SYSTEMD_USER_DIR...${NC}"
|
|
cp "$SCRIPT_DIR/gamesir-keepalive.service" "$SYSTEMD_USER_DIR/gamesir-keepalive.service"
|
|
|
|
echo -e "${YELLOW}[*] Recarregando daemon do systemd de usuário...${NC}"
|
|
systemctl --user daemon-reload
|
|
|
|
echo -e "${YELLOW}[*] Ativando e reiniciando o serviço...${NC}"
|
|
systemctl --user enable gamesir-keepalive.service
|
|
systemctl --user restart gamesir-keepalive.service
|
|
|
|
echo -e "${GREEN}==========================================${NC}"
|
|
echo -e "${GREEN} Instalação concluída com sucesso! ${NC}"
|
|
echo -e "${GREEN}==========================================${NC}"
|
|
echo ""
|
|
systemctl --user status gamesir-keepalive.service --no-pager || true
|