diff --git a/bin/omarchy-hw-touchpad b/bin/omarchy-hw-touchpad new file mode 100755 index 00000000..4bea4a68 --- /dev/null +++ b/bin/omarchy-hw-touchpad @@ -0,0 +1,3 @@ +#!/bin/bash + +hyprctl devices -j | jq -r '[.mice[] | .name | select(test("touchpad|trackpad"; "i"))] | first // empty' diff --git a/bin/omarchy-menu b/bin/omarchy-menu index 972b6e15..25cf71c2 100755 --- a/bin/omarchy-menu +++ b/bin/omarchy-menu @@ -170,7 +170,7 @@ show_share_menu() { show_toggle_menu() { local options="󱄄 Screensaver\n󰔎 Nightlight\n󱫖 Idle Lock\n󰍜 Top Bar\n󱂬 Workspace Layout\n Window Gaps\n 1-Window Ratio\n󰍹 Monitor Scaling\n󰛧 Laptop Display" - if hyprctl devices -j 2>/dev/null | jq -e '[.mice[] | select(.name | test("touchpad|trackpad"; "i"))] | length > 0' >/dev/null; then + if [[ -n "$(omarchy-hw-touchpad)" ]]; then options="$options\n󰟸 Touchpad" fi diff --git a/bin/omarchy-toggle-touchpad b/bin/omarchy-toggle-touchpad index 13611a6f..d2ef6876 100755 --- a/bin/omarchy-toggle-touchpad +++ b/bin/omarchy-toggle-touchpad @@ -3,7 +3,7 @@ STATE_CONF="$HOME/.local/state/omarchy/toggles/hypr/touchpad-disabled.conf" osdclient="swayosd-client --monitor $(omarchy-hyprland-monitor-focused)" -device="$(hyprctl devices -j | jq -r '[.mice[] | .name | select(test("touchpad|trackpad"; "i"))] | first // empty')" +device="$(omarchy-hw-touchpad)" if [[ -z $device ]]; then echo "No touchpad device found" >&2 @@ -24,19 +24,7 @@ disable() { } case "${1:-toggle}" in - on) enable ;; - off) disable ;; - toggle) - if [[ -f $STATE_CONF ]]; then - enable || { - echo "enable failed" >&2 - exit 1 - } - else - disable || { - echo "disable failed" >&2 - exit 1 - } - fi - ;; + on) enable ;; + off) disable ;; + toggle) if [[ -f $STATE_CONF ]]; then enable; else disable; fi ;; esac