Starting lightdm in wsl2 in VcXsrv - windows-subsystem-for-linux

I was able to start the lightdm and manager and greeter in a wsl2 debian in VcXsrv setting. When first starting the debian bash terminal and first starting the VcXsrv instance it appears to work fine. I can login at the greeter and be taken to gnome shell desktop.
/etc/init.d/dbus start
/etc/init.d/lightdm start
However, when I logout, gnome shell doesn't actually quit and the greeter appears as overlayed on top of the gnome shell... it appears gnome shell does not actually quit (the processes are still alive checking with ps).
The only way to start fresh is to exit the VcXsrv instance AND stop the LxssManager instance and restart it.
Why is gnome-shell staying alive after logout?
I would like to switch to xfce desktop. (I was already able to start xfce using xfce4-session).
Settings for /etc/lightdm/lightdm.conf
[Seat:*]
type=xremote
xserver-share=true
xserver-hostname=192.168.0.116
xserver-display-number=0

I'm not sure where 192.168.0.116 came from, but try replacing it with $(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null) or $(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0

Related

Chromium pop up on Raspbian

I'm running Chromium 16 on a Raspberry Pi 3 with the latest Raspbian. My purpose is to launch a Chromium page in --kiosk mode on start-up.
The Pi will always be shut down by switching the power off, so on start-up Chromium shows the "Chromium didn't shut down properly" pop-up. I need to disable this pop-up. I already looked for a bunch of solutions on the web, especially on this thread: https://superuser.com/questions/873381/how-can-i-disable-the-chromium-didn-t-shut-down-correctly-message-when-my-brow
Sadly, none of these work for me. I also tried to set the permissions for the chromium preferences file to read only, but permissions seem to be restored on boot.
Any ideas?
I was looking for a long time, here is my solution:
#!/bin/bash
#Set CrProfile to the value of your startup profile's config folder
CrProfile="Default"
HomeFolder="/home/myhome"
#Set URL to the URL that you want the browser to start with
URL="http://www.apple.com"
#Delete SingletonLock
rm -f $HomeFolder/.config/chromium/SingletonLock
rm -f $HomeFolder/.cache/chromium
#Clean up the randomly-named file(s)
for i in $HomeFolder/.config/chromium/$CrProfile/.org.chromium.Chromium.*; do
sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' $i
sed -i 's/"exit_state": "Crashed"/"exit_state": "Normal"/' $i
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' $i
done
#Clean up Preferences
sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' $HomeFolder/.config/chromium/$CrProfile/Preferences
sed -i 's/"exit_state": "Crashed"/"exit_state": "Normal"/' $HomeFolder/.config/chromium/$CrProfile/Preferences
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' $HomeFolder/.config/chromium/$CrProfile/Preferences
#Clean up Local State
sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' $HomeFolder/.config/chromium/"Local State"
/usr/bin/X11/chromium-browser --no-first-run --kiosk $URL
In most recent version (v60 here), I fix this by running with the following argument
chromium-browser --kiosk --app=http://www.example.com
For those arriving here from Google:
The best way to now perform this task, without having to use incognito, is to adjust two settings in the Chromium preferences. They are:
exited_cleanly
exit_type
From what I have gathered from personal tests, just changing the "exited_cleanly" setting may not always work at preventing the Chromium prompt on startup. Other flags such as "-disable-infobars" will also not work.
To adjust these settings, please add the following in your startup file, before launching Chromium (depending on how you have set up Chromium to automatically run in kiosk mode, this file can either be located at "/etc/xdg/lxsession/LXDE-pi/autostart", "/etc/xdg/openbox/autostart", "~/.Xsession", or another file, depending on what you have already installed).
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/Default/Preferences
sed -i ‘s/”exit_type”: “Crashed”/”exit_type”: “Normal”/’ ~/.config/chromium/Default/Preferences
For example, with my setup (using Xsession), the procedure would go as follows:
Enter "sudo ~/.Xsession" into the console
Insert the above 2 lines into the file, before Chromium is run (You should see a line starting with "chromium-browser", so insert them above this)
Press ctrl + X to exit the file
Type "Y"
Press enter
Reboot the machine
Again, the file used to start up Chromium may be located in a different location, depending on how you have setup your pi, but after changing these two settings, Chromium should start up without displaying the crashing prompt.

How to use screen to issue a command in the background over an ssh session

I am used to using linux terminals and nohup over ssh to issue commands that run in the background even when logged out of the ssh session. For some reason nohup seems to be broken in the latest MACOS. For that reason I am trying to executing this small sample script using screen command.
sleep 10
echo "this is my test file" > testfile
This file is saved as tst script. And then I issue the following command.
ssh sohaib#localhost screen -dm sh testscript
However nothing happens. screen just exits quietly without writing to the file testfile.
If I run this without ssh it works as desired. What am I doing wrong here?
The issue is that after your script exits the screen exits. The -dm is for deamons, i.e., scripts that keep running.
Showing the screen exiting after 10 seconds:
On remote host (file is executable):
ttucker#merlin:~$ cat test.sh
#!/bin/bash
echo derp > /tmp/test.txt
sleep 10
Command on local machine:
[ttucker#localhost ~]$ ssh ttucker#merlin 'screen -dmS my_screen ~/test.sh'
After run.
On remote machine, a few seconds after screen is running:
ttucker#merlin:~$ screen -ls
There is a screen on:
23141.my_screen (11/21/2016 07:05:11 PM) (Detached)
1 Socket in /var/run/screen/S-ttucker.
On remote machine, over 10 seconds later:
ttucker#merlin:~$ screen -ls
No Sockets found in /var/run/screen/S-ttucker.
Modifying the script to keep running, and so, keeping the screen up:
If you are really running a script that needs to stay up you can do the following in the script:
#!/bin/bash
while true; do
# Do something
sleep 10
done
This will do something, wait 10 seconds, then loop again.
Or, detaching the screen manually:
You can ssh to the remote machine, run screen, then press Ctrl+A,D, press Ctrl and hold, then hit A then hit D. You can now exit the SSH session and the screen will stay running.

Resuming screen after ssh-ing into server

I get the following error when I try to resume the only running screen session on a ubuntu machine (after sshing to it from my Mac OS X 10.9)
ubuntu#ip-10-252-164-249:~$ screen -r
Cannot find terminfo entry for 'xterm-new'
How can we fix this?
It sounds as if $TERM is set on the OSX end of the connection, and passed through to the Ubuntu end. The workaround would be (on the Ubuntu end, and presuming you are using bash):
TERM=xterm screen -x
which would override $TERM when reattaching the screen session. You could of course do
export TERM=xterm
screen -x
depending on how you want to work with it.

Is there a way to configure PuTTY or other terminal to flash the taskbar on next output to stdout?

I'm specifically looking for a solution for PuTTY but also interested for other terminal emulators, like Gnome Terminal.
My thought is it would be useful if I start a tar zxvf to be able to set a trigger on the terminal emulator, minimize it, and on next output to stdout/stderr I get a notification in the task bar that the command has finished.
This works for me:
echo -e "\a"
Then update your PuTTY session to use the Visual Bell, and set "Taskbar/caption indication on bell" to Flashing or Steady.
Then run this command after your tar completes:
tar xvzf file ; echo -e "\a"
Here is a screenshot: Save these settings as the default settings and/or the sessions' settings you have

How do I execute a command every time after ssh'ing from one machine to another?

How do I execute a command every time after ssh'ing from one machine to another?
e.g
ssh mymachine
stty erase ^H
I'd rather just have "stty erase ^H" execute every time after my ssh connection completes.
This command can't simply go into my .zshrc file. i.e. for local sessions, I can't run the command (it screws up my keybindings). But I need it run for my remote sessions.
Put the commands in ~/.ssh/rc
You can put something like this into your shell's startup file:
if [ -n "$SSH_CONNECTION" ]
then
stty erase ^H
end
The -n test will determine if SSH_CONNECTION is set which happens only when logged in via SSH.
If you're logging into a *nix box with a shell, why not put it in your shell startup?
.bashrc or .profile in most cases.
Assuming a linux target, put it in your .profile
Try adding the command below the end of your ~/.bashrc. It should be exited upon logoff. Do you want this command only executed when logging off a ssh session? What about local sessions, etc?
trap 'stty erase ^H; exit 0' 0
You probably could setup a .logout file from /etc/profile using this same pattern as well.
An answer for us, screen/byobu users:
The geocar's solution will not work as screen will complain that "Must be connected to a terminal.". (This is probably caused by the fact that .ssh/rc is processed before shell is started. See LOGIN PROCESS section from man 8 sshd).
Robert's solution is better here but since screen and byobu open it's own bash instance, we need to avoid infinite recursion. So here is adjusted byobu-friendly version:
## RUN BYOBU IF SSH'D ##
## '''''''''''''''''' ##
# (but only if this is a login shell)
if shopt -q login_shell
then
if [ -n "$SSH_CONNECTION" ]
then
byobu
exit
fi
fi
Note that I also added exit after byobu, since IMO if you use byobu in the first place, you normally don't want to do anything outside of it.