2024-09-09 00:22:14 +00:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
|
2024-09-17 15:37:53 +00:00
|
|
|
# Toggle left-pawed mouse
|
2024-09-15 22:42:24 +00:00
|
|
|
#?? left DEVICE
|
2024-09-09 00:22:14 +00:00
|
|
|
|
2024-09-15 22:42:24 +00:00
|
|
|
# BUG: New hyprctl syntax does not support per-device getoption
|
|
|
|
# https://github.com/hyprwm/hyprlang/issues/43
|
2024-09-17 15:37:53 +00:00
|
|
|
# HACK: Condition based on file presence, requires execution at reload to set state
|
|
|
|
#?? exec = left
|
|
|
|
FILE="$HOME/.left"
|
2024-09-09 00:22:14 +00:00
|
|
|
|
2024-09-17 15:37:53 +00:00
|
|
|
# Set initial state
|
2024-09-15 22:42:24 +00:00
|
|
|
if [[ -f "$FILE" ]]; then
|
2024-09-17 15:37:53 +00:00
|
|
|
left=1
|
2024-09-09 00:22:14 +00:00
|
|
|
else
|
2024-09-17 15:37:53 +00:00
|
|
|
left=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If device argument, then toggle
|
|
|
|
if (("$#" > 0)); then
|
|
|
|
left=$((1 - "$left"))
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Enforce state
|
|
|
|
if (("$left")); then
|
2024-09-15 22:42:24 +00:00
|
|
|
hyprctl keyword "device[$1]:left_handed" true
|
|
|
|
hyprctl keyword "device[$1]:natural_scroll" true
|
|
|
|
touch "$FILE"
|
2024-09-17 15:37:53 +00:00
|
|
|
notify-send "> left" "Left-pawed" --urgency low
|
|
|
|
else
|
|
|
|
hyprctl keyword "device[$1]:left_handed" false
|
|
|
|
hyprctl keyword "device[$1]:natural_scroll" false
|
|
|
|
rm --force "$FILE"
|
|
|
|
notify-send "> left" "Right-pawed" --urgency low
|
2024-09-09 00:22:14 +00:00
|
|
|
fi
|