Friday, 5 June 2015

Shell script for startup programs

We are already discussed about creating startup applications via terminal in previous article.



All the time adding and configuring is takes more time. To reduce the time, at the place we need shell script.
To do this, open terminal and create a shell via your favorite text editor.

               $vim startup.sh
               echo "Welcome to Autostart program!"
               echo "Type your configuration file name"
               read confname
               echo "Enter your script path"
               read path
               echo "Enter your program name"
               read pgname
               echo "[Desktop Entry]
               Type=Application
               Exec=$path
               Hidden=false
               X-GNOME-Autostart-enabled=true
               Name=$pgname" >> ~/.config/autostart/$confname\.desktop


Now save and quite by using :wq.

We need to change it as executable. To do this,

              $chmod +x startup.sh

Script is ready for using startup applications.Run the script,

              $sh startup.sh

//It will ask questions. just fillup. The shell script can be done.

Explanation:
         echo = is used to print text
         read = It is used to grab information from users
              = Grabbed information can be displayed
         \        = It is the escaping character in shell script. It is act as a delimiter when we are using standard symbols instead of a script file.
If you have any problem while doing this script, kindly post your problems as a comments. Thank you for reading!

No comments:

Post a Comment