From d9fd225f36fe37e6c5281dc80b2d4aa6e95194f0 Mon Sep 17 00:00:00 2001 From: GaspardCulis Date: Sun, 29 Oct 2023 12:29:57 +0100 Subject: [PATCH] Made separate scripts for toggle-touchpad One for wayland (specifically Hyrland), one for x11 --- bin/wtoggle-touchpad | 35 +++++++++++++++++++++++++++ bin/xtoggle-touchpad | 12 +++++++++ de/hypr/hyprland.conf.d/bindings.conf | 2 +- de/i3/config.d/bindings.conf | 2 +- 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100755 bin/wtoggle-touchpad create mode 100755 bin/xtoggle-touchpad diff --git a/bin/wtoggle-touchpad b/bin/wtoggle-touchpad new file mode 100755 index 0000000..007adca --- /dev/null +++ b/bin/wtoggle-touchpad @@ -0,0 +1,35 @@ +#!/bin/sh + +HYPRLAND_DEVICE="asue1209:00-04f3:319f-touchpad" + +if [ -z "$XDG_RUNTIME_DIR" ]; then + export XDG_RUNTIME_DIR=/run/user/$(id -u) +fi + +export STATUS_FILE="$XDG_RUNTIME_DIR/touchpad.status" + +enable_touchpad() { + printf "true" > "$STATUS_FILE" + + notify-send -u normal "Enabling Touchpad" + + hyprctl keyword "device:$HYPRLAND_DEVICE:enabled" true +} + +disable_touchpad() { + printf "false" > "$STATUS_FILE" + + notify-send -u normal "Disabling Touchpad" + + hyprctl keyword "device:$HYPRLAND_DEVICE:enabled" false +} + +if ! [ -f "$STATUS_FILE" ]; then + disable_touchpad +else + if [ $(cat "$STATUS_FILE") = "true" ]; then + disable_touchpad + elif [ $(cat "$STATUS_FILE") = "false" ]; then + enable_touchpad + fi +fi diff --git a/bin/xtoggle-touchpad b/bin/xtoggle-touchpad new file mode 100755 index 0000000..ded58b8 --- /dev/null +++ b/bin/xtoggle-touchpad @@ -0,0 +1,12 @@ +#!/bin/bash + +DEVICE_ID=$(xinput | grep Touchpad | cut -d "=" -f2 | cut -f1) + +if [ $(xinput list-props $DEVICE_ID | grep "Device Enabled" | cut -d ':' -f 2 | xargs) == 1 ]; then + dunstify "Disabled touchpad" + xinput disable $DEVICE_ID +else + dunstify "Enabled touchpad" + xinput enable $DEVICE_ID +fi + diff --git a/de/hypr/hyprland.conf.d/bindings.conf b/de/hypr/hyprland.conf.d/bindings.conf index 24cfa26..27367aa 100644 --- a/de/hypr/hyprland.conf.d/bindings.conf +++ b/de/hypr/hyprland.conf.d/bindings.conf @@ -28,7 +28,7 @@ bind = ,XF86MonBrightnessDown, exec, swayosd-client --brightness lower # Screen bind = ,XF86MonBrightnessUp, exec, swayosd-client --brightness raise # Screen brightness up FN+F8 bind = ,237, exec, brightnessctl -d asus::kbd_backlight set 33%- # Keyboard brightness down FN+F2 bind = ,238, exec, brightnessctl -d asus::kbd_backlight set 33%+ # Keyboard brightnes up FN+F3 -bind = ,XF86TouchpadToggle, exec, ~/.local/bin/toggle-touchpad +bind = ,XF86TouchpadToggle, exec, ~/.local/bin/wtoggle-touchpad bind = ,XF86Sleep, exec, ~/.local/bin/togglescreen # Led profile bind = ,XF86Launch3, exec, asusctl led-mode -n diff --git a/de/i3/config.d/bindings.conf b/de/i3/config.d/bindings.conf index 4f65ffa..bee47a7 100644 --- a/de/i3/config.d/bindings.conf +++ b/de/i3/config.d/bindings.conf @@ -29,7 +29,7 @@ bindsym $mod+Shift+p exec ~/.config/i3/scripts/power-profiles # Panel overdrive bindsym $mod+Shift+o exec button=1 ~/.config/i3/scripts/refresh-rate -bindsym XF86TouchpadToggle exec ~/.local/bin/toggle-touchpad +bindsym XF86TouchpadToggle exec ~/.local/bin/xtoggle-touchpad bindsym XF86MonBrightnessUp exec --no-startup-id ~/.config/i3/scripts/volume_brightness.sh brightness_up bindsym XF86MonBrightnessDown exec --no-startup-id ~/.config/i3/scripts/volume_brightness.sh brightness_down