change sharing setting from terminal

Asked by Tal Pilo

Hi,

Is there any way to enable screen sharing from terminal?
i mean the setting->sharing and then turn on sharing from terminal, and then enable:
setting->sharing->screen sharing from terminal and change the password inside the screen sharing.

Thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Tal Pilo
Solved:
Last query:
Last reply:
Revision history for this message
Larry Irwin (lrirwin) said :
#1

Some of this is done as root.
All the gsettings commands are logged in as "someuser" (they won't work as root...)

# [ enable auto-login and immediate lock screen to get vino running ]
vi /etc/gdm3/custom.conf
# [ uncomment this line or the mouse/keyboard I/O will be screwed (i.e. really really slow input only) ]
WaylandEnable=false
# [ add these lines ]
AutomaticLoginEnable = true
AutomaticLogin = someuser
# [ save the changes ]
mkdir -p /home/someuser/.config/autostart
chown cca:cca /home/someuser/.config/autostart
chmod 700 /home/someuser/.config/autostart
vi /home/someuser/.config/autostart/gnome-screensaver-command.desktop
# [ add these lines ]
[Desktop Entry]
Type=Application
Exec=dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=Screen Saver
Name=Screen Saver
Comment[en_US]=Screen Saver
Comment=Screen Saver
# [ save the file ]
chown someuser:someuser /home/someuser/.config/autostart/*.desktop
chmod 666 /home/someuser/.config/autostart/*.desktop

# if you forgot to enable screen sharing, login as someuser via ssh and run the following
PID=$(pgrep gnome-session | head -n 1)
export HOME=/home/someuser
export DISPLAY=:0
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
gsettings set org.gnome.Vino enabled true
gsettings set org.gnome.Vino notify-on-connect false
gsettings set org.gnome.Vino require-encryption false

# And to get vino working in a headless environment do these things
vi /home/someuser/.config/autostart/vino-server.desktop
# [ add these lines ]
[Desktop Entry]
Type=Application
Name=Vino VNC server
Exec=/usr/lib/vino/vino-server
NoDisplay=true
# [ save the file ]
chown someuser:someuser /home/someuser/.config/autostart/*.desktop
chmod 666 /home/someuser/.config/autostart/*.desktop
# and set up the "dummy" X11 monitor
vi /etc/X11/xorg.conf
# [replace content with these lines]
Section "Monitor"
 Identifier "Monitor0"
 HorizSync 28.0-80.0
 VertRefresh 48.0-75.0
 # 1024x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 64.11 MHz
 # Modeline "1024x768_60.00" 64.11 1024 1080 1184 1344 768 769 772 795 -HSync +Vsync
 # 1280x720 @ 60.00 Hz (GTF) hsync: 44.76 kHz; pclk: 74.48 MHz
 # Modeline "1280x720_60.00" 74.48 1280 1336 1472 1664 720 721 724 746 -HSync +Vsync
 # 1368x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 85.86 MHz
 # Modeline "1368x768_60.00" 85.86 1368 1440 1584 1800 768 769 772 795 -HSync +Vsync
 # 1600x900 @ 60.00 Hz (GTF) hsync: 55.92 kHz; pclk: 119.00 MHz
 Modeline "1600x900_60.00" 119.00 1600 1696 1864 2128 900 901 904 932 -HSync +Vsync
 # 1920x1080 @ 60.00 Hz (GTF) hsync: 67.08 kHz; pclk: 172.80 MHz
 # Modeline "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
EndSection
Section "Device"
 Identifier "Card0"
 Option "NoDDC" "true"
 Option "IgnoreEDID" "true"
 Driver "dummy"
EndSection
Section "Screen"
 DefaultDepth 16
 Identifier "Screen0"
 Device "Card0"
 Monitor "Monitor0"
  SubSection "Display"
  Depth 16
  Modes "1600x900"
  EndSubSection
EndSection
# [ save the file ]

systemctl restart gdm3

Revision history for this message
Larry Irwin (lrirwin) said :
#2

... anywhere you see "cca" as a user - replace it with "someuser" -- I missed a couple...

Revision history for this message
Larry Irwin (lrirwin) said :
#3

Once you connect via a VNC client app, you can run anything -except- System Settings. It will crash for some reason - probably something to do with either xorg or polkit.

Revision history for this message
Tal Pilo (talpilo) said :
#5

Thank you very much!!! it helped me a lot!!!