diff --git a/options/custom/desktops/hyprland/binds.nix b/options/custom/desktops/hyprland/binds.nix index 284a5d8..cb946cc 100644 --- a/options/custom/desktops/hyprland/binds.nix +++ b/options/custom/desktops/hyprland/binds.nix @@ -16,6 +16,7 @@ with lib; let jq = "${pkgs.jq}/bin/jq"; kill = "${pkgs.procps}/bin/kill"; kitty = "${config.home-manager.users.${config.custom.username}.programs.kitty.package}/bin/kitty"; + left = "~/.local/bin/left"; loginctl = "${pkgs.systemd}/bin/loginctl"; menu = "~/.local/bin/menu"; nautilus = "${pkgs.nautilus}/bin/nautilus"; @@ -127,7 +128,7 @@ in { # TODO: Toggle trackball hand #// (key "Delete" "Super" "exec" "left") - (key "Delete" "Super+Shift" "exec" "vrr") + (key "Delete" "Super+Shift" "exec" "${left} kensington-orbit-wireless-tb-mouse") (key "Down" "Super" "movewindow" "d") (key "Down" "Super+Shift" "movewindoworgroup" "d") (key "Equal" "Super" "exec" "audio Normalizer") diff --git a/options/custom/desktops/hyprland/settings.nix b/options/custom/desktops/hyprland/settings.nix index 77dfa3b..1190d28 100644 --- a/options/custom/desktops/hyprland/settings.nix +++ b/options/custom/desktops/hyprland/settings.nix @@ -9,6 +9,7 @@ with lib; let firefox-esr = "${ config.home-manager.users.${config.custom.username}.programs.firefox.finalPackage }/bin/firefox-esr"; + left = "~/.local/bin/left"; pkill = "${pkgs.procps}/bin/pkill"; rm = "${pkgs.coreutils}/bin/rm"; sleep = "${pkgs.coreutils}/bin/sleep"; diff --git a/options/custom/scripts/left.sh b/options/custom/scripts/left.sh index 82ac60e..9f4c0ee 100644 --- a/options/custom/scripts/left.sh +++ b/options/custom/scripts/left.sh @@ -1,15 +1,27 @@ #! /usr/bin/env bash # Toggle left-handed mouse -# TODO: Make device-specific when commit released -# https://github.com/hyprwm/hyprlang/commit/95471ec86f37acb8281062e54e2be99b24b50cd0 +#?? left DEVICE -left=$(("$(hyprctl getoption input:left_handed -j | jq '.int')" - 1)) +# 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 -hyprctl keyword input:left_handed ${left#-} - -if [[ "$(hyprctl getoption input:left_handed -j | jq '.int')" == 1 ]]; then - notify-send '> left' 'Left-handed' --urgency low -else - notify-send '> left' 'Right-handed' --urgency low +if (("$#" == 0)); then + touch "$FILE" + exit +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 + hyprctl keyword "device[$1]:left_handed" true + hyprctl keyword "device[$1]:natural_scroll" true + touch "$FILE" + notify-send "> left" "Left-handed" --urgency low fi