diff --git a/build-pkg/pkglist-de-p1st.txt b/build-pkg/pkglist-de-p1st.txt index 1763a50..de0682c 100644 --- a/build-pkg/pkglist-de-p1st.txt +++ b/build-pkg/pkglist-de-p1st.txt @@ -1,4 +1,4 @@ -de-p1st-locale de-p1st-systemd de-p1st-sudo de-p1st-screen de-p1st-htop de-p1st-pacman de-p1st-pacman-mirrorlist de-p1st-networkmanager de-p1st-ucode-placeholder de-p1st-ucode-intel de-p1st-ucode-amd de-p1st-nano de-p1st-mkinitcpio de-p1st-makepkg de-p1st-grub de-p1st-font de-p1st-keyboard-de de-p1st-keyboard-x11-de de-p1st-gnupg de-p1st-redshift de-p1st-theme de-p1st-sddm-autologin-placeholder de-p1st-sddm-autologin-yoda de-p1st-sddm-theme-default de-p1st-sddm-theme-nordic de-p1st-gpu-generic de-p1st-gpu-amdgpu de-p1st-installer de-p1st-repo de-p1st-ssh-key-placeholder de-p1st-ssh-key-yoda +de-p1st-rotate de-p1st-locale de-p1st-systemd de-p1st-sudo de-p1st-screen de-p1st-htop de-p1st-pacman de-p1st-pacman-mirrorlist de-p1st-networkmanager de-p1st-ucode-placeholder de-p1st-ucode-intel de-p1st-ucode-amd de-p1st-nano de-p1st-mkinitcpio de-p1st-makepkg de-p1st-grub de-p1st-font de-p1st-keyboard-de de-p1st-keyboard-x11-de de-p1st-gnupg de-p1st-redshift de-p1st-theme de-p1st-sddm-autologin-placeholder de-p1st-sddm-autologin-yoda de-p1st-sddm-theme-default de-p1st-sddm-theme-nordic de-p1st-gpu-generic de-p1st-gpu-amdgpu de-p1st-installer de-p1st-repo de-p1st-ssh-key-placeholder de-p1st-ssh-key-yoda de-p1st-smartcard de-p1st-kernel-default de-p1st-kernel-lts de-p1st-dns de-p1st-ssh de-p1st-base de-p1st-xfce4 diff --git a/pkg/de-p1st-rotate/PKGBUILD b/pkg/de-p1st-rotate/PKGBUILD new file mode 100644 index 0000000..a96449a --- /dev/null +++ b/pkg/de-p1st-rotate/PKGBUILD @@ -0,0 +1,23 @@ +# Maintainer: Daniel Langbein +_pkgname=rotate +_reponame=arch +pkgname="de-p1st-$_pkgname" +pkgver=0.0.1 +pkgrel=1 +pkgdesc="Scripts to automate screen rotation" +arch=('any') +url="https://codeberg.org/privacy1st/${_reponame}" +license=('MIT') +depends=('iio-sensor-proxy-git') # iio-sensor-proxy did not work on my Surface Go 2 but the git version dos +makedepends=('git') # to fetch source(s) via git +source=("git+${url}.git") +sha256sums=('SKIP') # 'SKIP' for git sources; Otherwise: autofill using updpkgsums, see https://man.archlinux.org/man/updpkgsums.8.en + +package() { + cd "${_reponame}/pkg/${pkgname}" + + install -Dm0544 usr/bin/de-p1st-rotate-screen "$pkgdir"/usr/bin/de-p1st-rotate-screen + install -Dm0544 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 +} diff --git a/pkg/de-p1st-rotate/etc/de-p1st-rotate/config.cfg b/pkg/de-p1st-rotate/etc/de-p1st-rotate/config.cfg new file mode 100644 index 0000000..1d2b7f3 --- /dev/null +++ b/pkg/de-p1st-rotate/etc/de-p1st-rotate/config.cfg @@ -0,0 +1,16 @@ +# The screen to rotate +SCREEN=eDP-1 # other values could be "eDP1" or "HDMI1" + +# xrandr devices to rotate together with the screen +DEVICES=() +#DEVICES+=( 'pointer:Wacom Pen and multitouch sensor Finger touch' ) # LenovoYoga460 +#DEVICES+=( 'pointer:Wacom Pen and multitouch sensor Pen stylus' ) # LenovoYoga460 +#DEVICES+=( 'pointer:Wacom Pen and multitouch sensor Pen eraser' ) # LenovoYoga460 +# +DEVICES+=( 'pointer:ELAN9038:00 04F3:2A1C' ) # SurfaceGo2 (default) +DEVICES+=( 'pointer:ELAN9038:00 04F3:2A1C Pen (0)' ) # SurfaceGo2 (default) +DEVICES+=( 'pointer:ELAN9038:00 04F3:2A1C Eraser (0)' ) # SurfaceGo2 (default) +# +#DEVICES+=( 'pointer:ELAN9038:00 04F3:2A1C touch' ) # SurfaceGo2 +#DEVICES+=( 'pointer:ELAN9038:00 04F3:2A1C stylus' ) # SurfaceGo2 +#DEVICES+=( 'pointer:ELAN9038:00 04F3:2A1C eraser' ) # SurfaceGo2 \ No newline at end of file diff --git a/pkg/de-p1st-rotate/examples/rotate-inverted.sh b/pkg/de-p1st-rotate/examples/rotate-inverted.sh new file mode 100644 index 0000000..773ce9b --- /dev/null +++ b/pkg/de-p1st-rotate/examples/rotate-inverted.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +de-p1st-rotate-screen "inverted" \ No newline at end of file diff --git a/pkg/de-p1st-rotate/examples/rotate-left.sh b/pkg/de-p1st-rotate/examples/rotate-left.sh new file mode 100644 index 0000000..881cb43 --- /dev/null +++ b/pkg/de-p1st-rotate/examples/rotate-left.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +de-p1st-rotate-screen "left" \ No newline at end of file diff --git a/pkg/de-p1st-rotate/examples/rotate-normal.sh b/pkg/de-p1st-rotate/examples/rotate-normal.sh new file mode 100644 index 0000000..21f7479 --- /dev/null +++ b/pkg/de-p1st-rotate/examples/rotate-normal.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +de-p1st-rotate-screen "normal" \ No newline at end of file diff --git a/pkg/de-p1st-rotate/usr/bin/de-p1st-installer/de-p1st-auto-rotate b/pkg/de-p1st-rotate/usr/bin/de-p1st-installer/de-p1st-auto-rotate new file mode 100644 index 0000000..23ddb7a --- /dev/null +++ b/pkg/de-p1st-rotate/usr/bin/de-p1st-installer/de-p1st-auto-rotate @@ -0,0 +1,29 @@ +#!/bin/bash + +# Output of "monitor-sensor --accel | grep 'orientation'": +# === Has accelerometer (orientation: normal) +# Accelerometer orientation changed: right-up + +# Feed output of 'monitor-sensor' and stop after first match of 'orientation' +ORIENTATION_STR="$(grep -m 1 'orientation' <( monitor-sensor ))" || exit $? + +case "${ORIENTATION_STR}" in + *": normal"*) + ORIENTATION="normal"; + ;; + *": bottom-up"*) + ORIENTATION="inverted"; + ;; + *": right-up"*) + ORIENTATION="left"; + ;; + *": left-up"*) + ORIENTATION="right"; + ;; + *) + echo "Could not parse ORIENTATION_STR!"; + exit 1; +esac + +# echo "Detected device orientation ${ORIENTATION}" +de-p1st-rotate-screen "${ORIENTATION}" diff --git a/pkg/de-p1st-rotate/usr/bin/de-p1st-installer/de-p1st-rotate-screen b/pkg/de-p1st-rotate/usr/bin/de-p1st-installer/de-p1st-rotate-screen new file mode 100644 index 0000000..c43bc8d --- /dev/null +++ b/pkg/de-p1st-rotate/usr/bin/de-p1st-installer/de-p1st-rotate-screen @@ -0,0 +1,36 @@ +#!/bin/bash + +# @post: $SCREEN variable and $DEVICES array are set +source /etc/de-1st-rotate/config.cfg || exit $? + +if [ "$#" -ne "1" ]; then + echo "usage: $0 ORIENTATION"; + exit 1; +fi + +ORIENTATION="$1" + +# "xrandr ... || exit 1" does not work to check if $SCREEN exists. +# 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."; + exit 1; +} + +xrandr --output "${SCREEN}" --rotate "${ORIENTATION}" || { + echo "Could not rotate ${SCREEN}!"; + exit 1; +} + +for i in "${DEVICES[@]}"; do + xinput --map-to-output "${i}" "${SCREEN}" || { + echo "Could not map device ${i} to screen ${SCREEN}!"; + FAILURE=true + } +done + +if [ "${FAILURE}" = "true" ]; then + # At least one error occurred. + exit 1; +fi