0

I want to create a file which will execute a code, for example:

sleep 60s; dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

-so that double-clicking on it will be equal to open the terminal and write it in there.

How do I do it?
(In windows, I think, it is a .bat file)

Tzahi Leh
  • 261
  • 3
  • 6
  • 17
  • 2
    Possible duplicate of [How do I run executable scripts in Nautilus?](http://askubuntu.com/q/286621/338915) – hg8 Dec 17 '15 at 09:24

1 Answers1

5

In Linux, we use bash (.sh) scripts.

To make a a bash script execute on double click you need to make it executable, and add the line #!/bin/bash to the start.

The file should look like this:

#!/bin/bash
sleep 60s; dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

Make it executable with:

chmod +x nameofscript.sh

You'll also want to follow this guide.

TellMeWhy
  • 17,124
  • 39
  • 95
  • 141