Score:0

How to turn a shell script to startup program?

vn flag

So I am currently using Ubuntu in my Lenovo 330 15ikb(Model 81DC) I am using a script https://github.com/anitaggu/ikbdop/ to disable my keyboard but I don't want to type the commands every time I open my laptop by cold booting.

Commands:-

./ikbdop.sh attach #to attach the internal keybord
./ilbdop.sh detach #to detach the internal keyboard

Is there a way to run the detach command every time I turn on my laptop or your can say how to turn that script to an startup application with automatic detach command?

Note:- I am not a professional so please write in a simple language.

cocomac avatar
cn flag
Welcome to Ask Ubuntu. Zorin OS is off-topic here, so your question will probably be closed as off-topic, but you can try to ask on [Unix & Linux Stack Exchange](https://unix.stackexchange.com/). Just to point you in the right direction, look into creating a `service` that runs on startup on Linux.
cocomac avatar
cn flag
Oh OK. Your original post said Zorin OS, but if you ended up using Ubuntu, you are all good. I've also removed my off-topic flag as you are using Ubuntu. Sorry for any misunderstanding.
Mine Easter avatar
vn flag
Man I accidentally deleted the previous comment but anyways I don't get it how do I turn that script to startup program with automatic detach command.
cocomac avatar
cn flag
@MineEster I added an answer explaining one possible way. Some other possible ways are in [this question](https://askubuntu.com/q/814/1438484).
Score:0
cn flag

There are many ways to run a script at startup, but here is one way using cron.

Create a script somewhere on your disk, say, /home/you/myscript.sh, and put the following in the script. This will be the commands that are ran every time you startup your computer, so double-check that they are correct. The first line (#!/usr/bin/env bash) tells Ubuntu to use Bash to run this script.

#!/usr/bin/env bash
/full/path/to/ikbdop.sh attach
/full/path/to/ilbdop.sh detach

Save the script where you want. Make it executable (chmod +x myscript.sh). Run crontab -e to edit your cronfile. Add a line to it that says @reboot /full/path/to/script.sh (replace the path with the location of your script, of course).

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.