From 2c09337e6153fb64d2fdb714138c734f30ae5257 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Thu, 17 Jun 2021 17:20:23 +0200 Subject: [PATCH] further work on de-p1st-rotate --- pkg/de-p1st-rotate/PKGBUILD | 6 +++--- pkg/de-p1st-rotate/examples/rotate.sh | 3 +++ pkg/de-p1st-rotate/usr/bin/de-p1st-rotate-screen | 14 +++++++++++--- .../de-p1st-rotate/get-orientation} | 3 +-- 4 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 pkg/de-p1st-rotate/examples/rotate.sh rename pkg/de-p1st-rotate/usr/{bin/de-p1st-auto-rotate => lib/de-p1st-rotate/get-orientation} (90%) diff --git a/pkg/de-p1st-rotate/PKGBUILD b/pkg/de-p1st-rotate/PKGBUILD index b0ca8e5..34a8293 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.6 +pkgver=0.0.7 pkgrel=1 pkgdesc="Scripts to automate screen rotation" arch=('any') @@ -17,7 +17,7 @@ package() { cd "${_reponame}/pkg/${pkgname}" install -Dm0555 usr/bin/de-p1st-rotate-screen "$pkgdir"/usr/bin/de-p1st-rotate-screen - install -Dm0555 usr/bin/de-p1st-auto-rotate "$pkgdir"/usr/bin/de-p1st-auto-rotate - install -Dm0644 -o0 etc/de-p1st-rotate/config.cfg "$pkgdir"/etc/de-p1st-rotate/config.cfg + install -Dm0644 -o0 usr/lib/de-p1st-rotate/get-orientation "$pkgdir"/usr/lib/de-p1st-rotate/get-orientation + install -Dm0644 -o0 etc/de-p1st-rotate/config.cfg "$pkgdir"/etc/de-p1st-rotate/config.cfg } diff --git a/pkg/de-p1st-rotate/examples/rotate.sh b/pkg/de-p1st-rotate/examples/rotate.sh new file mode 100644 index 0000000..e3f390b --- /dev/null +++ b/pkg/de-p1st-rotate/examples/rotate.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +de-p1st-rotate-screen 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 43233d3..9bb70bc 100644 --- a/pkg/de-p1st-rotate/usr/bin/de-p1st-rotate-screen +++ b/pkg/de-p1st-rotate/usr/bin/de-p1st-rotate-screen @@ -3,12 +3,20 @@ # @post: $SCREEN variable and $DEVICES array are set source /etc/de-p1st-rotate/config.cfg || exit $? -if [ "$#" -ne "1" ]; then - echo "usage: $0 ORIENTATION"; +if [ "$#" -gt "1 " ] || [ "${1}" = "-h" ] || [ "${1}" = "--help" ] ; then + echo "usage: +- Manually specify orientation: + ${0} ORIENTATION +- Automatically detect orientation: + ${0}"; exit 1; fi -ORIENTATION="$1" +if [ -z "${1}" ]; then + ORIENTATION="$(/usr/lib/de-p1st-rotate/get-orientation)" || exit $? +else + ORIENTATION="$1" +fi # "xrandr ... || exit 1" does not work to check if $SCREEN exists. # if e.g. the given output "$SCREEN" does not exist. diff --git a/pkg/de-p1st-rotate/usr/bin/de-p1st-auto-rotate b/pkg/de-p1st-rotate/usr/lib/de-p1st-rotate/get-orientation similarity index 90% rename from pkg/de-p1st-rotate/usr/bin/de-p1st-auto-rotate rename to pkg/de-p1st-rotate/usr/lib/de-p1st-rotate/get-orientation index b9177d7..1be7a57 100644 --- a/pkg/de-p1st-rotate/usr/bin/de-p1st-auto-rotate +++ b/pkg/de-p1st-rotate/usr/lib/de-p1st-rotate/get-orientation @@ -33,5 +33,4 @@ case "${ORIENTATION_STR}" in exit 1; esac -# echo "Detected device orientation ${ORIENTATION}" -de-p1st-rotate-screen "${ORIENTATION}" +echo "${ORIENTATION}"