Shortcut keys: two commands are not possible

In the shortcut keys, I would like to use two commands, but it seems to be that it is not possible. In the terminal it is possible. This would be the two commands in one:
xrandr -o inverted && xinput set-prop 9 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1
Is there a trick how to use two commands?
Or is this possible only with a script?

You can pass it to a shell;

bash -c 'xrandr -o inverted && touch ~/flag_is.inverted'

(The second cmd creates a file in your home directory.)

(In reference to your other topic, I would recommend you use a script instead. It’s easier to maintain.
You can use the existence of a file as a flag. And test that flag in a script.

# one-button-toggle.sh

if [ -f ~/flag_is.inverted ]; then 
    # flip back to normal
   rm ~/flag_is.inverted
else
    # invert screen
   touch ~/flag_is.inverted
fi
1 Like

That works for me as command (that consists each of two commands) for the shortcuts:
normal (Shift+F1):
bash -c ‘xrandr -o normal && xinput set-prop 9 ‘Coordinate Transformation Matrix’ 1 0 0 0 1 0 0 0 1’
inverted (Shift+F2):
bash -c ‘xrandr -o inverted && xinput set-prop 9 ‘Coordinate Transformation Matrix’ -1 0 1 0 -1 1 0 0 1’
left (Shift+F3):
bash -c ‘xrandr -o left && xinput set-prop 9 ‘Coordinate Transformation Matrix’ 0 -1 1 1 0 0 0 0 1’
right (Shift+F4):
bash -c ‘xrandr -o right && xinput set-prop 9 ‘Coordinate Transformation Matrix’ 0 1 0 -1 0 1 0 0 1’

@humpty Thank you so much for your help.

The toggle solution:
I use this command for Shift+F2 as shortcut:
sh one-button-toggle.sh

Content of one-button-toggle.sh:

#!/bin/sh
if [ -f ~/flag_is.inverted ]; then 
   xrandr -o normal
   xinput set-prop 9 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
   rm ~/flag_is.inverted
else
   xrandr -o inverted
   xinput set-prop 9 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1
   touch ~/flag_is.inverted
fi

@humpty Thank you so much for your help.

Just for information: I recognized today that the id can change. The last days the id was 9, but today the id is 13.

Yes, I was afraid of that.
This is a from a trick I use with my mouse script which I have modified for you. If it works, you can get rid of the echo…

#!/bin/bash

NAME='FTSC1000'

ID=`xinput list --short | grep -i "$NAME" | cut -f2 | cut -c4-| head -n1 `
echo $NAME ID is $ID

if [ -f ~/flag_is.inverted ]; then
   xrandr -o normal
   xinput set-prop $ID 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
   rm ~/flag_is.inverted
else
   xrandr -o inverted
   xinput set-prop $ID 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1
   touch ~/flag_is.inverted
fi

@humpty

Thank you for the script, but I found meanwhile a solution:
xinput set-prop 'FTSC1000:00 2808:5012' 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
I have no idea, why in the past it didn’t work. Now it works fine.

2 Likes

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.