Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ldrahnik committed Oct 11, 2023
1 parent f1403c2 commit 4473144
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 7 deletions.
2 changes: 2 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source non_sudo_check.sh

LOGS_DIR_PATH="/var/log/asus-numberpad-driver"

source install_logs.sh
Expand Down
2 changes: 2 additions & 0 deletions install_calc_toggle.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source non_sudo_check.sh

# INHERIT VARS
INSTALL_DIR_PATH="/usr/share/asus-numberpad-driver"

Expand Down
2 changes: 2 additions & 0 deletions install_device_check.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source non_sudo_check.sh

INTERFACES=$(for i in $(i2cdetect -l | grep DesignWare | sed -r "s/^(i2c\-[0-9]+).*/\1/"); do echo $i; done)
if [ -z "$INTERFACES" ]; then
echo "No i2c interface can be found. Make sure you have installed libevdev packages"
Expand Down
2 changes: 2 additions & 0 deletions install_external_keyboard_toggle.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

#!/bin/bash

source non_sudo_check.sh

# INHERIT VARS
#INSTALL_DIR_PATH="/usr/share/asus-numberpad-driver"
#CONFIG_FILE_DIR_PATH="$INSTALL_DIR_PATH"
Expand Down
2 changes: 2 additions & 0 deletions install_layout_auto_suggestion.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source non_sudo_check.sh

LAPTOP_NAME=$(sudo dmidecode -s system-product-name | rev | cut -d ' ' -f1 | rev | cut -d "_" -f1)
LAPTOP_NAME_FULL=$(sudo dmidecode -s system-product-name)

Expand Down
2 changes: 2 additions & 0 deletions install_layout_select.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source non_sudo_check.sh

DEVICE_ID=$(cat /proc/bus/input/devices | grep ".*Touchpad\"$" | sort | cut -f 3 -d" " | cut -f 2 -d ":" | head -1)

if [ -z "$LAYOUT_NAME" ]; then
Expand Down
1 change: 1 addition & 0 deletions install_logs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

source non_sudo_check.sh

# INHERIT
if [ -z "$LOGS_DIR_PATH" ]; then
Expand Down
2 changes: 2 additions & 0 deletions install_service.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source non_sudo_check.sh

# INHERIT VARS
if [ -z "$CONFIG_FILE_DIR_PATH" ]; then
CONFIG_FILE_DIR_PATH="/usr/share/asus-numberpad-driver"
Expand Down
2 changes: 2 additions & 0 deletions install_user_groups.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source non_sudo_check.sh

sudo groupadd "input"
sudo groupadd "i2c"
sudo groupadd "uinput"
Expand Down
5 changes: 5 additions & 0 deletions non_sudo_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

if [[ $(id -u) == 0 ]]; then
echo "Please run the install and uninstallation scripts as current user"
exit 1
fi
6 changes: 4 additions & 2 deletions numberpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@

numlock: bool = False

logging.basicConfig()
logging.basicConfig(
format='%(asctime)s %(levelname)-8s %(message)s',
level=os.environ.get('LOG', 'INFO')
)
log = logging.getLogger('asus-numberpad-driver')
log.setLevel(os.environ.get('LOG', 'INFO'))

# Constants
try_times = 5
Expand Down
13 changes: 8 additions & 5 deletions uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/bash

LOGS_DIR="/var/log/asus-numberpad-driver"
LOGS_UNINSTALL_FILE_NAME=uninstall-"$(date +"%d-%m-%Y-%H-%M-%S")".log
LOGS_UNINSTALL_LOG_FILE_PATH="$LOGS_DIR/$LOGS_UNINSTALL_FILE_NAME"
sudo mkdir -p "$LOGS_DIR"
sudo touch "$LOGS_UNINSTALL_LOG_FILE_PATH"
source non_sudo_check.sh

LOGS_DIR_PATH="/var/log/asus-numberpad-driver"

# log output from every uninstalling attempt aswell
LOGS_UNINSTALL_LOG_FILE_NAME=uninstall-"$(date +"%d-%m-%Y-%H-%M-%S")".log
LOGS_UNINSTALL_LOG_FILE_PATH="$LOGS_DIR_PATH/$LOGS_UNINSTALL_LOG_FILE_NAME"
touch "$LOGS_UNINSTALL_LOG_FILE_PATH"

{
# for `rm` exclude !(xy)
Expand Down
2 changes: 2 additions & 0 deletions uninstall_calc_toggle.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source non_sudo_check.sh

# INHERIT VARS
#
# None
Expand Down
2 changes: 2 additions & 0 deletions uninstall_external_keyboard_toggle.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source non_sudo_check.sh

# INHERIT VARS
INSTALL_DIR_PATH="/usr/share/asus-numberpad-driver"

Expand Down
2 changes: 2 additions & 0 deletions uninstall_service.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source non_sudo_check.sh

SERVICE_INSTALL_FILE_NAME="[email protected]"
SERVICE_INSTANCE_FILE_NAME="asus_numberpad_driver@$USER.service"

Expand Down
2 changes: 2 additions & 0 deletions uninstall_user_groups.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source non_sudo_check.sh

sudo rm -f /etc/udev/rules.d/99-input.rules

if [[ $? != 0 ]]; then
Expand Down

0 comments on commit 4473144

Please sign in to comment.