4

I have written a simple Shell script named decBright.sh that decreases my screen brightness by a bit every time I run it. However, I do not want to open the terminal and execute bash decBright.sh every single time.

Instead, I want to create some kind of executable file that I can place on my Desktop, which will run my script when it is double-clicked. One answer I found here on the askUbuntu forums did not work for me.

Is there some other way to do it?

I am using Ubuntu 14.04 (Trusty Tahr)

2
  • 1
    also you may be interested bind to the script a hotkey, e.g. with every press will decrease the brightness... read this Commented Oct 5, 2014 at 15:14
  • Why did the suggested mechanism from the Ubuntu forums not work? What desktop are you running? Commented Oct 6, 2014 at 13:53

1 Answer 1

2

An executable in linux is a file with the executable bit on. Thus you simply modify it with chmod:

chmod +x decBright.sh

Then you can run it with:

./decbright.sh

You can also run it by double-clicking in many graphical linux distributions.

You also better provide a "Shebang": the first line of your script should specify the "interpreter":

#!/bin/bash

Or any other interpreter (at the first line of your file).

Sign up to request clarification or add additional context in comments.

4 Comments

I gave the execute permissions using chmod and also provided the shebang on the first line as you said. Yet, when I double click it, it opens up with gedit :/
Please avoid the bad habit of double-clicking (i.e. only using the mouse and the GUI)! The best way to run any script or any executable is thru a command line in a terminal. And the behavior with double-clicking is probably window manager specific.
@AkshayDamle: can you write the output of ls -l on your question.
@BasileStarynkevitch: True, as a programmer,always use the terminal. But from a user's perspective...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.