2

I installed Fedora (3.17.2-200.fc20.x86_64) on my new Notebook (Lenovo Yoga Pad) and wanted to add this script to trigger whenever I flip over my screen. The script triggered whith the event is located in /etc/acpi/actions and owned by root.

The problem: When I flipped over the screen nothing happened except SELinux telling me different warnings (like access denied, some stuff about ioctl and read etc. that I can't recall properly) Anyway it told me to run grep tablet_mode.ori /var/log/audit/audit.log | audit2allow -M mypol and semodule -i mypol.pp to fix it, I did that but after a reboot nothing happened when I flipped over the screen. Now, I deleted the mypol files in my home directory because I thought I would be able to look at the SELinux output again.

I'm stuck now and I'm afraid of opening security holes in my SELinux, what's the proper solution to this? The funny thing is, when I restart acpid with sudo killall acpid && sudo acpid the event gets triggered and works, the only thing that doesn't work in this case is the gsettings command, it doesn't show any errors, but it doesn't change the settings of my user (toor).

This is the script that gets triggered by the event:

#!/bin/bash

su toor -c "/home/toor/backup/scripts/toggle_keyboard.sh"
touchpad=$(xinput list-props "SynPS/2 Synaptics TouchPad" | grep "Device Enabled" | awk -F ":" '{print $2}')
if [ $touchpad -eq 1 ]; then
    /home/toor/backup/scripts/rotate.sh inverted
    xinput --set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 0
else
    /home/toor/backup/scripts/rotate.sh normal
    xinput --set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 1
fi

This is the rotate.sh:

#!/bin/bash

current_orientation(){
    xrandr|grep " connected" |awk '{print $4}'
}
rotate_left(){
    xrandr -o left
    xsetwacom set "Wacom ISDv4 EC Pen stylus" rotate ccw
        xsetwacom set "Wacom ISDv4 EC Pen eraser" rotate ccw
    xinput set-prop "ELAN Touchscreen" "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
}
rotate_right(){
    xrandr -o right
    xsetwacom set "Wacom ISDv4 EC Pen stylus" rotate cw
        xsetwacom set "Wacom ISDv4 EC Pen eraser" rotate cw
    xinput set-prop "ELAN Touchscreen" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
}
rotate_inverted(){
    xrandr -o inverted
    xsetwacom set "Wacom ISDv4 EC Pen stylus" rotate half
        xsetwacom set "Wacom ISDv4 EC Pen eraser" rotate half
    xinput set-prop "ELAN Touchscreen" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1
}
rotate_normal(){
    xrandr -o normal
    xsetwacom set "Wacom ISDv4 EC Pen stylus" rotate none
        xsetwacom set "Wacom ISDv4 EC Pen eraser" rotate none
    xinput set-prop "ELAN Touchscreen" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
}

orientation=$(current_orientation)

# if the orientation argument was given to this script, sets orientation variable
# according to the way we want to rotate in next loop.
if [ -n "$1" ]; then
    if [ "$1" == "normal" ]; then
        orientation="right"
    fi
    if [ "$1" == "left" ]; then
        orientation="(normal"
    fi
    if [ "$1" == "right" ]; then
        orientation="inverted"
    fi
    if [ "$1" == "inverted" ]; then
        orientation="left"
    fi
fi

# turns 90° counter-clockwise
case $orientation in
    "(normal" )
        rotate_left
        ;;
    "inverted" )
        rotate_right
        ;;
    "right" )
        rotate_normal
        ;;
    "left" )
        rotate_inverted
        ;;
    * )
        echo "it fucked up"
        exit 1
        ;;
esac

exit 0

and this would be the toggle_keyboard.sh

#!/bin/bash
# toggle onboard keyboard

obk=$(gsettings get org.gnome.desktop.a11y.applications screen-keyboard-enabled)

if [ $obk == 'false' ]; then
        gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true
else
        gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled false
fi

Hopefully you can help me out with this one, I appreciate any help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy