简体   繁体   English

我想在启动时执行脚本(.sh文件),以便可以设置鼠标的灵敏度。 我怎样才能做到这一点?

[英]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 使用以下步骤在启动时执行脚本

  1. Create your file in /etc/init.d location. /etc/init.d位置创建文件。 Here the format of the file is important 这里文件的格式很重要

    !/bin/bash !/斌/庆典

    Source function library. 源函数库。

    . /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

  2. 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.

相关问题 Robot Framework:如何在测试用例中执行 .sh 文件? - Robot Framework: How can I execute a .sh file in a test case? 如何在启动时自动运行此脚本 - How can I run this script automatically on startup 如何设置用户的权限,以便它可以执行bash脚本来读取其他用户的文件? - How can I set up a user's permissions so it can execute a bash script to read other users' files? 我可以在POSIX sh脚本中避免使用此子shell吗? - Can I avoid this subshell in a POSIX sh script? 我怎样才能让“sudo chmod +x my_script.sh”工作? (不允许操作)(Fedora 30) - How can I get "sudo chmod +x my_script.sh" to work? (operation not permitted) (Fedora 30) 如何在外壳程序脚本中包含html? 执行shell脚本时能否获得html格式的输出? - How can I include html in my shell script? Can I get html formatted output when I execute my shell script? 如何创建一个运行五个 osmocom 脚本的 sh 脚本? - How can I create a sh script for running five osmocom scripts? 如何在脚本中执行grep? - How Can i Execute grep in a Script? 如何从bash中的第二个文件sh中读取值? - How can I read a value from a second file sh in bash? 如何检查启动时是否调用了初始化脚本? - How can I check if init script called on startup?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM