# x

* [get screen solution](#get-screen-solution)
* [screen sharing](#screen-sharing)
  * [setup screen sharing](#setup-screen-sharing)
  * [start x server](#start-x-server)
  * [backup and restore config](#backup-and-restore-config)
    * [read all conf](#read-all-conf)
  * [reset vnc password](#reset-vnc-password)
  * [check using wayland or xorg](#check-using-wayland-or-xorg)
  * [start application remotely](#start-application-remotely)
* [gdm](#gdm)
  * [gnome-shell](#gnome-shell)
  * [autologin](#autologin)
  * [login session](#login-session)
  * [default session](#default-session)
  * [process and subprocesses](#process-and-subprocesses)
    * [pstree](#pstree)
  * [ps](#ps)
* [Wayland](#wayland)
  * [wayland known error](#wayland-known-error)

> \[!NOTE|label:references:]
>
> * [GDM Reference Manual](https://help.gnome.org/admin/gdm/stable/index.html.en)
> * [GNOME](https://wiki.archlinux.org/index.php/GNOME)
> * [How to configure Vino for remote desktop access using command line](https://access.redhat.com/solutions/346033)
> * [Vino](https://wiki.archlinux.org/index.php/Vino)
> * [Vino. The Remote Desktop Project](https://people.gnome.org/~markmc/remote-desktop.html)
> * [VND/Servers](https://help.ubuntu.com/community/VNC/Servers)

## get screen solution

```bash
$ xrandr --verbose
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192
XWAYLAND0 connected 1920x1080+0+0 (0x22) normal (normal left inverted right x axis y axis) 480mm x 270mm
    Identifier: 0x21
    Timestamp:  3807
    Subpixel:   unknown
    Gamma:      1.0:1.0:1.0
    Brightness: 0.0
    Clones:
    CRTC:       0
    CRTCs:      0
    Transform:  1.000000 0.000000 0.000000
                0.000000 1.000000 0.000000
                0.000000 0.000000 1.000000
               filter:
  1920x1080 (0x22) 173.000MHz -HSync +VSync *current +preferred
        h: width  1920 start 2048 end 2248 total 2576 skew    0 clock  67.16KHz
        v: height 1080 start 1083 end 1088 total 1120           clock  59.96Hz
```

## screen sharing

### setup screen sharing

```bash
#!/usr/bin/env bash
export DISPLAY=:0
read -e -p "VNC Password: " -i "ubuntu" password
dconf write /org/gnome/desktop/remote-access/enabled true
dconf write /org/gnome/desktop/remote-access/prompt-enabled false
dconf write /org/gnome/desktop/remote-access/authentication-methods "['vnc']"
dconf write /org/gnome/desktop/remote-access/require-encryption false08/03/2018
dconf write /org/gnome/desktop/remote-access/vnc-password \"\'$(echo -n $password | base64)\'\"
dconf dump /org/gnome/desktop/remote-access/
## sudo service lightdm restart
```

*   or

    ```bash
    $ read -e -p "VNC Password: " -i "ubuntu" VNCPASSWORD
    $ dconf write /org/gnome/desktop/remote-access/enabled true
    $ dconf write /org/gnome/desktop/remote-access/authentication-methods "['vnc']"
    $ dconf write /org/gnome/desktop/remote-access/prompt-enabled false
    $ dconf write /org/gnome/desktop/remote-access/require-encryption false
    $ dconf write /org/gnome/desktop/remote-access/vnc-password \"\'$(echo -n $VNCPASSWORD | base64)\'\"
    $ sudo service lightdm restart
    ```
*   or

    ```bash
    $ vino-preference
    $ dconf-editor
    ```

### start x server

```bash
$ export DISPLAY=:0
$ /usr/lib/vino/vino-server --display=:0 &
```

### backup and restore config

```bash
$ dconf dump /org/gnome/desktop/remote-access/ > ubuntu1804_remoteaccess
$ cat ubuntu1804_remoteaccess
[/]
require-encryption=false
vnc-password='bWFyc2xv'
authentication-methods=['vnc']
prompt-enabled=false
$ dconf load /org/gnome/desktop/remote-access/ < ubuntu1804_remoteaccess
```

#### read all conf

```bash
$ for i in $(gsettings list-keys org.gnome.Vino); do
  echo -e "$i:\t --> "$(dconf read /org/gnome/desktop/remote-access/$i);
done
notify-on-connect:   -->
alternative-port:    -->
disable-background:  -->
use-alternative-port:    -->
icon-visibility:     -->
use-upnp:    -->
view-only:   -->
prompt-enabled:  --> false
disable-xdamage:     -->
authentication-methods:  --> ['vnc']
network-interface:   -->
require-encryption:  --> false
mailto:  -->
lock-screen-on-disconnect:   -->
vnc-password:    --> 'bWFyc2xv'
```

### [reset vnc password](https://access.redhat.com/solutions/346033)

```bash
$ echo -n 'awesome' | base64
$ gconftool-2 -s -t string /desktop/gnome/remote_access/vnc_password $(echo -n "<YOURPASSWORD>" | base64)
$ gconftool-2 --type string --set /desktop/gnome/remote_acess/vnc_password '123456'
```

*   or

    ```bash
    $ echo -n "marslo" | base64
    bWFyc2xv
    ```

### check using wayland or xorg

```bash
$ echo $XDG_SESSION_TYPE
```

* Ubuntu: Wayland (Wayland)
* Ubuntu on Xorg: Xorg (X11)

### start application remotely

```bash
$ export DISPLAY=:0
$ gnome-terminal
```

## [gdm](https://wiki.archlinux.org/index.php/GDM)

```bash
$ cat /lib/systemd/system/gdm.service
[Unit]
Description=GNOME Display Manager

## replaces the getty
Conflicts=getty@tty1.service
After=getty@tty1.service

## replaces plymouth-quit since it quits plymouth on its own
Conflicts=plymouth-quit.service
After=plymouth-quit.service

## Needs all the dependencies of the services it's replacing
## pulled from getty@.service and plymouth-quit.service
## (except for plymouth-quit-wait.service since it waits until
## plymouth is quit, which we do)
After=rc-local.service plymouth-start.service systemd-user-sessions.service

## GDM takes responsibility for stopping plymouth, so if it fails
## for any reason, make sure plymouth still stops
OnFailure=plymouth-quit.service

[Service]
ExecStartPre=/usr/share/gdm/generate-config
ExecStart=/usr/sbin/gdm3
KillMode=mixed
Restart=always
RestartSec=1s
IgnoreSIGPIPE=no
BusName=org.gnome.DisplayManager
StandardOutput=syslog
StandardError=inherit
EnvironmentFile=-/etc/default/locale
ExecReload=/usr/share/gdm/generate-config
ExecReload=/bin/kill -SIGHUP $MAINPID
```

### [gnome-shell](https://www.archlinux.org/packages/extra/x86_64/gnome-shell/)

### [autologin](https://wiki.archlinux.org/index.php/GDM##Users_and_login)

*   login with desired session

    ```bash
    $ cat /var/lib/AccountsService/users/devops
    [User]
    FormatsLocale=en_US.UTF-8
    XSession=gnome-xorg
    SystemAccount=false

    [InputSource0]
    xkb=us
    ```
*   auto login with gdm

    ```bash
    $ grep -i auto /etc/gdm3/custom.conf
    [daemon]
    ## Enabling automatic login
    AutomaticLoginEnable = true
    AutomaticLogin = devops
    ```
*   auto login with delay

    ```bash
    $ grep -i time /etc/gdm3/custom.conf
    [daemon]
    ## Enabling timed login
    ##  TimedLoginEnable = true
    ##  TimedLogin = user1
    ##  TimedLoginDelay = 10
    ```

### login session

![desktop styles](https://github.com/marslo/ibook/blob/marslo/docs/screenshots/desktop-style-2.jpeg)

### default session

```bash
$ cat /etc/X11/default-display-manager
/usr/sbin/gdm3
```

### process and subprocesses

#### pstree

```bash
$ pstree 1391
gdm3─┬─gdm-session-wor─┬─gdm-x-session─┬─Xorg───{Xorg}
     │                 │               ├─gnome-session-b─┬─deja-dup-monito───4*[{deja-dup-monito}]
     │                 │               │                 ├─gnome-software───3*[{gnome-software}]
     │                 │               │                 ├─gsd-a11y-settin───3*[{gsd-a11y-settin}]
     │                 │               │                 ├─gsd-clipboard───2*[{gsd-clipboard}]
     │                 │               │                 ├─gsd-color───3*[{gsd-color}]
     │                 │               │                 ├─gsd-datetime───3*[{gsd-datetime}]
     │                 │               │                 ├─gsd-disk-utilit───2*[{gsd-disk-utilit}]
     │                 │               │                 ├─gsd-housekeepin───3*[{gsd-housekeepin}]
     │                 │               │                 ├─gsd-keyboard───3*[{gsd-keyboard}]
     │                 │               │                 ├─gsd-media-keys───3*[{gsd-media-keys}]
     │                 │               │                 ├─gsd-mouse───3*[{gsd-mouse}]
     │                 │               │                 ├─gsd-power───3*[{gsd-power}]
     │                 │               │                 ├─gsd-print-notif───2*[{gsd-print-notif}]
     │                 │               │                 ├─gsd-rfkill───2*[{gsd-rfkill}]
     │                 │               │                 ├─gsd-screensaver───2*[{gsd-screensaver}]
     │                 │               │                 ├─gsd-sharing───3*[{gsd-sharing}]
     │                 │               │                 ├─gsd-smartcard───4*[{gsd-smartcard}]
     │                 │               │                 ├─gsd-sound───3*[{gsd-sound}]
     │                 │               │                 ├─gsd-wacom───2*[{gsd-wacom}]
     │                 │               │                 ├─gsd-xsettings───3*[{gsd-xsettings}]
     │                 │               │                 ├─nautilus-deskto───3*[{nautilus-deskto}]
     │                 │               │                 ├─ssh-agent
     │                 │               │                 ├─update-notifier───3*[{update-notifier}]
     │                 │               │                 └─3*[{gnome-session-b}]
     │                 │               └─2*[{gdm-x-session}]
     │                 └─2*[{gdm-session-wor}]
     └─2*[{gdm3}]
```

### ps

```bash
$ ps auxwwf
/usr/sbin/gdm3
 \_ gdm-session-worker [pam/gdm-autologin]
     \_ /usr/lib/gdm3/gdm-x-session --run-script env GNOME_SHELL_SESSION_MODE=ubuntu gnome-session --session=ubuntu
         \_ /usr/lib/xorg/Xorg vt1 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -background none -noreset -keeptty -verbose 3
         \_ /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
             \_ /usr/bin/ssh-agent /usr/bin/im-launch env GNOME_SHELL_SESSION_MODE=ubuntu gnome-session --session=ubuntu
             \_ /usr/lib/gnome-settings-daemon/gsd-power
             \_ /usr/lib/gnome-settings-daemon/gsd-print-notifications
             \_ /usr/lib/gnome-settings-daemon/gsd-rfkill
             \_ /usr/lib/gnome-settings-daemon/gsd-screensaver-proxy
             \_ /usr/lib/gnome-settings-daemon/gsd-sharing
             \_ /usr/lib/gnome-settings-daemon/gsd-smartcard
             \_ /usr/lib/gnome-settings-daemon/gsd-sound
             \_ /usr/lib/gnome-settings-daemon/gsd-xsettings
             \_ /usr/lib/gnome-settings-daemon/gsd-wacom
             \_ /usr/lib/gnome-settings-daemon/gsd-clipboard
             \_ /usr/lib/gnome-settings-daemon/gsd-a11y-settings
             \_ /usr/lib/gnome-settings-daemon/gsd-datetime
             \_ /usr/lib/gnome-settings-daemon/gsd-color
             \_ /usr/lib/gnome-settings-daemon/gsd-keyboard
             \_ /usr/lib/gnome-settings-daemon/gsd-housekeeping
             \_ /usr/lib/gnome-settings-daemon/gsd-mouse
             \_ /usr/lib/gnome-settings-daemon/gsd-media-keys
             \_ /usr/lib/gnome-disk-utility/gsd-disk-utility-notify
             \_ /usr/bin/gnome-software --gapplication-service
             \_ nautilus-desktop
             \_ update-notifier
             \_ /usr/lib/deja-dup/deja-dup-monitor
```

```bash
$ ps auxwwf
root      1391  0.0  0.1 308176  8340 ?        Ssl  16:58   0:00 /usr/sbin/gdm3
root      1456  0.0  0.1 271860  8720 ?        Sl   16:58   0:00  \_ gdm-session-worker [pam/gdm-autologin]
devops    1497  0.0  0.0 212124  6000 tty1     Ssl+ 16:58   0:00      \_ /usr/lib/gdm3/gdm-x-session --run-script env GNOME_SHELL_SESSION_MODE=ubuntu gnome-session --session=ubuntu
devops    1499  0.4  1.0 370392 81984 tty1     Sl+  16:58   0:02          \_ /usr/lib/xorg/Xorg vt1 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -background none -noreset -keeptty -verbose 3
devops    1518  0.0  0.1 716920 15716 tty1     Sl+  16:58   0:00          \_ /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
devops    1599  0.0  0.0  11304   320 ?        Ss   16:58   0:00              \_ /usr/bin/ssh-agent /usr/bin/im-launch env GNOME_SHELL_SESSION_MODE=ubuntu gnome-session --session=ubuntu
devops    2471  0.0  0.2 527336 23468 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-power
devops    2472  0.0  0.1 349316 10144 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-print-notifications
devops    2475  0.0  0.0 423340  5728 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-rfkill
devops    2481  0.0  0.0 275728  5048 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-screensaver-proxy
devops    2485  0.0  0.1 471340 11980 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-sharing
devops    2493  0.0  0.1 466472 10096 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-smartcard
devops    2495  0.0  0.1 343116  9808 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-sound
devops    2499  0.0  0.2 504824 23460 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-xsettings
devops    2511  0.0  0.2 440656 22568 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-wacom
devops    2530  0.0  0.2 355824 21572 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-clipboard
devops    2531  0.0  0.1 296660  8348 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-a11y-settings
devops    2532  0.0  0.1 476600 15176 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-datetime
devops    2536  0.0  0.3 678216 24396 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-color
devops    2537  0.0  0.2 508124 22096 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-keyboard
devops    2539  0.0  0.1 374712  8804 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-housekeeping
devops    2542  0.0  0.1 296672  8284 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-mouse
devops    2545  0.0  0.3 1155368 24656 tty1    Sl+  16:58   0:00              \_ /usr/lib/gnome-settings-daemon/gsd-media-keys
devops    2589  0.0  0.0 271928  6216 tty1     Sl+  16:58   0:00              \_ /usr/lib/gnome-disk-utility/gsd-disk-utility-notify
devops    2590  0.4  1.8 1318392 152212 tty1   SLl+ 16:58   0:02              \_ /usr/bin/gnome-software --gapplication-service
devops    2599  0.2  0.9 1197708 75864 tty1    Sl+  16:58   0:01              \_ nautilus-desktop
devops    3686  0.0  0.3 605436 28680 tty1     Sl+  16:59   0:00              \_ update-notifier
devops    4017  0.0  0.4 118225468 32448 tty1  Sl+  17:00   0:00              \_ /usr/lib/deja-dup/deja-dup-monitor
```

## [Wayland](https://wiki.archlinux.org/index.php/Wayland)

```bash
$ echo $WAYLAND_DISPLAY
wayland-0
```

### [wayland known error](https://askubuntu.com/a/967538)

```bash
cat <<EOF | sudo tee /etc/xdg/autostart/xhost.desktop
[Desktop Entry]
Name=xhost
Comment=Fix graphical root applications
Exec="xhost +si:localuser:root"
Terminal=false
Type=Application
EOF
```
