[英]I want to execute a script (.sh file) on startup so that I can set the sensitivity of my mouse. How can I do this?
Basically, I want to be able to have a script run on startup. 基本上,我希望能够在启动时运行脚本。
The script I want to run is: 我要运行的脚本是:
#!/bin/sh
xinput --set-prop 13 "Device Accel Constant Deceleration" 1.3
I tried putting the script in /etc/init.d
like other threads suggested but this did not run the script. 我尝试像建议的其他线程一样将脚本放入/etc/init.d
但这没有运行该脚本。 I have chmod
it to +x
as well. 我也将它chmod
为+x
。
Does anybody have any suggestions as how to get this to run on startup? 有人对如何在启动时运行有任何建议吗?
Thank you 谢谢
Put the following in ~/.profile which is executed only when you log in with a graphic interface: 将以下内容放在〜/ .profile中,仅在使用图形界面登录时才执行:
source /path/to/script.sh
or simply copy in it: 或直接复制到其中:
xinput --set-prop 13 "Device Accel Constant Deceleration" 1.3
Use following steps to execute your script on startup 使用以下步骤在启动时执行脚本
Create your file in /etc/init.d location. 在/etc/init.d位置创建文件。 Here the format of the file is important 这里文件的格式很重要
. 。 /etc/init.d/functions /etc/init.d/functions
start() { # Here you write your script that should be executed on start up start(){#您在此处编写应在启动时执行的脚本
} }
stop() { 停() {
# This get called by kill scripts #这被杀死脚本调用
} }
case "$1" in 案例“ $ 1”在
start) 开始)
start 开始
;; ;;
stop) 停)
stop 停
;; ;;
restart) 重新开始)
stop 停
start 开始
;; ;;
status) 状态)
# This is optional #这是可选的
;; ;;
*) *)
echo "Usage: $0 {start|stop|status|restart}" echo“用法:$ 0 {开始|停止|状态|重新启动}”
esac ESAC
exit 0 出口0
After first step is done , you create a symbolic link in /etc/rc3.d/ which will point to above script 第一步完成后,您将在/etc/rc3.d/中创建一个符号链接,该链接将指向上面的脚本
ex: if some_script is your script name link should be created like 例如:如果some_script是您的脚本名称链接,则应像
ln -s ../init.d/some_script S01some_script ln -s ../init.d/some_script S01some_script
If you want somethings to be executed on shutdown time you may create a link with capital K this is called as kill script 如果您希望在关闭时执行某些操作,则可以创建一个大写的K链接,这称为kill脚本。
Thanks, 谢谢,
Sudhir 苏德赫
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.