3

I got Ubuntu 17.10 recently, and it is amazing. I am using it on my HP Pavilion, and when I rotate the screen, the touchpad isn't rotating. I don't have a touchscreen. I want to rotate the touchpad with the screen, but couldn't get it to work. I looked at a lot of questions here, like this one, and many others, but none of them worked. Can somebody please help me?

aravk33
  • 264

1 Answers1

2

I am not sure if you are still looking for a solution to this but I had written a script a while back to get this functionality. it uses xrandr and xinput.

put the following in ~/bin after replacing eDP1 with the screen your touchpad to follow. can get a list of your screens by running xrandr.

change --output eDP1 to -o if you want to rotate all screens.

you may need to play around with the code that gets the xinput id for your touchpad.

make sure it is executable and also bin is in $PATH variable.

without stuff that doesn't pretain your question

#!/bin/bash
#inverted -> right -> normal -> left -> inverted
status="$(xrandr -q|grep eDP1|awk '{print $3}')"
if [ $status == 'primary' ]; then
   state="$(xrandr -q|grep eDP1|awk '{print $5}')"
else
   state="$(xrandr -q|grep eDP1|awk '{print $4}')"
fi
touchpad=$(xinput | awk '/Touchpad/ {print $7}' | grep -oP [0-9]+) #


case "${state}" in
'inverted')
  xrandr --output eDP1 --rotate right
  xinput set-prop "$touchpad" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 0 0 0 1
  ;;
'right')
  xrandr --output eDP1 --rotate normal
  xinput set-prop ${touchpad} --type=float "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
  ;;
'(normal')
  xrandr --output eDP1 --rotate left 
  xinput set-prop ${touchpad} --type=float "Coordinate Transformation Matrix" 0 -1 0 1 0 0 0 0 1
  ;;
'left')
  xrandr --output eDP1 --rotate inverted
  xinput set-prop ${touchpad} --type=float "Coordinate Transformation Matrix" -1 0 0 0 -1 0 0 0 1
  ;;
esac

I have it doing custom things as well

#!/bin/bash
#inverted -> right -> normal -> left -> inverted
state="$(orientation)"
#[ "${state}" == 'inverted' ] && xrandr --output eDP1 --rotate right || ([ "${state}" == 'right' ] && xrandr --output eDP1 --rotate normal || ([ "${state}" == 'left' ] && xrandr --output eDP1 --rotate inverted || xrandr --output eDP1 --rotate left));
#sleep 2
#xrandr-invert-colors;
touchpad=$(xinput | awk '/Touchpad/ {print $7}' | grep -oP [0-9]+) #xinput list --id-only "ipts 1B96:005E Touchscreen"
libinput_enabled=false
gestures_enabled=true

case "${state}" in
'inverted')
  xrandr --output eDP1 --rotate right
  xinput set-prop "$touchpad" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 0 0 0 1
  if [ "$libinput_" = true ]; then  
    cp ~/.config/libinput-gestures.conf_right ~/.config/libinput-gestures.conf
    libinput-gestures-setup restart
  fi
  ;;
'right')
  xrandr --output eDP1 --rotate normal
  xinput set-prop ${touchpad} --type=float "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
  if [ "$libinput_" = true ]; then
    cp ~/.config/libinput-gestures.conf_normal ~/.config/libinput-gestures.conf
    libinput-gestures-setup restart
  fi
  ;;
'(normal')
  xrandr --output eDP1 --rotate left 
  xinput set-prop ${touchpad} --type=float "Coordinate Transformation Matrix" 0 -1 0 1 0 0 0 0 1
  if [ "$libinput_" = true ]; then
    cp ~/.config/libinput-gestures.conf_left ~/.config/libinput-gestures.conf
    libinput-gestures-setup restart
  fi
  ;;
'left')
  xrandr --output eDP1 --rotate inverted
  xinput set-prop ${touchpad} --type=float "Coordinate Transformation Matrix" -1 0 0 0 -1 0 0 0 1
  if [ "$libinput_" = true ]; then
    cp ~/.config/libinput-gestures.conf_inverted ~/.config/libinput-gestures.conf
    libinput-gestures-setup restart
  fi
  ;;
esac

if [ "$gestures_enabled" = true ]; then
   restartTouchpad;
fi