#!/usr/bin/env bash # Uninstall script for Omarchy Disable Trackpad While Typing feature set -euo pipefail # Define logging functions info() { echo -e "\033[34m[INFO]\033[0m $*"; } success() { echo -e "\033[32m[SUCCESS]\033[0m $*"; } warn() { echo -e "\033[33m[WARN]\033[0m $*"; } error() { echo -e "\033[31m[ERROR]\033[0m $*"; } # Installation paths INSTALL_DIR="$HOME/.local/share/omarchy/bin" INPUT_CONF="$HOME/.config/hypr/input.conf" AUTOSTART_CONF="$HOME/.config/hypr/autostart.conf" SUDOERS_FILE="/etc/sudoers.d/omarchy-trackpad-dwt" # Scripts to remove SCRIPT_MAIN="omarchy-disable-trackpad-while-typing" SCRIPT_TUI="omarchy-disable-trackpad-while-typing-tui" MENU_SCRIPT="omarchy-menu" main() { local header="Omarchy: Disable Trackpad While Typing Uninstaller" local separator=$(printf '=%.0s' $(seq 1 ${#header})) echo "$separator" echo "$header" echo "$separator" echo "" # Confirm uninstall warn "This will remove the Disable Trackpad While Typing feature" read -p "Continue with uninstall? [y/N]: " -n 1 -r /dev/null || true success "Stopped running instances" echo "" # Remove scripts info "Removing scripts..." remove_scripts echo "" # Restore menu info "Restoring omarchy-menu..." restore_menu echo "" # Remove sudoers rule info "Removing sudoers configuration..." remove_sudoers echo "" # Clean up config files info "Cleaning up configuration files..." cleanup_config_files echo "" # Remove dependencies info "Checking dependencies..." remove_dependencies echo "" # Final message local message="Uninstall complete!" local separator=$(printf '=%.0s' $(seq 1 $((${#message} + 10)))) echo "$separator" success "$message" echo "$separator" echo "" info "The Disable Trackpad While Typing feature has been removed" echo "" warn "Note: You may want to restart Hyprland to fully clear the feature" echo " (Super+Esc → Relaunch)" } remove_scripts() { local removed=false if [ -f "${INSTALL_DIR}/${SCRIPT_MAIN}" ]; then rm -f "${INSTALL_DIR}/${SCRIPT_MAIN}" success "Removed ${SCRIPT_MAIN}" removed=true fi if [ -f "${INSTALL_DIR}/${SCRIPT_TUI}" ]; then rm -f "${INSTALL_DIR}/${SCRIPT_TUI}" success "Removed ${SCRIPT_TUI}" removed=true fi if ! $removed; then info "Scripts were not found (already removed?)" fi } restore_menu() { local menu_path="${INSTALL_DIR}/${MENU_SCRIPT}" # Check if menu has DWT integration if ! grep -q "show_setup_input_menu" "$menu_path" 2>/dev/null; then info "Menu doesn't have DWT integration (already removed?)" return fi # Create a backup before uninstalling local backup_path="${menu_path}.backup-$(date +%Y%m%d-%H%M%S)" cp "$menu_path" "$backup_path" info "Created backup at $backup_path" echo # Patch 1: Revert the Input handler to open editor directly info "Reverting Input menu handler..." if grep -q "\*Input\*) show_setup_input_menu ;;" "$menu_path"; then sed -i 's|\*Input\*) show_setup_input_menu ;;|\*Input\*) open_in_editor ~/.config/hypr/input.conf ;;|' "$menu_path" if [ $? -eq 0 ]; then success "Reverted Input menu handler" else error "Failed to revert Input menu handler" warn "You may need to manually edit $menu_path" fi else warn "Input menu handler not found in expected format" fi echo # Patch 2: Remove the show_setup_input_menu function info "Removing show_setup_input_menu function..." # Use sed to delete the function (from the function declaration to the closing brace) sed -i '/^show_setup_input_menu() {$/,/^}$/d' "$menu_path" if [ $? -eq 0 ]; then success "Removed show_setup_input_menu function" else error "Failed to remove show_setup_input_menu function" warn "You may need to manually edit $menu_path" fi echo # Clean up old backup files local old_backups=$(ls -t "${menu_path}.backup-"* 2>/dev/null | tail -n +2) if [ -n "$old_backups" ]; then echo read -p "Remove old backup files? [Y/n]: " -n 1 -r /dev/null; then # Create backup cp "$INPUT_CONF" "${INPUT_CONF}.backup-$(date +%Y%m%d-%H%M%S)" # Remove default comment blocks if they haven't been customized # Installer's multi-line comment block if grep -q '^# Trackpad: Disable While Typing (DWT) setup script$' "$INPUT_CONF" 2>/dev/null; then # Check if line before the comment is blank, and delete it if so sed -i '/^$/{N;/\n# Trackpad: Disable While Typing (DWT) setup script$/s/^.*\n//;}' "$INPUT_CONF" # Delete the comment block itself (from start through last example line) sed -i '/^# Trackpad: Disable While Typing (DWT) setup script$/,/^# env = OMARCHY_TRACKPAD_DWT_TIMEOUT.*# Optional - timeout in seconds (default: 1\.5)$/d' "$INPUT_CONF" fi # TUI's single-line comment if grep -q '^# Trackpad disable-while-typing (configured by omarchy-disable-trackpad-while-typing-tui)$' "$INPUT_CONF" 2>/dev/null; then # Check if line before the comment is blank, and delete it if so sed -i '/^$/{N;/\n# Trackpad disable-while-typing (configured by omarchy-disable-trackpad-while-typing-tui)$/s/^.*\n//;}' "$INPUT_CONF" # Delete the comment line sed -i '/^# Trackpad disable-while-typing (configured by omarchy-disable-trackpad-while-typing-tui)$/d' "$INPUT_CONF" fi # Remove the actual env lines sed -i '/^\s*env = OMARCHY_TRACKPAD_DWT/d' "$INPUT_CONF" echo success "Removed configuration from input.conf" info "Backup saved to ${INPUT_CONF}.backup-$(date +%Y%m%d-%H%M%S)" cleaned=true fi # Remove from autostart.conf (check for active config, not comments) if [ -f "$AUTOSTART_CONF" ] && grep -q '^\s*exec-once.*omarchy-disable-trackpad-while-typing' "$AUTOSTART_CONF" 2>/dev/null; then # Create backup cp "$AUTOSTART_CONF" "${AUTOSTART_CONF}.backup-$(date +%Y%m%d-%H%M%S)" # Remove TUI's comment (including preceding blank line) if it hasn't been customized if grep -q '^# Trackpad disable-while-typing$' "$AUTOSTART_CONF" 2>/dev/null; then # Remove blank line before the comment sed -i '/^$/{N;/\n# Trackpad disable-while-typing$/d;}' "$AUTOSTART_CONF" sed -i '/^# Trackpad disable-while-typing$/d' "$AUTOSTART_CONF" fi # Remove the actual exec-once line sed -i '/^\s*exec-once.*omarchy-disable-trackpad-while-typing/d' "$AUTOSTART_CONF" echo success "Removed configuration from autostart.conf" info "Backup saved to ${AUTOSTART_CONF}.backup-$(date +%Y%m%d-%H%M%S)" cleaned=true fi if ! $cleaned; then info "Configuration files were clean (already removed?)" fi } remove_dependencies() { local packages_to_remove=() # Check evtest if command -v evtest &>/dev/null; then local evtest_required=$(pacman -Qi evtest 2>/dev/null | grep "Required By" | cut -d: -f2 | xargs) if [ "$evtest_required" = "None" ]; then packages_to_remove+=("evtest") fi fi # Check socat if command -v socat &>/dev/null; then local socat_required=$(pacman -Qi socat 2>/dev/null | grep "Required By" | cut -d: -f2 | xargs) if [ "$socat_required" = "None" ]; then packages_to_remove+=("socat") fi fi # If no packages to remove, inform and return if [ ${#packages_to_remove[@]} -eq 0 ]; then info "No unused dependencies to remove" return fi # Ask user if they want to remove echo warn "The following dependencies are not required by other packages:" for pkg in "${packages_to_remove[@]}"; do echo " - $pkg" done echo read -p "Remove these packages? [y/N]: " -n 1 -r /dev/null; then success "Removed $pkg" else warn "Failed to remove $pkg" fi done else info "Keeping dependencies installed" fi } # Show usage if [ "${1:-}" = "--help" ] || [ "${1:-}" = "-h" ]; then cat <