Results 1 to 4 of 4

Thread: Help with my Nautilus scripting?

  1. #1
    Join Date
    Mar 2009
    Location
    London, UK
    Beans
    128
    Distro
    Ubuntu Jaunty Jackalope (testing)

    Help with my Nautilus scripting?

    Hey, I'm trying to make a Nautilus script that plays an unfinished .rar file containing a video file.

    This command does everything I need - it's essentially perfect.

    Code:
    unrar p -inul myarchive.rar | mplayer -cache 2048 -
    I'm just a bit lost on how to convert it to a Nautilus script. So far I've got this far:

    Code:
    #!/bin/sh
    unrar p -inul $NAUTILUS_SCRIPT_SELECTED_URIS | mplayer -cache 2048 -
    ...however this doesn't do anything when I add it as a Nautilus script and run a .rar file through it.

    I'm on Ubuntu 9.10 64-bit. Any help would be much appreciated

  2. #2
    Join Date
    Jun 2008
    Location
    California
    Beans
    2,271
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Help with my Nautilus scripting?

    I don't have unrar or mplayer installed to test your command, but $NAUTILUS_SCRIPT_SELECTED_URIS won't work. Instead, you should use $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS, which returns the name of the selected file including its path, or $1, which returns the name of the selected file without its path.

    For example, if the selected file is located in my home directory and is named file.txt, then

    $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS returns /home/kaibob/file.txt

    $NAUTILUS_SCRIPT_SELECTED_URIS returns file:///home/kaibob/file.txt

    $1 returns file.txt
    Last edited by kaibob; February 15th, 2010 at 12:19 AM. Reason: Forgot to quote

  3. #3
    Join Date
    Mar 2009
    Location
    London, UK
    Beans
    128
    Distro
    Ubuntu Jaunty Jackalope (testing)

    Re: Help with my Nautilus scripting?

    Quote Originally Posted by kaibob View Post
    I don't have unrar or mplayer installed to test your command, but $NAUTILUS_SCRIPT_SELECTED_URIS won't work. Instead, you should use $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS, which returns the name of the selected file including its path, or $1, which returns the name of the selected file without its path.

    For example, if the selected file is located in my home directory and is named file.txt, then

    $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS returns /home/kaibob/file.txt

    $NAUTILUS_SCRIPT_SELECTED_URIS returns file:///home/kaibob/file.txt

    $1 returns file.txt
    Thanks for your reply!

    Unfortunately I can't get any of that to work. I've made the script simply:
    Code:
    #!/bin/sh
    $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS > ~/test-01.txt
    ... and test-01.txt is created, but it's blank. If I make it like this:

    Code:
    #!/bin/sh
    ls . > ~/test-01.txt
    ...then it functions as expected (returning a file list). I just can't get those naming functions you described to work properly - I tried all three, and they all return a blank file.

    Thanks again

    EDIT: this seems to work!
    Code:
    #!/bin/sh
    unrar p -inul "$@" | mplayer -cache 2048 -
    Last edited by Xero Xenith; February 15th, 2010 at 01:17 AM.

  4. #4
    Join Date
    Jun 2008
    Location
    California
    Beans
    2,271
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Help with my Nautilus scripting?

    Quote Originally Posted by Xero Xenith View Post
    Thanks for your reply!

    Unfortunately I can't get any of that to work. I've made the script simply:
    Code:
    #!/bin/sh
    $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS > ~/test-01.txt
    ... and test-01.txt is created, but it's blank. If I make it like this:

    Code:
    #!/bin/sh
    ls . > ~/test-01.txt
    ...then it functions as expected (returning a file list). I just can't get those naming functions you described to work properly - I tried all three, and they all return a blank file.

    Thanks again

    EDIT: this seems to work!
    Code:
    #!/bin/sh
    unrar p -inul "$@" | mplayer -cache 2048 -
    You have to use the echo command--the following will work:

    Code:
    #!/bin/sh
    echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" > ~/test-01.txt
    "$1" should return the same thing as "$@" if you only select one file in Nautilus. I don't know why that didn't work for you. Anyways, glad you got things working.
    Last edited by kaibob; February 15th, 2010 at 01:53 AM.

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
  •