Giter VIP home page Giter VIP logo

rotbright's Introduction

rotBright - rotation & brightness

Linux bash scripts to get display, brightness, touchscreen (and pen) in tune

Linux distributions tend to neglect thorough special key handling, brightness control, touchscreen and pen support,
especially notebook, tablet and convertible users suffer from half-cooked, incorrect or missing implementation.

In many cases system devices are recognized correctly, so let's use what we got and try to mend it for daily use.


download

download repository from GitHub,
unzip and copy for example to: ~/rotBright

or

copy scripts to current directory
wget https://raw.github.com/qrti/rotBright/master/script/rotate.sh
wget https://raw.github.com/qrti/rotBright/master/script/bright.sh

or

check if git is installed
$ git --version

if git is not installed
$ sudo apt-get install git-all

clone shrink repository to current directory
$ git clone https://github.com/qrti/rotBright.git


configure

figure out your machines touch (and pen) device
$ xinput -list

edit the script
$ nano rotate.sh

if necessary replace preconfigured entries, for correct pen configuration see -> remarks

DEVICE0="pointer:ELAN22A6:00 04F3:22A6"             # Asus T102HA touchscreen
DEVICE1="ELAN22A6:00 04F3:22A6 Pen (0)"             #             pen
DEVICE2="ASUS HID Device ASUS HID Device Touchpad"  #             touchpad

leave an entry empty to not configure a device

DEVICE0="YOUR_DEVICE:xx xxxx:xxxx"      # your touchscreen
DEVICE1=

display rotation possibly sets brightness to maximum, so it has to be restored as well
executing rotate.sh will also call bright.sh and restore brightness if

RESTBRIGHT=true                         # restore brightness

execute

change directory
$ cd ~/rotBright

make scripts executable once
chmod a+x rotate.sh
chmod a+x bright.sh

execute rotation script
$ ./rotate.sh [+|normal|inverted|left|right|restore]

+ normal inverted left right restore
+90° 180° 90° 270° last used current

(counter clockwise)

execute brightness script
$ ./bright.sh [-|+|[10-100]|restore]

- + 10-100 restore
darker brighter absolute last used current

see configure to execute rotate.sh in combination with bright.sh


keyboard shortcuts

for convenient use you can bind rotation and brightness control to keys,
unfortunately on most laptops the special function key in combination with F1..F12 will not work,
so try to figure out unused combinations with CTRL and/or ALT

example for brightness advance
preferences/keyboard/shortcuts/custom shortcuts/add custom shortcut

name: Bright+
command: /home/USERNAME/rotBright/bright.sh +
key: CTRL-F6

replace USERNAME with your username


auto restore

to automatically restore last used rotation and brightness at system start do the following

preferences/startup applications/custom command

name: Restore Rotation and Brightness 
command: /home/USERNAME/rotBright/rotate.sh restore
startup delay: 15

replace USERNAME with your username
on fast systems startup delay can be reduced


remarks

- for correct pen restauration please consider

directly after boot a generic pen device will be listed with xinput
ELAN22A6:00 04F3:22A6 Pen

after first pen use a device instance is added to the list
ELAN22A6:00 04F3:22A6 Pen Pen (0)

use this instance in the script -> configure

- restoring pen orientation after boot and first pen use requires a manual
$ ./rotate.sh restore

- developed under Linux Mint on Asus T102HA Mini Transformer with Visual Studio Code
- not tested on other machines but might work well on various notebooks, tablets and convertibles

inspired by
https://www.linux.com/learn/how-configure-touchscreen-linux
https://askubuntu.com/questions/368317/rotate-touch-input-with-touchscreen-and-or-touchpad
https://gist.github.com/mildmojo/48e9025070a2ba40795c
https://ubuntuforums.org/archive/index.php/t-2313209.html
https://wiki.debian.org/InstallingDebianOn/Asus/T100TA#Screen_power_management

Donations are welcome!

https://www.paypal.com


history

V0.5
- initial version

V0.6
- proper touchpad support (thanks to np2048)
- fixed 'rotation +' bug

rotate V0.7
- corrected device entries


copyright

rotBright is published under the terms of MIT license

Copyright (c) 2019 [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

rotbright's People

Contributors

qrti avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

np2048

rotbright's Issues

Touchpad works incorrectly with rotated screen

Touchpad need to be rotated too in order to work correctly according to the screen. The device 'ASUS HID Device ASUS HID Device Touchpad' has transformation matrix property available through xinput command.
It was working badly originally on Linux (by default screen has a portrait orientation, but touchpad hasn't). But it could be easily fixed by this script.

fix:

  1. new variable
    DEVICE2="ASUS HID Device ASUS HID Device Touchpad" # touchpad
  2. new transormation case:
    case "$2" in normal) [ ! -z "$DEVICE0" ] && xinput set-prop "$DEVICE0" "$TRANSFORM" 1 0 0 0 1 0 0 0 1 [ ! -z "$DEVICE1" ] && xinput set-prop "$DEVICE1" "$TRANSFORM" 1 0 0 0 1 0 0 0 1 [ ! -z "$DEVICE2" ] && xinput set-prop "$DEVICE2" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1 ;; inverted) [ ! -z "$DEVICE0" ] && xinput set-prop "$DEVICE0" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1 [ ! -z "$DEVICE1" ] && xinput set-prop "$DEVICE1" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1 [ ! -z "$DEVICE2" ] && xinput set-prop "$DEVICE2" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1 ;; left) [ ! -z "$DEVICE0" ] && xinput set-prop "$DEVICE0" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1 [ ! -z "$DEVICE1" ] && xinput set-prop "$DEVICE1" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1 [ ! -z "$DEVICE2" ] && xinput set-prop "$DEVICE2" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1 ;; right) [ ! -z "$DEVICE0" ] && xinput set-prop "$DEVICE0" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1 [ ! -z "$DEVICE1" ] && xinput set-prop "$DEVICE1" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1 [ ! -z "$DEVICE2" ] && xinput set-prop "$DEVICE2" "$TRANSFORM" 1 0 0 0 1 0 0 0 1 ;; esac

Incorrect ID for the pen device

I have an Asus T102HA and the pen device name (id) differs from the one that is in the script.
$ uname -a Linux T102 4.19.24-1-MANJARO #1 SMP PREEMPT Wed Feb 20 22:59:23 UTC 2019 x86_64 GNU/Linux

fix:
DEVICE1="ELAN22A6:00 04F3:22A6 Pen Pen (0)"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.