Results 1 to 3 of 3

Thread: Bash sleep/execution question

  1. #1
    Join Date
    Jul 2008
    Beans
    141
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Bash sleep/execution question

    I like to listen to music when I go to bed, so I made a very simple script to kill audacious after 30 minutes.

    Code:
    #!/bin/bash
    sleep 1800
    killall audacious
    Is there a way to specify how long I want the sleep duration to be upon executing the script if I want it to be longer or shorter than 30 minutes? I know very little about scripting, so I don't know if there's a simple way to just have a dialog box pop up where I can type in the length of time I want, click ok, and have the script run.

    Any help would be greatly appreciated.

  2. #2
    Join Date
    Nov 2007
    Beans
    465

    Re: Bash sleep/execution question

    I edited and commented on your script as to what I edited in does:
    Code:
    #!/bin/bash
    ## This prompt will allow you to enter the amount of time you wish for the script to sleep
    echo "How long do you wish for the script to sleep:"
    ## This reads the input as a variable, which will be used to set the amount of time to sleep
    read sleep
    ## The variable is read here
    sleep $sleep
    killall audacious
    You must run this from a terminal, though, as creating a GUI prompt would be getting beyond what Bash can do.

  3. #3
    Join Date
    Jul 2008
    Beans
    141
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Bash sleep/execution question

    Thanks! That's very helpful. Is there a way to have the script run in the terminal by double clicking it rather than opening a terminal and typing in the path of the script? I tried having it open with gnome-terminal, but that didn't work.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •