Files
omarchy-pkgs/pkgbuilds/edge/dell-xps-touchpad-haptics/dell-xps-touchpad-haptics
T
Jacob Mink 8f45850b7d Package Dell XPS touchpad haptics (#86)
* feature: Add Dell haptic touchpad control, update default intensity

* fix: polish Dell haptic touchpad package

Use an MIT license file for the packaged scripts and prefer the active loginctl user in the install hook so the initial intensity setup targets the live desktop session instead of an arbitrary regular account.

* fix: clean up Dell haptic touchpad package metadata

Drop the bundled license file and align the package metadata so the package contents still build cleanly after the maintainer update.

* fix: correct Dell haptic touchpad package URL

Point the package metadata at the canonical omarchy-pkgs repository so users see the source location maintained under the omacom-io project.

* feature: package Dell XPS haptics as standalone service

* fix: tighten Dell haptics package setup
2026-05-07 17:16:22 +02:00

127 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
CONFIG_PATH="$HOME/.config/omarchy/dell-haptic.conf"
DEFAULT_INTENSITY=100
LOW_INTENSITY=10
MID_INTENSITY=50
HIGH_INTENSITY=100
SERVICE_NAME="dell-xps-touchpad-haptics.service"
usage() {
printf 'Usage: %s get | set <low|mid|high>\n' "$(basename -- "$0")"
}
clamp_intensity() {
local value=$1
if ! [[ $value =~ ^[0-9]+$ ]]; then
printf '%s\n' "$DEFAULT_INTENSITY"
return 0
fi
if (( value < 0 )); then
printf '0\n'
elif (( value > 100 )); then
printf '100\n'
else
printf '%s\n' "$value"
fi
}
read_intensity() {
local line=""
local value=""
[[ -f $CONFIG_PATH ]] || {
printf '%s\n' "$DEFAULT_INTENSITY"
return 0
}
while IFS= read -r line; do
line=${line#${line%%[![:space:]]*}}
line=${line%${line##*[![:space:]]}}
[[ -z $line || ${line:0:1} == "#" || $line != *=* ]] && continue
if [[ ${line%%=*} == "INTENSITY" ]]; then
value=${line#*=}
value=${value#${value%%[![:space:]]*}}
value=${value%${value##*[![:space:]]}}
clamp_intensity "$value"
return 0
fi
done < "$CONFIG_PATH"
printf '%s\n' "$DEFAULT_INTENSITY"
}
level_for_intensity() {
local intensity=$1
if (( intensity <= 30 )); then
printf 'low\n'
elif (( intensity < 75 )); then
printf 'mid\n'
else
printf 'high\n'
fi
}
intensity_for_level() {
case "$1" in
low) printf '%s\n' "$LOW_INTENSITY" ;;
mid | medium) printf '%s\n' "$MID_INTENSITY" ;;
high) printf '%s\n' "$HIGH_INTENSITY" ;;
*)
echo "Haptic level must be one of: low, mid, high." >&2
exit 1
;;
esac
}
write_config() {
local intensity=$1
install -d -m 755 "$(dirname -- "$CONFIG_PATH")"
printf '# Dell XPS touchpad haptic intensity.\n# Presets: low=10, mid=50, high=100.\nINTENSITY=%s\n' "$intensity" >"$CONFIG_PATH"
}
service_active() {
systemctl is-active --quiet "$SERVICE_NAME" 2>/dev/null
}
case "${1:-}" in
get)
if (( $# != 1 )); then
usage >&2
exit 1
fi
level_for_intensity "$(read_intensity)"
;;
set)
if (( $# != 2 )); then
usage >&2
exit 1
fi
previous_level=$(level_for_intensity "$(read_intensity)")
intensity=$(intensity_for_level "$2")
write_config "$intensity"
if service_active; then
printf 'Set Dell XPS touchpad haptics from %s to %s. The running service will apply and verify the new gain in the journal shortly.\n' "$previous_level" "$(level_for_intensity "$intensity")"
else
printf 'Set Dell XPS touchpad haptics from %s to %s. Start %s to apply it.\n' "$previous_level" "$(level_for_intensity "$intensity")" "$SERVICE_NAME"
fi
;;
--help | -h)
usage
;;
*)
usage >&2
exit 1
;;
esac