diff --git a/options/custom/desktops/hyprland/settings.nix b/options/custom/desktops/hyprland/settings.nix index a9baeec..3ab9a50 100644 --- a/options/custom/desktops/hyprland/settings.nix +++ b/options/custom/desktops/hyprland/settings.nix @@ -61,7 +61,7 @@ in { # https://wiki.hyprland.org/Configuring/Keywords/#executing exec = [ - left # Left-handed at boot + left # Set left-pawed state "${systemctl} --user restart walker" "${sleep} 2 && ${systemctl} --user restart waybar" ]; diff --git a/options/custom/scripts/left.sh b/options/custom/scripts/left.sh index 9f4c0ee..741a87f 100644 --- a/options/custom/scripts/left.sh +++ b/options/custom/scripts/left.sh @@ -1,27 +1,35 @@ #! /usr/bin/env bash -# Toggle left-handed mouse +# Toggle left-pawed mouse #?? left DEVICE # BUG: New hyprctl syntax does not support per-device getoption # https://github.com/hyprwm/hyprlang/issues/43 -# HACK: Condition based on file presence, requires creation at login to set state -#?? exec-once = left -FILE=/tmp/left +# HACK: Condition based on file presence, requires execution at reload to set state +#?? exec = left +FILE="$HOME/.left" -if (("$#" == 0)); then - touch "$FILE" - exit +# Set initial state +if [[ -f "$FILE" ]]; then + left=1 +else + left=0 fi -if [[ -f "$FILE" ]]; then - hyprctl keyword "device[$1]:left_handed" false - hyprctl keyword "device[$1]:natural_scroll" false - rm --force "$FILE" - notify-send "> left" "Right-handed" --urgency low -else +# If device argument, then toggle +if (("$#" > 0)); then + left=$((1 - "$left")) +fi + +# Enforce state +if (("$left")); then hyprctl keyword "device[$1]:left_handed" true hyprctl keyword "device[$1]:natural_scroll" true 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