reverted changes to touchpad toggle script

main
The_miro 2025-12-09 14:03:42 +01:00
parent 0bde224aac
commit bd6fba866f
2 changed files with 42 additions and 42 deletions

View File

@ -1,25 +1,40 @@
#!/usr/bin/env bash
export STATUS_FILE="$XDG_RUNTIME_DIR/keyboard.status"
STATUS_FILE="$XDG_RUNTIME_DIR/touchpad.status"
enable_keyboard() {
# Detect touchpad name dynamically
TOUCHPAD_NAME=$(hyprctl devices | awk '/type: touchpad/{getline; print $2; exit}')
TOUCHPAD_KEYWORD="device:${TOUCHPAD_NAME}:enabled"
# Functions
enable_touchpad() {
printf "true" >"$STATUS_FILE"
notify-send -u normal "Enabling Touchpad"
hyprctl keyword '$LAPTOP_KB_ENABLED' "true" -r
notify-send -u normal "Touchpad Enabled"
hyprctl keyword "$TOUCHPAD_KEYWORD" "true" -r
}
disable_keyboard() {
disable_touchpad() {
printf "false" >"$STATUS_FILE"
notify-send -u normal "Disabling Touchpad"
hyprctl keyword '$LAPTOP_KB_ENABLED' "false" -r
notify-send -u normal "Touchpad Disabled"
hyprctl keyword "$TOUCHPAD_KEYWORD" "false" -r
}
# Get current state from Hyprland (1 = enabled, 0 = disabled)
CURRENT_STATE=$(hyprctl getoption "$TOUCHPAD_KEYWORD" | grep "int:" | awk '{print $2}')
# Initialize status file if missing
if ! [ -f "$STATUS_FILE" ]; then
enable_keyboard
else
if [ $(cat "$STATUS_FILE") = "true" ]; then
disable_keyboard
elif [ $(cat "$STATUS_FILE") = "false" ]; then
enable_keyboard
if [ "$CURRENT_STATE" -eq 1 ]; then
printf "true" >"$STATUS_FILE"
else
printf "false" >"$STATUS_FILE"
fi
fi
# Toggle based on status file
if [ "$(cat "$STATUS_FILE")" = "true" ]; then
disable_touchpad
else
enable_touchpad
fi

View File

@ -1,40 +1,25 @@
#!/usr/bin/env bash
STATUS_FILE="$XDG_RUNTIME_DIR/touchpad.status"
export STATUS_FILE="$XDG_RUNTIME_DIR/keyboard.status"
# Detect touchpad name dynamically
TOUCHPAD_NAME=$(hyprctl devices | awk '/type: touchpad/{getline; print $2; exit}')
TOUCHPAD_KEYWORD="device:${TOUCHPAD_NAME}:enabled"
# Functions
enable_touchpad() {
enable_keyboard() {
printf "true" >"$STATUS_FILE"
notify-send -u normal "Touchpad Enabled"
hyprctl keyword "$TOUCHPAD_KEYWORD" "true" -r
notify-send -u normal "Enabling Touchpad"
hyprctl keyword '$LAPTOP_KB_ENABLED' "true" -r
}
disable_touchpad() {
disable_keyboard() {
printf "false" >"$STATUS_FILE"
notify-send -u normal "Touchpad Disabled"
hyprctl keyword "$TOUCHPAD_KEYWORD" "false" -r
notify-send -u normal "Disabling Touchpad"
hyprctl keyword '$LAPTOP_KB_ENABLED' "false" -r
}
# Get current state from Hyprland (1 = enabled, 0 = disabled)
CURRENT_STATE=$(hyprctl getoption "$TOUCHPAD_KEYWORD" | grep "int:" | awk '{print $2}')
# Initialize status file if missing
if ! [ -f "$STATUS_FILE" ]; then
if [ "$CURRENT_STATE" -eq 1 ]; then
printf "true" >"$STATUS_FILE"
else
printf "false" >"$STATUS_FILE"
enable_keyboard
else
if [ $(cat "$STATUS_FILE") = "true" ]; then
disable_keyboard
elif [ $(cat "$STATUS_FILE") = "false" ]; then
enable_keyboard
fi
fi
# Toggle based on status file
if [ "$(cat "$STATUS_FILE")" = "true" ]; then
disable_touchpad
else
enable_touchpad
fi