Page 9 of 9 FirstFirst ... 789
Results 81 to 88 of 88

Thread: HOWTO: Easily open any file as root via drag & drop

  1. #81
    Join Date
    May 2010
    Location
    Here
    Beans
    1,297
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Wink Re: HOWTO: Easily open any file as root via drag & drop

    Quote Originally Posted by segrewb View Post
    I'm not going to pretend to be a programmer, but would the following work for kde?


    Code:
    #!/bin/sh
    ### openas-root:
    ###   konqueror script for opening the selected files as superuser (uid=0),
    ###   utilizing the appropriate applications.
    
    for uri in $KONQUEROR_SCRIPT_SELECTED_URIS; do
        kde-sudo "kde-open $uri" &
    done
    
    ### end of file.
    Thanks in advance

    Segrewb
    Code:
    #!/bin/bash
    ### openas-root:
    ###   konqueror script for opening the selected files as superuser (uid=0),
    ###   utilizing the appropriate applications.
    
    for uri in $KONQUEROR_SCRIPT_SELECTED_URIS; do
        kdesudo "kde-open $uri" &
    # instead of kde-sudo
    done
    
    ### end of file.

  2. #82
    Join Date
    Nov 2010
    Beans
    19

    Re: HOWTO: Easily open any file as root via drag & drop

    Quote Originally Posted by Nis View Post
    As and you shall receive. Put the following into ~/.gnome2/nautilus-scripts/Open\ as\ root
    Code:
    #!/bin/sh
    gksudo "gnome-open  $NAUTILUS_SCRIPT_SELECTED_URIS"
    Then make it executable with
    Code:
    chmod +x ~/.gnome2/nautilus-scripts/Open\ as\ root
    Noob to Linux - several years late.

    "~/.gnome2/nautilus-scripts" is an empty directory.
    What/where are you wanting with the "/Open\ as\ root" ??

    The chmod I get. The gksudo line I get.

    I'm not seeing how to connect the dots.

    Thanks

  3. #83
    Join Date
    Oct 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: HOWTO: Easily open any file as root via drag & drop

    Quote Originally Posted by Ricalsin View Post
    Noob to Linux - several years late.

    "~/.gnome2/nautilus-scripts" is an empty directory.
    What/where are you wanting with the "/Open\ as\ root" ??

    The chmod I get. The gksudo line I get.

    I'm not seeing how to connect the dots.

    Thanks
    The "/Open\ as\ root" part is just the name of the script file you are supposed to create in that folder. The "\" are to deal with the spaces in "Open as root" I believe. You could also navigate to "~/.gnome2/nautilus-scripts" in Nautilus and Right-Click > Create Document > Empty File and name it "Open as root". Then open in gedit (left click) and past in the following (most recent version):

    Code:
    #!/bin/sh
    ### openas-root:
    ###   nautilus script for opening the selected files as superuser (uid=0),
    ###   utilizing the appropriate applications.
    
    if [ -n "$1" ]; then
    for uri in $NAUTILUS_SCRIPT_SELECTED_URIS; do
            gksu "gnome-open $uri" &
    done
    else
    gksu "nautilus --no-desktop $NAUTILUS_SCRIPT_CURRENT_URI"
    fi
    Make it executable, either by chmod or Right Click > Properties > Permissions and you should be set. When you right click on a file or empty space in a folder, you can select Scripts > Open as root and it should ask for your password and then open the file or the folder respectively.
    David

  4. #84
    Join Date
    Aug 2006
    Beans
    2

    Re: HOWTO: Easily open any file as root via drag & drop

    Quote Originally Posted by Nis View Post
    As and you shall receive. Put the following into ~/.gnome2/nautilus-scripts/Open\ as\ root
    Code:
    #!/bin/sh
    gksudo "gnome-open  $NAUTILUS_SCRIPT_SELECTED_URIS"
    Then make it executable with
    Code:
    chmod +x ~/.gnome2/nautilus-scripts/Open\ as\ root

    As I was trying to create a send-to menu item to send files to gedit, I found your code very useful.

    Here's how I modified it:

    Code:
    #!/bin/sh
    gnome-text-editor $NAUTILUS_SCRIPT_SELECTED_URIS
    saved it in ~/.gnome2/nautilus-scripts, as executable.

    After this, I get a nifty right-click menu titled "Scripts" in Nautilus where I can activate the script after right clicking a file in nautilus. This is very handy when trying to open files that don't open with a text editor by default.

  5. #85
    Join Date
    Jan 2012
    Beans
    6

    Question Re: HOWTO: Easily open any file as root via drag & drop

    Quote Originally Posted by 23meg View Post
    Create a launcher with the following command:

    Code:
    gksudo "gnome-open %u"
    When you drag and drop any file on this launcher (it's useful to put it on the desktop or on a panel), it will be opened as root with its own associated application. This is helpful especially when you're editing config files owned by root, since they will be opened as read only by default with gedit, etc.
    I could really use this utility to open and edit my xorg file but it does not work for me...

    If I run the terminal command in the first post I get multiple error messages:
    "(gksudo:5330): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap",
    Nothing happens after that...

    I'm too much of a newbie on ubuntu 11.1 to know wht this means and how to fix it. Perhaps someone could help?

  6. #86
    Join Date
    Jun 2007
    Beans
    12,906

    Re: HOWTO: Easily open any file as root via drag & drop

    Quote Originally Posted by Jones235 View Post
    I could really use this utility to open and edit my xorg file but it does not work for me...

    If I run the terminal command in the first post I get multiple error messages:
    "(gksudo:5330): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap",
    Nothing happens after that...

    I'm too much of a newbie on ubuntu 11.1 to know wht this means and how to fix it. Perhaps someone could help?
    This thread is old & somewhat not maintained

    For 11.10/12.04 if you want the same deal for a Desktop DnD launcher you could try this
    In terminal

    Code:
    gedit ~/Desktop/openit.desktop
    Paste this in, save, close gedit

    Code:
    #!/usr/bin/env xdg-open
    
    [Desktop Entry]
    Version=1.0
    Type=Application
    Terminal=false
    Exec=gksudo "xdg-open %u"
    Name=Open as Root
    Icon=gnome-panel-launcher
    finish with
    Code:
    chmod u+x ~/Desktop/openit.desktop
    Icon= can be generally be whatever you wish, usually best to full path if not a standard
    Name= can be as desired

    For a unity launcher DnD then you'd need to add an appropiate MimeType= line to the .desktop

  7. #87
    Join Date
    May 2012
    Beans
    3

    Re: HOWTO: Easily open any file as root via drag & drop

    Quote Originally Posted by mc4man View Post
    This thread is old & somewhat not maintained

    For 11.10/12.04 if you want the same deal for a Desktop DnD launcher you could try this
    In terminal

    Code:
    gedit ~/Desktop/openit.desktop
    Paste this in, save, close gedit

    Code:
    #!/usr/bin/env xdg-open
    
    [Desktop Entry]
    Version=1.0
    Type=Application
    Terminal=false
    Exec=gksudo "xdg-open %u"
    Name=Open as Root
    Icon=gnome-panel-launcher
    finish with
    Code:
    chmod u+x ~/Desktop/openit.desktop
    Icon= can be generally be whatever you wish, usually best to full path if not a standard
    Name= can be as desired

    For a unity launcher DnD then you'd need to add an appropiate MimeType= line to the .desktop
    thanks mate sorted me out to

  8. #88
    Join Date
    Jun 2013
    Location
    Somewhere on Earth.
    Beans
    345
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: HOWTO: Easily open any file as root via drag & drop

    Quote Originally Posted by 23meg View Post
    Create a launcher with the following command:

    Code:
    gksudo "gnome-open %u"
    When you drag and drop any file on this launcher (it's useful to put it on the desktop or on a panel), it will be opened as root with its own associated application. This is helpful especially when you're editing config files owned by root, since they will be opened as read only by default with gedit, etc.
    I have a variation that works with newer version of ubuntu (12.04+), xubuntu, and lubuntu.

    For the command put in:

    Code:
    gksu "xdg-open %u"
    for KDE/Kubuntu:

    Code:
    kdesudo "xdg-open %u"
    --Hope it helps!
    I recommend a full ubuntu installation rather than a wubi install. Ask me why.
    To migrate from wubi, click here. (by bcbc)
    Status: Online
    https://help.ubuntu.com/community/UEFI, and Buggy UEFI solution.

Page 9 of 9 FirstFirst ... 789

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
  •