1
1
Fork 0

left: set state at reload

Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
Myned 2024-09-17 10:37:53 -05:00
parent 59aef55d50
commit e5c0983fe7
Signed by: myned
GPG key ID: C7224454F7881A34
2 changed files with 23 additions and 15 deletions

View file

@ -61,7 +61,7 @@ in {
# https://wiki.hyprland.org/Configuring/Keywords/#executing # https://wiki.hyprland.org/Configuring/Keywords/#executing
exec = [ exec = [
left # Left-handed at boot left # Set left-pawed state
"${systemctl} --user restart walker" "${systemctl} --user restart walker"
"${sleep} 2 && ${systemctl} --user restart waybar" "${sleep} 2 && ${systemctl} --user restart waybar"
]; ];

View file

@ -1,27 +1,35 @@
#! /usr/bin/env bash #! /usr/bin/env bash
# Toggle left-handed mouse # Toggle left-pawed mouse
#?? left DEVICE #?? left DEVICE
# BUG: New hyprctl syntax does not support per-device getoption # BUG: New hyprctl syntax does not support per-device getoption
# https://github.com/hyprwm/hyprlang/issues/43 # https://github.com/hyprwm/hyprlang/issues/43
# HACK: Condition based on file presence, requires creation at login to set state # HACK: Condition based on file presence, requires execution at reload to set state
#?? exec-once = left #?? exec = left
FILE=/tmp/left FILE="$HOME/.left"
if (("$#" == 0)); then # Set initial state
touch "$FILE" if [[ -f "$FILE" ]]; then
exit left=1
else
left=0
fi fi
if [[ -f "$FILE" ]]; then # If device argument, then toggle
hyprctl keyword "device[$1]:left_handed" false if (("$#" > 0)); then
hyprctl keyword "device[$1]:natural_scroll" false left=$((1 - "$left"))
rm --force "$FILE" fi
notify-send "> left" "Right-handed" --urgency low
else # Enforce state
if (("$left")); then
hyprctl keyword "device[$1]:left_handed" true hyprctl keyword "device[$1]:left_handed" true
hyprctl keyword "device[$1]:natural_scroll" true hyprctl keyword "device[$1]:natural_scroll" true
touch "$FILE" touch "$FILE"
notify-send "> left" "Left-handed" --urgency low 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
fi fi