Using Xnest between Mac OS X (Snow Leopard) and Ubuntu 10.10 - osx-snow-leopard

I just installed an Ubuntu 10.10 desktop on a system to do some development work. I would like to run the X server environment on my MacBook instead of keyboard hopping (the graphics system on the Ubuntu box is not so great).
Poking around on the web I uncovered the following command that I can run from a terminal in Mac OS X:
/usr/X11/bin/Xnest -geometry 1280x900 :1 & DISPLAY=:1 ssh -X -Y grog#ubuntusys gnome-session
Note I have ssh set up so authentication happens automatically.
This seems to work great -- the Ubuntu desktop appears on my Mac OS X screen! (It seems to be smart enough to start X11 if it isn't running already). However if I try to open any program, it dies out. So close.
Any suggestions appreciated.
Update: Thanks to the answer below that provides a tutorial link I learned how to do basic X forwarding. You can do this from an X terminal window on the Mac simply like this:
ssh -X -Y username#targetsystem
then you can start X applications that run on the remote system but their windows are on the Mac X server. The issue that I now have is I want to start the gnome desktop session:
gnome-session
but the problem there is that the session takes over the whole Mac desktop. You cannot resize it or move it. Worse, the top part of the windows managed by the window manager end up underneath the menu bar that Mac OS puts up there so you cannot access those controls. I think this is a problem that Xnest was intended to solve, or am I misunderstanding what it is all about?

Use Xnest or Xephyr this way on your Mac OS X:
Xnest :1 -geometry 1280x800 -query 10.0.1.x
Xephyr :1 -screen 1280x1024 -query 192.168.1.x
The only thing you have to do is to enable remote login in your Linux by manually editing /etc/gdm/custom.cfg or using the gdmsetup GUI program. Here CentOS 5 is taken as an example. In Ubuntu things will be a little differrent.
This approach is very different to VNC which is like Microsoft's RDP (screen capture) while XDMCP utilizes the graphic power of your Mac to assist Linux system.
Remember that X11 was specifically designed to be used over network connections rather than on an integral or attached display device. X features network transparency: the machine where an application (the client application, for instance Firefox on Linux) runs can differ from the user's local machine (the display server, that is the X11 on your Mac). This approach allows both 2D and 3D operations to be fully accelerated on the user's local X server.

Depending on which version of OSX you're running, the best bet is probably the native Mac X11 Distribution. It's on the install CD (or if you're like me you got Lion through the App Store, it is available in the Utilities folder by default).
Launching it (Applications > Utilities > X11) brings up a specific X11 x-terminal, which you can use to ssh forward over to your Ubuntu system. That link in Answer 1 is pretty old, I found this one to be more helpful: http://www.craigryder.com/linux-ubuntudebetc/x11-forwarding-and-ssh-for-remote-linux-ubuntu-desktop/
The only extra option I use is the -C flag to enable compression when I run my ssh command. Please note that you do NOT have to run a full gnome-session to use the X features - you can simply run the program you want (ie, $ gedit&). This gets you out of using the whole desktop, but it is kind of weird since your Mac desktop still gets blacked out. You can find more on this technique # http://ubuntuforums.org/showthread.php?t=1373823&page=2
I also noticed that on 10.10 Ubuntu, my system showed the same odd UI control behaviors you mention, but those disappeared when I upgraded my distribution to Ubuntu 11. I didn't really go to deep to see if simply upgrading X to the latest version on the 10.10 Ubuntu system would have fixed that issue, but I can confirm that it does not appear in 11.
One final note, this still seems to force the Mac X11 server into Full-Screen mode, but if you press COMMAND-ALT-A it immediately takes you out of the X desktop and back into your Lion desktop, which allows me to have both running and still be productive when I need to jump out of my Ubuntu system. I seem to be able to always access all the title and menu bars for all of my X apps just as though I was sitting at the Ubuntu desktop.
One caveat - I'm running the above to connect to a VMWare Workstation VM running Ubuntu (with 3D acceleration enabled) on my workstation - connecting to actual hardware may (though I can't fathom how) result in slightly different behavior.
Hope this helped!

Is VNC not working for you?
Or regular X forwarding over SSH.

Related

How to synchronize code files on windows with WSL/linux?

Basically I have some C/C++ code that I need to build and debug on a Linux machine. Unfortunately, my windows laptop doesn't have enough free hard space to install some Linux dist nor does it have enough free RAM to comfortably run VM.
Until now, I dealt with it rather comfortably using WSL, but the scale was rather small. It was easy to edit and debug 2-3 .c files through CLI and gdb, but it became really annoying on a large scale projects.
I want something simple as "edit code in windows IDE [X], compile it on remote Linux/WSL (the project uses Makefiles), and preferably debug it via gdb".
VS has something close to what I want, but it can't deal with existing Linux projects. It needs to create a new configuration which is alien to the project's Makefile.
I know this question is a bit old, but I think the solution is to make a symlink between your WSL folder and the Window's folder. This is how I handled it for a Ubuntu-20.04 WSL:
Access PowerShell in Administrator mode
Type cmd.exe in the PowerShell
Once cmd.exe is opened, type mklink /d C:\<path_to_your_Windows_folder> \\wsl$\Ubuntu-20.04\home\<your_user>\<path_to_your_WSL_folder>
EDIT
This was tested under Windows 10 Version 2004 with WSL2
I'm unsure about C and C++ but it sounds like this is exactly the same as how i work in node and javascript every day.
I checkout my code using git inside WSL to a location like /mnt/c/code/myproject. Then using sublime/VS code/webstorm i edit the files in windows in the location c:\code\myproject this works really well and have been doing this every day for over a year.
Things to be aware of are that you need to ensure that your editor of choice saves files with linux line endings and that all command line operations are done inside WSL.
Please see this article to see the differences between windows and linux files and how this works inside the WSL.
I want something simple as "edit code in windows IDE , compile it on remote linux/WSL
You will have something as simple as that.
Only with Windows 19.03 though:
See "Updated WSL in Windows 10 version 1903 lets you access Linux files from Windows"
Microsoft's Craig Loewen says:
In the past, creating and changing Linux files from Windows resulted in losing files or corrupting data. Making this possible has been a highly requested and long anticipated feature. We're proud to announce you can now easily access all the files in your Linux distros from Windows.
So how does this work? He goes on to explain:
To put it briefly: a 9P protocol file server facilitates file related requests, with Windows acting as the client.
We've modified the WSL init daemon to include a 9P server. This server contains protocols that support Linux metadata, including permissions.
There is a Windows service and driver that acts as the client and talks to the 9P server (which is running inside of a WSL instance).
Client and server communicate over AF_UNIX sockets, since WSL allows interop between a Windows application and a Linux application using AF_UNIX as described in this post.
Warning:
The old rules still apply, you should NOT access your Linux files inside of the AppData folder!
If you try to access your Linux files through your AppData folder, you are bypassing using the 9P server, which means that you will not have access to your Linux files, and you could possibly corrupt your Linux distro.

Starting a graphical application using sfml on Raspberry Pi boot

I would like to make a Graphical interface for a home-made program using SFML on Raspberry Pi2. I am using Raspbian. I recompiled the graphical lib
It works fine unsing startx first, then using my application, which wors perfectly fine.
But I can't figure if it is possible or how to launch my application directly after boot without launching startx (just to optimise the cpu of the Raspberry).
Starting my program direcly after boot, I get the following error:
Failed to open X11 display: make sure the DISPLAY environnement variable is set correctly.
Aborted.
I already tested the classic export DISPLAY=:0.0 but without sucess.
I interested myself in x and xinit, but I am not sure that would even do it.
Where should I start looking? I don't need a complete solution, even a hint or an idea would be nice!
I checked to see if it was possible to open a graphical app without the X desktop environment and as that answer states, with Firefox at least, you need the X server which SFML also probably needs in order to create a window.
The answer states:
Basically something like:
$ X
Then you just start Firefox in this X server:
$ DISPLAY=:0 firefox
You can switch from the X server and the framebuffer by using
CTRL+ALT+F1 and CTRL+ALT+F7.
You could try that and see if it helps.
Also, still searching, I found a forum post on the sfml website about what you're trying to accomplish stating somewhere:
SFML requires OpenGL, so as far as I know you need at least X running,
but you probably don't need gnome, KDE or a similar Desktop
Environment on top.
The forum guy asking for help seems to have managed to get X11 and a SFML basic render window to work on Ubuntu server after someone posted a link to xinitrc. I guess, that's the route to go from here.

What is blocking driver installation in Windows?

I've written a C program in Windows that uses some precompiled files from WinDivert. My program uses a .dll from WinDivert and some of the functions in the .dll install the WinDivert.sys driver. There are also a few more files from WinDivert that are a part of this (a .lib, a .inf, and another .dll).
The problem is that on one of my computers (Windows 8.1 64 bit), everything works perfectly. But, when I try to use the program on my laptop (Windows 8.1 64), my friend's laptop (Windows 7 64), or another Windows 7 64 desktop, something blocks the installation of the driver. I'm unsure what is blocking it or how to stop it from being blocked because on all computers:
+I'm running on an admin profile
+Running the program in admin command prompt
+Tried disabling firewall, anti virus, etc (although it runs fine with these on for the computer that works)
+As far as I can tell, all my security settings are the same
+Note: the driver does have a valid signature.
Why does the driver install perfectly on one computer, but not on the other three? What could be issue?
The main causes for 1275 errors are documented on the WinDivert FAQ. However, there may be other causes that I'm unaware of (perhaps some experts out there can help?)
Another thing to try is the following commands:
sc stop WinDivert1.1
sc delete WinDivert1.1

TCP/IP Programming in C

I have an exam on tomorrow on TCP/IP programming. Following is one of the previous question on this paper.
Write and run a client and a server program. Using C language in UNIX, with the
following specifications :
• A TCP client program will send a range of number (e.g. 1 to 10) to the server.
• TCP server accept the number range from client and send back the sum of the
number range. Client will print the result.
I dont know how to setup the compiler and other settings to run this tcp ip programs. When I search online, I got two different programs, one for Client and another For server. Some please tell me how can i run these programs to get desired output. What kind of compiler should I install on my system.( I am using windows 7) ??
Since the assignment requires your code to work on a Unix system, you first need to install one. Follow these simple steps to install a virtual Unix environment on top of your existing Windows installation.
Download and install VirtualBox for Windows.
Download & unpack this Ubuntu 12.10 disc image (NOTE: Requires 7-Zip).
Launch VirtualBox and create a new Virtual Machine (name it Ubuntu).
In the "Virtual Hard Disk" settings, select "Use existing hard disk" and select the image file you just downloaded (NOTE: It's filename should end in ".vdi").
Run your new Virtual Machine. You should see the Ubuntu splash screen.
Login with username ubuntu and password reverse (NOTE: Case Sensitive!).
Open up Terminal and type sudo apt-get install build-essential (NOTE: when Terminal prompts you for a password, use reverse).
You should (with hope) have everything you need for your assignment. For more information on network programming, consult Beej's Guide to Network Programming -- Using Internet Sockets.
You need to open two different terminals on your system.
In the first terminal compile and run the server.c program.(make sure either you listen to all ips or your host ip(atleast).
while this is running.(it will wait for a request from your client program)
Run the client program in the other terminal.
Hope this solves the problem!
For details on how to create and run a file in unix refer http://www.wikihow.com/Compile-a-C-Program-Using-the-GNU-Compiler-%28GCC%29
P.S: you can do the same in win7 if iam not wrong only that terminal here in called command prompt!
Post the results if possible!
Download a thing called VMWare player. And look for a Ubuntu image that you can load with the VMWare player. That way, you will have a little Linux virtual machine that you can run inside or along with Windows 7. You can use the compiler GCC in your Ubuntu or whatever other Linux virtual machine. And get lots of coffee. Blargle is correct, but I think my suggestion is a little better, because you end up having a fairly complete Unix type environment to develop in. Blargle's way put Unix tools on top of Windows, which I find to be kind of clunky.
I learnt socket programming from this site. He has given everything in detail . Download an Vmware workstation and load up ubuntu . Understand the programs they are pretty much straight forward .
Maybe you can try to look at Network Socket on the web. You can easily find a lot of good tutorial that can answer your question.
You can use the compiler you want on your system, depending on what are you using now.

Launch OpenGL app straight from a windowless Linux Terminal

How exactly would one go about getting an OpenGL app to run fullscreen straight from the terminal (Ubuntu Server 9.04)? I've developed an application for visual diagnostics on my server, but, I'm not totally sure the best way to get it to run in a windowless environment.
Ideally, I would run my program:
./visualdiagnostics
and have that launch the OpenGL app. Then, via a simple Ctrl+X key binding, I'll kill the app and go back to the terminal.
Do I need to install X11 and then somehow launch it from within the program? What would be the best way to detect if it's already running and, start/stop it if necessary?
And FYI: No, I'm not trying to get this to run over Putty or anything... I have a monitor hooked straight up to the server. The server has proper video drivers installed.
There are several parts to your task. Keep in mind that some of this can be very distro-specific; but since you said Ubuntu we'll talk Ubuntu!
Also you tagged this question C however I am starting off with a common Linux pattern: a native application with a Bash shell script wrapper. Perhaps once you get things working well you might fold that functionality into C if you have to.
Detecting whether X is running
Being root can help a lot. Some things that work.
pgrep Xorg
Check whether /var/lib/gdm/:0.Xauth exists. This will be there even if nobody has logged in but GDM is running.
ls -l /home/*/.Xauthority (Even if you're not root you can at least confirm whether you are running X.
Piggybacking an existing X session
You did not specifically mention it but if you are root at the console, or if you want to run the app as the same user who is already logged in, it's pretty easy.
You have to get the DISPLAY and XAUTHORITY environment variables right, and once you do you can use the existing X display.
For DISPLAY you might just assume :0 or you could find an existing X program (x-session-manager is the GNOME standard) and read its environment from /proc/PID/environ. Variables are in key=value format delimited by a null byte. For example, if its PID is 12345:
cat /proc/12345/environ \
| ruby -ne 'puts $_.split("\0").select {|e| e.starts_with? "DISPLAY=" }'
For XAUTHORITY you could get it the same way. Or if you prefer guessing, it's almost always /home/whoever/.Xauthority
Once you have those two variables, running X code is easy, for example:
env DISPLAY=:0 XAUTHORITY=/home/brian/.Xauthority ./visualdiagnostics
Stopping X
This one is easy if you're root: /etc/init.d/gdm stop. killall Xorg will work too.
If you are a user, kill your own Xorg or x-session-manager process. (I'd welcome input from others for the canonical way to do this. Maybe some dbus-send message?)
Starting X
I would recommend xinit whose goal in life is to fire X and run exactly one program.
For example: xinit ./visualdiagnostics
You can also tell xinit what resolution to run X at which may or may not be important to you. (This becomes important in the full-screen section below.)
The problem with this is you will have no window manager— no maximize and minimize buttons. It's not just cosmetic. Usually an app is useless because a popup window cannot be moved or you cannot focus on the right input field. However if you have a special app it could be sufficient (see full-screen below).
The next step would be my answer to everything: another shell script wrapper! Something simple that starts the window manager and then becomes your program should work.
#!/bin/bash
#
# Start visualdiagnostics once xinit calls me.
/usr/bin/metacity& # Or ratpoison, or fluxbox, or compiz, etc.
exec ./visualdiagnostics
It's important to exec (become) the main program because once that first program exits, X will shut down.
Running fullscreen
I am not 100% certain on this. Some ideas:
Try the standard X -geometry parameters to set 0,0 as the upper-left corner and +x+y for your horizontal and vertical size. How do you know the size? Either you hard-coded it when you launched xinit or you could ask the X server. xwininfo -root will tell you and there is an xlib API call that would do that too—check the xwininfo source I guess.
Your app itself can request maximization and/or resizing to fill the screen. I'm not familiar but it is definitely in the X API.
Some of the more configurable window managers can be pre-configured to run you maximized already. This is probably what I personally would check first. Your wrapper script could create a $HOME/.fluxboxrc just by echoing some hard-coded configs > the file.
Summary
The others are right. X is not strictly necessary sine OpenGL can run against a framebuffer. However considering how ubiquitous X is and how much work has gone into automating it for distributions, I would probably invest my effort into the X route as it might be easier long-term even though it's a little convoluted.
(By the way, I sincerely hope when you say "terminal" you mean you are at the text console, not gnome-terminal that would be awful! :)
Well I am clearly not sure my answer might help you out.
Long ago when I was student, I manage to do so (launching an openGL app from a terminal only linux installation) by installing frame buffer. As long as I remember I needed to recompile my kernel (as framebuffer was/is a kernel module).
This was maybe 5 years ago on a debian distrib, and I don't know how does it work now for up-to-date debian distrib as Ubuntu. Maybe framebuffer is compiled statically in the binary kernel provided by default with Ubuntu. May be not. Maybe framebuffer is irrelevant now... Or I may be totally wrong and not remembering every details of my own adventure 5 years ago now ..
Have a look on Google ! ;-)
Hope it will help...
**
Update:
**
What is frame buffer ?
How to install it? Here or there
As yves pointed out, you can avoid running the X server if you use the framebuffer. Actually, the framebuffer modules are often yet available (for example, they are used to have the tux logo during the kernel start or a text terminal with fancy images in the background), this anyway depends on the distribution and the settings you are using.
The kernel side is quite primitive so I'd suggest to use some higher level library such as DirectFB. The framebuffer is usable without problems but don't expect the same maturity level than a full blown X server.
Are you trying to have the video be on the monitor connected directly to the computer?
Is X running on the server?
If X is running, you can do
export DISPLAY=:0.0
which tells X apps to connect to the X server at localhost, rather than where' you're coming from.
If you're actually logging in locally (from a direct terminal) ... yes, you need X installed and running.

Resources