From cdb9694360a031c15ac194be01ff9896442d5d71 Mon Sep 17 00:00:00 2001 From: N1R4 Date: Fri, 1 May 2026 20:32:11 +0545 Subject: [PATCH] Add a toggle for touchscreen on supported devices (#5510) * Add minimum brightness cap to prevent OLED displays turning off * Revert "Add minimum brightness cap to prevent OLED displays turning off" This reverts commit fe855ecf9aeacfa1b9ffcff3d43adb10908435e5. * Add touchscreen toggle support * Use finger glyph --------- Co-authored-by: David Heinemeier Hansson --- bin/omarchy-hw-touchscreen | 4 ++++ bin/omarchy-menu | 5 +++++ bin/omarchy-toggle-touchscreen | 29 +++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100755 bin/omarchy-hw-touchscreen create mode 100755 bin/omarchy-toggle-touchscreen diff --git a/bin/omarchy-hw-touchscreen b/bin/omarchy-hw-touchscreen new file mode 100755 index 00000000..47157398 --- /dev/null +++ b/bin/omarchy-hw-touchscreen @@ -0,0 +1,4 @@ +#!/bin/bash + +device=$(hyprctl devices -j | jq -r '[.touch[]?.name, .tablets[]?.name] | first // empty') +[[ -n $device ]] && echo "$device" diff --git a/bin/omarchy-menu b/bin/omarchy-menu index add96198..52cb3048 100755 --- a/bin/omarchy-menu +++ b/bin/omarchy-menu @@ -194,10 +194,15 @@ show_hardware_menu() { options="$options\n󰟸 Touchpad" fi + if omarchy-hw-touchscreen; then + options="$options\n󰆽 Touchscreen" + fi + case $(menu "Toggle" "$options") in *Laptop*) omarchy-hyprland-monitor-internal toggle ;; *Mirror*) omarchy-hyprland-monitor-internal-mirror toggle;; *Touchpad*) omarchy-toggle-touchpad ;; + *Touchscreen*) omarchy-toggle-touchscreen ;; *"Hybrid GPU"*) present_terminal omarchy-toggle-hybrid-gpu ;; *) back_to show_trigger_menu ;; esac diff --git a/bin/omarchy-toggle-touchscreen b/bin/omarchy-toggle-touchscreen new file mode 100755 index 00000000..81414c98 --- /dev/null +++ b/bin/omarchy-toggle-touchscreen @@ -0,0 +1,29 @@ +#!/bin/bash + +STATE_CONF="$HOME/.local/state/omarchy/toggles/hypr/touchscreen-disabled.conf" + +device="$(omarchy-hw-touchscreen)" + +if [[ -z $device ]]; then + echo "No touchscreen device found" >&2 + exit 1 +fi + +enable() { + hyprctl keyword "device[$device]:enabled" true >/dev/null + rm -f "$STATE_CONF" + omarchy-swayosd-client --custom-icon device-support-touch-symbolic --custom-message "Touchscreen enabled" +} + +disable() { + hyprctl keyword "device[$device]:enabled" false >/dev/null + mkdir -p "$(dirname "$STATE_CONF")" + printf 'device {\n name = %s\n enabled = false\n}\n' "$device" > "$STATE_CONF" + omarchy-swayosd-client --custom-icon touch-disabled-symbolic --custom-message "Touchscreen disabled" +} + +case "${1:-toggle}" in + on) enable ;; + off) disable ;; + toggle) if [[ -f $STATE_CONF ]]; then enable; else disable; fi ;; +esac \ No newline at end of file