Consider this script (saved as /home/muru/test.sh
):
#! /bin/bash
DRI_PRIME=1 glxgears -info
A basic launcher for this would look like (say, save it as /home/muru/test.desktop
):
[Desktop Entry]
Type=Application
Terminal=true
Name=glx-gears-info
Exec=/home/muru/test.sh
Make them both executable:
chmod +x test.sh test.desktop
Now you should have these two entries in your home folder:
Notice how the name is glx-gears-info
even though the launcher's filename is test.desktop
. You can double click on it to start the script:
For a script like (say, located at /home/muru/start-aria.sh
):
#!/bin/bash
touch /home/cip/Downloads/aria2/session.txt && \
aria2c --enable-rpc --rpc-listen-all \
--save-session=/home/cip/Downloads/aria2/session.txt \
--input-file=/home/cip/Downloads/aria2/session.txt -x16 -s16 -k1M \
--dir=/home/cip/Downloads/aria2
(I split the command into multiple lines for readability) the launcher file would look like (say /home/muru/start-aria.desktop
):
[Desktop Entry]
Type=Application
Terminal=false
Name=Start Aria2
Exec=/home/muru/start-aria.sh
You can set Terminal=false
here as this command probably doesn't need a terminal.
To get the terminal window when using Xfce launchers, tick 'Run in Terminal'.
A second command, that would close aria2, can be added in the same Xfce launcher: pkill aria2c
Also:
(namely 'show last used item' and 'inside button'),
- and adding two specific icons,
the launcher will always display the current status of aria2: running or closed.
Best Answer
Your "shell" or the command line interface is called bash. You can write a bash script which is similar to a batch file. A bash script starts with a She-bang
#!/bin/bash
and is nothing more then a set of commands to run in a sequence to run them. You are not limited to bash command, you can call any binary on the system by using the full path to the binary or script.A master thread on learning/books/terminal/bash/Linux etc Linux Command Line Learning Resources - cortman https://help.ubuntu.com/community/CommandLineResources
My first bash was several commands I was running multiple times in terminal. So I listed history with history command and copied them into text file. First line must be this (no spaces before it and first line):
And after saving you must make it executeable.
Note that it is a good idea to put your scripts in one place, so you can run them without requiring a path. If you create a bin directory in your home ( mkdir ~/bin ) the next time you login, that will automatically be included in your PATH.
Edit : If you want the script to be available to all users, place it in /usr/local/bin and have it owned by root with rx access by others
sudo chown root:root /usr/local/bin/your_script ; sudo chmod 655 /usr/local/bin/your_script
Add the following to the end of .bashrc and save: