diff --git a/desktopenvs/hyprland/scripts/deprecated/hyprland-toggle-touchpad.sh.old b/desktopenvs/hyprland/scripts/deprecated/hyprland-toggle-touchpad.sh.old index cafa8e4..d5f65d0 100755 --- a/desktopenvs/hyprland/scripts/deprecated/hyprland-toggle-touchpad.sh.old +++ b/desktopenvs/hyprland/scripts/deprecated/hyprland-toggle-touchpad.sh.old @@ -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 - fi + 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 diff --git a/desktopenvs/hyprland/scripts/hyprland-toggle-touchpad.sh b/desktopenvs/hyprland/scripts/hyprland-toggle-touchpad.sh index d5f65d0..cafa8e4 100755 --- a/desktopenvs/hyprland/scripts/hyprland-toggle-touchpad.sh +++ b/desktopenvs/hyprland/scripts/hyprland-toggle-touchpad.sh @@ -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" - fi -fi - -# Toggle based on status file -if [ "$(cat "$STATUS_FILE")" = "true" ]; then - disable_touchpad + enable_keyboard else - enable_touchpad + if [ $(cat "$STATUS_FILE") = "true" ]; then + disable_keyboard + elif [ $(cat "$STATUS_FILE") = "false" ]; then + enable_keyboard + fi fi