简体   繁体   English

唤醒时执行 bash 脚本

[英]Executing bash script on wakeup

Since some time I have a Prolbem with my Linux distribution (Kubuntu 18.04).一段时间以来,我的 Linux 发行版(Kubuntu 18.04)有一个问题。 Every time my linux comes back from standby modus the touchpad is not working properly anymore (can't grab and drag files or other objects).每次我的 linux 从待机模式恢复时,触摸板都无法正常工作(无法抓取和拖动文件或其他对象)。

I already found a solution for my Problem:我已经为我的问题找到了解决方案:

modprobe psmouse -r
modprobe psmouse

This code does solve the problem.这段代码确实解决了这个问题。 However, after this the rightclick area which I always disable at sartup is enabled again.但是,在此之后,我总是在 sartup 禁用的右键单击区域再次启用。 I have a script that runs on startup which executes the following:我有一个在启动时运行的脚本,它执行以下操作:

synclient RightButtonAreaLeft=0
synclient RightButtonAreaTop=0

What I am now trying to do, is to write a script that runs whenever the system is waking up form standby modus.我现在要做的是编写一个脚本,该脚本在系统从待机模式唤醒时运行。 I wrote the script like this:我写了这样的脚本:

#!/bin/bash
exec 1> /home/luc/Schreibtisch/update.log 2>&1
set -x

case $1/$2 in
  pre/*)
    echo "Going to $2..."
    # Place your pre suspend commands here, or `exit 0`
    # if no pre suspend action required
    exit 0
    ;;
  post/*)
    echo "Waking up from $2..."

    sh /home/luc/Schreibtisch/test.sh
    sh /home/luc/Schreibtisch/test2.sh
    ;;
esac

Where test.sh runs the modprobe commands and test2.sh runs the synclient commands.其中 test.sh 运行modprobe命令,而 test2.sh 运行synclient命令。

After going to standby modus and waking up again I'm getting the following log:进入待机模式并再次醒来后,我收到以下日志:

+ case $1/$2 in
+ echo 'Waking up from suspend...'
Waking up from suspend...
+ sh /home/luc/Schreibtisch/test.sh
+ sh /home/luc/Schreibtisch/test2.sh
Failed to connect to X Server.
Failed to connect to X Server.

And the grabing and draging of the files works perfectly but the rightclick is still enabled.并且文件的抓取和拖动工作完美,但仍然启用右键单击。

My question is now if it is possible to execute the synclient commands after the X Server is ready?我现在的问题是在 X 服务器准备好之后是否可以执行synclient命令?

Kind regards Pepsilon亲切的问候百事隆

It looks like i have found a workaround for the problem of the touchpad not working properly after wakeup.看来我找到了解决唤醒后触摸板无法正常工作的问题的解决方法。

In my /etc/modprobe.d/blacklist.conf the module i2c_i801 was blacklisted.在我的/etc/modprobe.d/blacklist.conf模块i2c_i801被列入黑名单。 After removing this module form the blacklist my touchpad now works fine after standby mode.从黑名单中删除此模块后,我的触摸板现在在待机模式后可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM