7

I use VirtualBox for using Ubuntu 15.04, and I run at guest

$ sudo VBoxClient --clipboard

every time I want to copy something from host to guest. Every time I mean once per bootup.

How I can make the command run with sudo at guest boot time?

I have already set Shared Clipboard to Bidirectional value at VirtualBox Settings.

GeoMint
  • 785
  • 1
  • 8
  • 29
  • 1
    When you say "boot time" do you mean host boot or guest boot? – Seth Nov 01 '15 at 16:29
  • i mean guest boot – GeoMint Nov 01 '15 at 16:30
  • @GeoMint Maybe not what you are looking for but why don't you turn on the "share clipboard option" in your virtualBox parameters? – Prolix Nov 01 '15 at 16:30
  • I have already set share clipboard option to Bidirectional – GeoMint Nov 01 '15 at 16:33
  • You run that command on the host in order to launch the VBox client and boot your VM, right? Why not just make VBoxClient an alias to sudo VBoxClient --clipboard? – terdon Nov 01 '15 at 16:40
  • My host operating system is windows 8.1 – GeoMint Nov 01 '15 at 16:44
  • This could help. – Prolix Nov 01 '15 at 16:45
  • can you tell me how to do this? i am not into the symlinks. – GeoMint Nov 01 '15 at 16:51
  • All the command are in the answer from the link: Once the script is in /etc/init.d with the correct permissions chmod 755 Myscript. You go to the directory of the correct runlevel: e.g. /etc/rc2.d Then you do a ls find the last script in this level (highest number after S). And then you create the symlink using ln -s /etc/init.d/Myscript /etc/rc2.d/SHighestNumberMyscript. Just let me know if something does not work or is not clear. – Prolix Nov 01 '15 at 17:05
  • @Prolix that doesn't work. The command needs to be run after the GUI has been loaded since it applies to the X clipboard. It is best to run this after login and not at boot. – terdon Nov 01 '15 at 18:04
  • @terdon Good catch! I got mislead by the "guest boot time" part of the question! – Prolix Nov 02 '15 at 09:36

1 Answers1

4

A simple solution would be to give your user the right to run the command without entering a password and then adding it to the list of startup programs. First, run sudo visudo and add this line to the file (change geomint to your actual user name):

geomint ALL=NOPASSWD:/usr/bin/VBoxClient --clipboard

Then, use the tools provided by your desktop environment to add the command to your startup applications. Instructions for Unity can be found here.

Alternatively, do it manually. Create a file called ~/.config/autostart/VboxClipbvoard.desktop with the following contents:

[Desktop Entry]
Type=Application
Exec=sudo VBoxClient --clipboard
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=VBox clipboard
Name=VBox clipboard
Comment[en_US]=
Comment=

Now reboot, and it should work as expected.

terdon
  • 100,812