我在我的新笔记本(Lenovo Yoga Pad)上安装了 Fedora(3.17.2-200.fc20.x86_64),并希望添加此脚本以在我翻转屏幕时触发。事件触发的脚本位于 root/etc/acpi/actions
并由 root 拥有。
问题:当我翻转屏幕时,除了 SELinux 告诉我不同的警告(例如访问被拒绝,一些关于 ioctl 和读取的内容等,我无法正确回忆起来)之外,什么也没发生。无论如何,它告诉我运行grep tablet_mode.ori /var/log/audit/audit.log | audit2allow -M mypol
并semodule -i mypol.pp
修复它,我这样做了,但重新启动后,当我翻转屏幕时什么也没有发生。现在,我删除了主目录中的 mypol 文件,因为我认为我可以再次查看 SELinux 输出。
我现在陷入困境,我害怕在我的 SELinux 中打开安全漏洞,对此的正确解决方案是什么?有趣的是,当我重新启动 acpid 并sudo killall acpid && sudo acpid
触发事件并起作用时,在这种情况下唯一不起作用的是 gsettings 命令,它不会显示任何错误,但不会更改我的用户(toor)。
这是由事件触发的脚本:
#!/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
这是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
这将是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
希望你能帮我解决这个问题,我很感激任何帮助