Page 1 of 2

open as root?

Posted: Sun Oct 25, 2009 4:04 pm
by miks
How do I set up a menu entry to open pcmanfm as root?

Re: open as root?

Posted: Sun Oct 25, 2009 7:19 pm
by Neal
Open /usr/share/applications/pcmanfm.desktop as root. Edit it to change this line:
Exec=pcmanfm %F --no-desktop
so that it reads like this:
Exec=gksu -l /usr/bin/pcmanfm &
Save the file as pcmanfm superuser mode or your name of choice.
:!: :!: Use "Save As" not "Save" or your entry for PCManFM will be lost. :!: :!:

Re: open as root?

Posted: Sun Oct 25, 2009 10:16 pm
by miks
Thanks Neal. I have done as you say and also changed "name" to "Root File Manager" before saving the file as pcmanfm-root, and it now shows in the menu as Root File Manager. Excellent so far! When I launch it, I get the window asking for my root password, which is accepted, but pcmanfm does not appear, although HTOP shows that it is running. This is on a vanilla install of Debian Lenny. Any ideas?

EDIT: I get the same result from the root terminal.

Re: open as root?

Posted: Mon Oct 26, 2009 3:33 am
by Neal
Try this:
Open leafpad or other text editor and copy the following into it -->

Code: Select all

#!/bin/sh

#-------------------------------------------------------
# Start program

export launchasroot='
<window title="Root Launcher" icon="/usr/share/icons/gnome/32x32/apps/file-manager.png" window-position="2"> 
<vbox> 
  <notebook label="Launch as Root ">
  <vbox>
  <frame>
				<hbox>
				     <button>
						<input file>"/usr/share/icons/file_tools_section.png"</input>
						<action>gksu -l /usr/bin/pcmanfm &</action>
					</button>
					<text use-markup="true" width-chars="17">
						<label>"File Manager Superuser Mode"</label>
					</text>
				</hbox>	
  </vbox>
</window>
'

gtkdialog --program=launchasroot
unset launchasroot

You can change the icons to others, if you choose. Save the file as launchasroot. There should be no need for an extension, but if there is, use .sh. Copy the file to /usr/bin (Or wherever the programs for debian are installed by default) and set its permissions. --> right click on the file, choose Properties and click on the Permissions tab. Enter into Owner and Group fields root. Then set Owner to read write and execute, Group to read and execute and Others to read and execute (this is optional).

Next create a .desktop file for this script.
[Desktop Entry]
Name=Launch as Root
Exec=/usr/bin/launchasroot
Comment=Root Launcher
Icon=file-manager.png
Terminal=false
Type=Application
StartupNotify=true
Categories=Settings;GTK;X-MandrivaLinux-System-Configuration; (change this to match )
OnlyShowIn=LXDE;
Set its permissions. You should now have a menu entry for this launcher.
You will need to install gtkdialog, if you do not have it already.

Re: open as root?

Posted: Mon Oct 26, 2009 10:45 am
by miks
OK, thanks Neal, I will try that but just one question, I do not know what to put in this line:

Code: Select all

Categories=Settings;GTK;X-MandrivaLinux-System-Configuration; (change this to match )

Re: open as root?

Posted: Mon Oct 26, 2009 2:02 pm
by Neal
You're welcome. Look at your file for pcmanfm. What is on that line? Copy it over.

Re: open as root?

Posted: Mon Oct 26, 2009 4:16 pm
by FreelY
Hi Neal

Thank you but it doesn't work for me, I have the same answer: File doesn't exist

1-Install "gtkdialog"
2- In /usr/bin create a file "launchasroot" (tested with launchasroot.sh) with your script, and set permissions for Owner and Group
3- In /home/freely create a .desktop file with the second script, edit "Categories=" for my computer and set permissions for Owner and Group

Any idea?

Re: open as root?

Posted: Mon Oct 26, 2009 4:25 pm
by Neal
FreelY wrote:Hi Neal

3- In /home/freely create a .desktop file with the second script, edit "Categories=" for my computer and set permissions for Owner and Group

Any idea?
This is your problem. The .desktop file should not be in your /home directory. It should be in /usr/share/applications with your other .desktop files. Be sure to check its permissions - right click > properties > permissions tab. Compare to other .desktop files to be sure they're set correctly.

Re: open as root?

Posted: Mon Oct 26, 2009 4:56 pm
by FreelY
Again the same answer

But now that's good! with "Exec=gksu /usr/bin/pcmanfm" and not "Exec=gksu -l /usr/bin/pcmanfm & " in my file pcmanfm_root.desktop

thanks ;)

Re: open as root?

Posted: Wed Oct 28, 2009 12:15 am
by miks
Neal wrote:Try this:
Open leafpad or other text editor and copy the following into it -->

Code: Select all

#!/bin/sh

#-------------------------------------------------------
# Start program

export launchasroot='
<window title="Root Launcher" icon="/usr/share/icons/gnome/32x32/apps/file-manager.png" window-position="2"> 
<vbox> 
  <notebook label="Launch as Root ">
  <vbox>
  <frame>
				<hbox>
				     <button>
						<input file>"/usr/share/icons/file_tools_section.png"</input>
						<action>gksu -l /usr/bin/pcmanfm &</action>
					</button>
					<text use-markup="true" width-chars="17">
						<label>"File Manager Superuser Mode"</label>
					</text>
				</hbox>	
  </vbox>
</window>
'

gtkdialog --program=launchasroot
unset launchasroot

You can change the icons to others, if you choose. Save the file as launchasroot. There should be no need for an extension, but if there is, use .sh. Copy the file to /usr/bin (Or wherever the programs for debian are installed by default) and set its permissions. --> right click on the file, choose Properties and click on the Permissions tab. Enter into Owner and Group fields root. Then set Owner to read write and execute, Group to read and execute and Others to read and execute (this is optional).

Next create a .desktop file for this script.
[Desktop Entry]
Name=Launch as Root
Exec=/usr/bin/launchasroot
Comment=Root Launcher
Icon=file-manager.png
Terminal=false
Type=Application
StartupNotify=true
Categories=Settings;GTK;X-MandrivaLinux-System-Configuration; (change this to match )
OnlyShowIn=LXDE;
Set its permissions. You should now have a menu entry for this launcher.
You will need to install gtkdialog, if you do not have it already.
Hi Neal, not got this working yet. The program does not execute. In terminal, I get:

Code: Select all

mike@acer-7520:~$ launchasroot

** ERROR **: gtkdialog: Error in line 16, near token '</vbox>': syntax error

aborting...
/usr/bin/launchasroot: line 25:  3500 Aborted                 gtkdialog --program=launchasroot
Also, I do not get a menu entry.