1

Sorry for my probably very naive question.

What I mean is: how to create an executable script/bash file that would run more complex commands, commands which must normally be put in a terminal?

Specifically, I am referring to the following commands:

  • Learned about it from here:
DRI_PRIME=1 glxgears -info

That would start glxgears and put to work the ATI discrete card. Then I can monitor its temperature etc. But when I run it from terminal, I get this:

enter image description here

While when I run it with the script

#!/bin/bash

DRI_PRIME=1 glxgears -info

only the gears window is visible, not the other one with text.

I would like to be able to use a bash file and have the first result, and then run the file from a launcher.


Considering this page on aria2 and webgui-aria2, aria2 is started in that context by running in terminal a long command:

touch /path/to/download/folder/session.txt && aria2c --enable-rpc --rpc-listen-all --save-session=/path/to/download/folder/session.txt --input-file=/path/to/download/folder/session.txt -x16 -s16 -k1M --dir=/path/to/download/folder

How to run that with a script (that I would then execute from a launcher) and have the same result, the same info?

A script like so (adapted to my download folder)

#!/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

gives nothing, while thhe programs starts.

(I'm in Xubuntu 14.04).

7
  • Regarding the second part, see askubuntu.com/q/141229/158442.
    – muru
    Oct 15, 2014 at 22:29
  • How did you run the glxgears script? You could create a launcher for that too, and set Terminal=true in it.
    – muru
    Oct 15, 2014 at 22:33
  • @muru - i think that question is about how to put already existing scripts in launchers, and that i know already. while i ask is how to put long commands in scripts: commands that i can run in terminal but i do not know how to add in a bash file
    – user47206
    Oct 15, 2014 at 22:34
  • What does the length have to do with anything? You'd put that in a script the same way you have done with the glxgears script.
    – muru
    Oct 15, 2014 at 22:35
  • 1
    Sorry I was unclear. You add Terminal=true in a .desktop file (the launcher you create for the script).
    – muru
    Oct 15, 2014 at 22:38

2 Answers 2

2

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: enter image description here

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: enter image description here


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

enter image description here

A second command, that would close aria2, can be added in the same Xfce launcher: pkill aria2c

Also:

  • by adding them into a single launcher,

  • setting advanced properties like in the image below

enter image description here

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

enter image description here

2
  • @cipricus Thanks for the edits. Which Launcher editor is that?
    – muru
    Oct 15, 2014 at 23:47
  • 1
    it's the Xfce panel launcher. it allows multiple 'shortcuts' into one launcher, which is handy for many purposes: creating category launcher (like multimedia or internet browsers), or different options for the same application like in the situation above (also: multiple chromium or firefox accounts into one launcher etc)
    – user47206
    Oct 16, 2014 at 10:17
1

Quick answer, try this:

#!/bin/bash
DRI_PRIME=1
xfce4-terminal --window -H -x glxgears -info

Don't know if all the switches are needed, but it worked.

1
  • @muru - that works. the longer one can be used in the same way, aria2 starts, but with a different window than when run in terminal. i will edit the question with detail. maybe i will get farther progress
    – user47206
    Oct 15, 2014 at 22:56

You must log in to answer this question.