From e427b6420cfd474dfc2e8951d74702f6607ef4b9 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Thu, 17 Jun 2021 17:30:28 +0200 Subject: [PATCH] further work on de-p1st-rotate (2) --- pkg/de-p1st-rotate/PKGBUILD | 2 +- pkg/de-p1st-rotate/usr/bin/de-p1st-rotate-screen | 13 ++++++++----- .../usr/lib/de-p1st-rotate/get-orientation | 5 ++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/de-p1st-rotate/PKGBUILD b/pkg/de-p1st-rotate/PKGBUILD index 7e547e8..14cfc3d 100644 --- a/pkg/de-p1st-rotate/PKGBUILD +++ b/pkg/de-p1st-rotate/PKGBUILD @@ -2,7 +2,7 @@ _pkgname=rotate _reponame=arch pkgname="de-p1st-$_pkgname" -pkgver=0.0.8 +pkgver=0.0.9 pkgrel=1 pkgdesc="Scripts to automate screen rotation" arch=('any') diff --git a/pkg/de-p1st-rotate/usr/bin/de-p1st-rotate-screen b/pkg/de-p1st-rotate/usr/bin/de-p1st-rotate-screen index 9bb70bc..87c1d1d 100644 --- a/pkg/de-p1st-rotate/usr/bin/de-p1st-rotate-screen +++ b/pkg/de-p1st-rotate/usr/bin/de-p1st-rotate-screen @@ -8,12 +8,15 @@ if [ "$#" -gt "1 " ] || [ "${1}" = "-h" ] || [ "${1}" = "--help" ] ; then - Manually specify orientation: ${0} ORIENTATION - Automatically detect orientation: - ${0}"; + ${0}" >&2; exit 1; fi if [ -z "${1}" ]; then - ORIENTATION="$(/usr/lib/de-p1st-rotate/get-orientation)" || exit $? + ORIENTATION="$(/usr/lib/de-p1st-rotate/get-orientation)" || { + echo "Could not get orientation: ${ORIENTATION}" >&2; + exit 1; + } else ORIENTATION="$1" fi @@ -22,18 +25,18 @@ fi # if e.g. the given output "$SCREEN" does not exist. # Thus we check if $SCREEN is valid with grep: xrandr --listmonitors | grep --quiet "\s${SCREEN}\$" || { - echo "The given screen ${SCREEN} does not exist."; + echo "The given screen ${SCREEN} does not exist." >&2; exit 1; } xrandr --output "${SCREEN}" --rotate "${ORIENTATION}" || { - echo "Could not rotate ${SCREEN}!"; + echo "Could not rotate ${SCREEN}!" >&2; exit 1; } for i in "${DEVICES[@]}"; do xinput --map-to-output "${i}" "${SCREEN}" || { - echo "Could not map device ${i} to screen ${SCREEN}! Please check output of 'xinput'."; + echo "Could not map device ${i} to screen ${SCREEN}! Please check output of 'xinput'." >&2; FAILURE=true } done diff --git a/pkg/de-p1st-rotate/usr/lib/de-p1st-rotate/get-orientation b/pkg/de-p1st-rotate/usr/lib/de-p1st-rotate/get-orientation index 1be7a57..5d8d31d 100644 --- a/pkg/de-p1st-rotate/usr/lib/de-p1st-rotate/get-orientation +++ b/pkg/de-p1st-rotate/usr/lib/de-p1st-rotate/get-orientation @@ -24,12 +24,11 @@ case "${ORIENTATION_STR}" in ORIENTATION="left"; ;; *": undefined"*) - echo "The orientation could not yet be determined. Please rotate the device a bit and try again." + echo "The orientation could not yet be determined. Please rotate the device a bit and try again." >&2; exit 1; ;; *) - echo "Could not parse ORIENTATION_STR!"; - echo "${ORIENTATION_STR}"; + echo "Could not parse ORIENTATION_STR: ${ORIENTATION_STR}" >&2; exit 1; esac