further work on de-p1st-rotate (2)

This commit is contained in:
Daniel Langbein 2021-06-17 17:30:28 +02:00
parent 291fe5482c
commit e427b6420c
3 changed files with 11 additions and 9 deletions

View File

@ -2,7 +2,7 @@
_pkgname=rotate _pkgname=rotate
_reponame=arch _reponame=arch
pkgname="de-p1st-$_pkgname" pkgname="de-p1st-$_pkgname"
pkgver=0.0.8 pkgver=0.0.9
pkgrel=1 pkgrel=1
pkgdesc="Scripts to automate screen rotation" pkgdesc="Scripts to automate screen rotation"
arch=('any') arch=('any')

View File

@ -8,12 +8,15 @@ if [ "$#" -gt "1 " ] || [ "${1}" = "-h" ] || [ "${1}" = "--help" ] ; then
- Manually specify orientation: - Manually specify orientation:
${0} ORIENTATION ${0} ORIENTATION
- Automatically detect orientation: - Automatically detect orientation:
${0}"; ${0}" >&2;
exit 1; exit 1;
fi fi
if [ -z "${1}" ]; then 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 else
ORIENTATION="$1" ORIENTATION="$1"
fi fi
@ -22,18 +25,18 @@ fi
# if e.g. the given output "$SCREEN" does not exist. # if e.g. the given output "$SCREEN" does not exist.
# Thus we check if $SCREEN is valid with grep: # Thus we check if $SCREEN is valid with grep:
xrandr --listmonitors | grep --quiet "\s${SCREEN}\$" || { 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; exit 1;
} }
xrandr --output "${SCREEN}" --rotate "${ORIENTATION}" || { xrandr --output "${SCREEN}" --rotate "${ORIENTATION}" || {
echo "Could not rotate ${SCREEN}!"; echo "Could not rotate ${SCREEN}!" >&2;
exit 1; exit 1;
} }
for i in "${DEVICES[@]}"; do for i in "${DEVICES[@]}"; do
xinput --map-to-output "${i}" "${SCREEN}" || { 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 FAILURE=true
} }
done done

View File

@ -24,12 +24,11 @@ case "${ORIENTATION_STR}" in
ORIENTATION="left"; ORIENTATION="left";
;; ;;
*": undefined"*) *": 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; exit 1;
;; ;;
*) *)
echo "Could not parse ORIENTATION_STR!"; echo "Could not parse ORIENTATION_STR: ${ORIENTATION_STR}" >&2;
echo "${ORIENTATION_STR}";
exit 1; exit 1;
esac esac