-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working and installable version achived
- Loading branch information
Luca Leon Happel
committed
Nov 7, 2021
0 parents
commit dbee083
Showing
4 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# @AUTHOR: Luca Leon Happel | ||
# @DATE : 2021-11-07 So 19:12 32 | ||
# | ||
|
||
function processnewcommand { | ||
case $1 in | ||
"Accelerometer orientation changed: normal") | ||
echo "screen rotated to normal" | ||
./screenrotation.sh "normal" | ||
;; | ||
"Accelerometer orientation changed: bottom-up") | ||
echo "screen rotated to inverted" | ||
./screenrotation.sh "inverted" | ||
;; | ||
"Accelerometer orientation changed: left-up") | ||
echo "screen rotated to left" | ||
./screenrotation.sh "left" | ||
;; | ||
"Accelerometer orientation changed: right-up") | ||
echo "screen rotated to right" | ||
./screenrotation.sh "right" | ||
;; | ||
esac | ||
} | ||
|
||
export -f processnewcommand | ||
monitor-sensor | xargs --replace=% bash -c 'processnewcommand "%"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ pkgs ? import <nixpkgs> {} }: with pkgs; | ||
|
||
stdenv.mkDerivation { | ||
version = "1.0"; | ||
name = "flex5ScreenRotate"; | ||
src = ./.; | ||
buildInputs = [ | ||
libwacom | ||
xf86_input_wacom | ||
xorg.xrandr | ||
iio-sensor-proxy | ||
]; | ||
dontBuild = true; | ||
installPhase = '' | ||
mkdir -pv $out/bin/ | ||
cp ./screenrotation.sh $out/bin/ | ||
chmod +x $out/bin/screenrotation.sh | ||
cp ./autoscreenrotation.sh $out/bin/ | ||
chmod +x $out/bin/autoscreenrotation.sh | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# flex5ScreenRotate | ||
|
||
Automatically rotate the Lenovo Flex 5 screen and Wacom inputs | ||
given the accelerometer picks up an orientation change | ||
|
||
## Requirements | ||
|
||
Please look in `default.nix` under `buildInputs = [ ... ];` which | ||
programs are reqired. `iio-sensor-proxy` is also needed. | ||
|
||
## Usage | ||
|
||
Run `./autoscreenrotation.sh` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# @AUTHOR: Luca Leon Happel | ||
# @DATE : 2021-06-13 So 00:50 57 | ||
# | ||
# This is a script that toggles rotation of the screen through xrandr, | ||
# and also toggles rotation of the stylus, eraser and cursor through xsetwacom | ||
|
||
screen=`xrandr --current | grep " connected" | awk '{print $1;}'` | ||
orientation=`xrandr --verbose -q | grep $screen | awk '{print $6}'` | ||
|
||
echo $screen | ||
echo $orientation | ||
|
||
function wacom_setup { | ||
xsetwacom set "Wacom HID 5218 Pen stylus" Rotate $1 | ||
xsetwacom set "Wacom HID 5218 Finger touch" Rotate $1 | ||
xsetwacom set "Wacom HID 5218 Pen eraser" Rotate $1 | ||
} | ||
|
||
if [[ -z "$1" ]]; then | ||
echo "Missing argument!" | ||
echo "Possible values are: normal, inverted, left, right" | ||
elif [ "$1" = "normal" ]; then | ||
xrandr --output $screen --rotate normal | ||
wacom_setup none | ||
elif [ "$1" = "inverted" ]; then | ||
xrandr --output $screen --rotate inverted | ||
wacom_setup half | ||
elif [ "$1" = "left" ]; then | ||
xrandr --output $screen --rotate left | ||
wacom_setup ccw | ||
elif [ "$1" = "right" ]; then | ||
xrandr --output $screen --rotate right | ||
wacom_setup cw | ||
fi |