0

OS: Linux Mint 18.x Cinnamon 64-bit

Say, I would like to run nemo, the default file manager in Cinnamon, with normal sudo, and in current working directory:

sudo nemo .

Problems:

  1. It shows different minor errors I don't care of, such as:

    (nemo:21081): Gtk-WARNING **: Failed to register client: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files
    
  2. After I close it, it takes exactly 30 seconds for the gnome-terminal to give back control to me.


Goal is to define a bash alias or function, which would not have these two, or any other negative aspects.

Additionally:

  1. I would like it to give control back immediately, so that I could work with Nemo and Terminal independently.

  2. I would like to be able to run it as it is for working directory or give it some directory as an argument.

0

From my standpoint, the most effective method is to:

  1. Use a Subshell, i.e. ( and ) at the beginning and the end of actual commands.

  2. Background the command with & at the end.

  3. Because we are running it as a background process, normal sudo would not do the trick, so we have to use the its graphical equivalent, gksudo.

  4. IMHO this is not possible with alias, we need to define a function instead, because we need to check if the argument has been given and act accordingly.

  5. The redirection of any output to the black hole (> /dev/null 2>&1) is a just good habit of mine. Not actually doing anything in such case as this one.

The function below fulfills my expectations, feel free to add your solutions.


Working solution on Linux Mint 18.x

function sunemo {
    if [ -z "$1" ]
    then
        (gksudo nemo .    > /dev/null 2>&1 &)
    else
        (gksudo nemo "$1" > /dev/null 2>&1 &)
    fi
}

As you probably noticed, in Linux Mint 19.x gksudo has been removed.

Working solution on Linux Mint 19.x

function sunemo {
    if [ -z "$1" ]
    then
        (nemo "admin://$PWD" > /dev/null 2>&1 &)
    else
        (nemo "admin://$1"   > /dev/null 2>&1 &)
    fi
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.