Made separate scripts for toggle-touchpad

One for wayland (specifically Hyrland), one for x11
This commit is contained in:
GaspardCulis 2023-10-29 12:29:57 +01:00
parent 2b72ea43aa
commit d9fd225f36
4 changed files with 49 additions and 2 deletions

35
bin/wtoggle-touchpad Executable file
View file

@ -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

12
bin/xtoggle-touchpad Executable file
View file

@ -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

View file

@ -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 = ,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 = ,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 = ,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 bind = ,XF86Sleep, exec, ~/.local/bin/togglescreen
# Led profile # Led profile
bind = ,XF86Launch3, exec, asusctl led-mode -n bind = ,XF86Launch3, exec, asusctl led-mode -n

View file

@ -29,7 +29,7 @@ bindsym $mod+Shift+p exec ~/.config/i3/scripts/power-profiles
# Panel overdrive # Panel overdrive
bindsym $mod+Shift+o exec button=1 ~/.config/i3/scripts/refresh-rate 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 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 bindsym XF86MonBrightnessDown exec --no-startup-id ~/.config/i3/scripts/volume_brightness.sh brightness_down