Skip to content

Commit

Permalink
Fixed uninstall script
Browse files Browse the repository at this point in the history
  • Loading branch information
ldrahnik committed Mar 7, 2023
1 parent d11ae80 commit eac0bd6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ or download latest release (stable version) from [release page](https://github.c

```bash
# install as root
sudo ./install.sh
sudo bash ./install.sh
# install under current user (highly recommended)
sudo ./install.sh --user
sudo bash ./install.sh --user
```

or is available package for arch on AUR [here](https://aur.archlinux.org/packages?O=0&SeB=nd&K=asus-touchpad-numpad-driver&outdated=&SB=p&SO=d&PP=50&submit=Go) (replace model with available models, e.g. `asus-touchpad-numpad-driver-ux433fa-git`)
Expand All @@ -88,9 +88,9 @@ paru -S asus-touchpad-numpad-driver-${model}-git
And to uninstall, just run:

```bash
sudo ./uninstall.sh
sudo bash ./uninstall.sh
# stop driver and uninstall for current user
sudo ./uninstall.sh --user
sudo bash ./uninstall.sh --user
```

### Dependencies
Expand Down
23 changes: 14 additions & 9 deletions uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ then
exit 1
fi

# for `rm` exclude !(xy)
shopt -s extglob


# "root" by default or when is used --user it is "current user"
RUN_UNDER_USER=$USER

if [ "$1" = "--user" ]; then
if [ "$1" = "--user" ]
then
RUN_UNDER_USER=$SUDO_USER
fi

Expand All @@ -23,7 +28,7 @@ if [[ $? != 0 ]]
then
echo "asus_touchpad_numpad.service cannot be stopped correctly..."
exit 1

fi

systemctl disable asus_touchpad_numpad@$RUN_UNDER_USER.service
if [[ $? != 0 ]]
Expand All @@ -39,29 +44,28 @@ then
exit 1
fi

# for `rm` exclude !(xy)
shopt -s extglob

NUMPAD_LAYOUTS_DIR="/usr/share/asus_touchpad_numpad-driver/numpad_layouts/"

NUMPAD_LAYOUTS_DIR_DIFF=""
if test -d "$NUMPAD_LAYOUTS_DIR"; then
if test -d "$NUMPAD_LAYOUTS_DIR"
then
NUMPAD_LAYOUTS_DIR_DIFF=$(diff --exclude __pycache__ numpad_layouts $NUMPAD_LAYOUTS_DIR)
fi

if [ "$NUMPAD_LAYOUTS_DIR_DIFF" != "" ]
then
read -r -p "Installed numpad layouts contain modifications compared to the default ones. Do you want remove them [y/N]" response
case "$response" in [yY][eE][sS]|[yY])
rm -rf /usr/share/asus_touchpad_numpad-driver/!(asus_touchpad_numpad_dev)
rm -rf "/usr/share/asus_touchpad_numpad-driver/"!(asus_touchpad_numpad_dev)
if [[ $? != 0 ]]
then
echo "/usr/share/asus_touchpad_numpad-driver/ cannot be removed correctly..."
exit 1
fi
;;
*)
rm -rf /usr/share/asus_touchpad_numpad-driver/!(numpad_layouts|asus_touchpad_numpad_dev)
rm -rf "/usr/share/asus_touchpad_numpad-driver/"!(numpad_layouts|asus_touchpad_numpad_dev)
if [[ $? != 0 ]]
then
echo "/usr/share/asus_touchpad_numpad-driver/ cannot be removed correctly..."
Expand All @@ -72,7 +76,7 @@ then
;;
esac
else
rm -rf /usr/share/asus_touchpad_numpad-driver/!(asus_touchpad_numpad_dev)
rm -rf "/usr/share/asus_touchpad_numpad-driver/"!(asus_touchpad_numpad_dev)
if [[ $? != 0 ]]
then
echo "/usr/share/asus_touchpad_numpad-driver/ cannot be removed correctly..."
Expand All @@ -83,7 +87,8 @@ fi
CONF_FILE="/usr/share/asus_touchpad_numpad-driver/asus_touchpad_numpad_dev"

CONFIG_FILE_DIFF=""
if test -f "$CONF_FILE"; then
if test -f "$CONF_FILE"
then
CONFIG_FILE_DIFF=$(diff <(grep -v '^#' asus_touchpad_numpad_dev) <(grep -v '^#' $CONF_FILE))
fi

Expand Down

0 comments on commit eac0bd6

Please sign in to comment.