Skip to content

Instantly share code, notes, and snippets.

@ludufre
Created August 19, 2025 01:24
Show Gist options
  • Select an option

  • Save ludufre/59a86188df6fc446151dc162621e5349 to your computer and use it in GitHub Desktop.

Select an option

Save ludufre/59a86188df6fc446151dc162621e5349 to your computer and use it in GitHub Desktop.
Tela adicional virtual no VNC do PI

Tela adicional virtual no VNC do PI

# Tela adicional para VN no PI

mkdir -p ~/bin

tee ~/bin/start-vnc-virtual.sh >/dev/null <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
# evita instâncias presas
/usr/bin/vncserver-virtual -kill :1 >/dev/null 2>&1 || true
# sobe o :1
exec /usr/bin/vncserver-virtual :1 -geometry 1280x800
EOF

chmod +x ~/bin/start-vnc-virtual.sh

mkdir -p ~/.config/systemd/user

tee ~/.config/systemd/user/[email protected] /dev/null <<'EOF'
[Unit]
Description=RealVNC Virtual Desktop on display %i
After=network-online.target
Wants=network-online.target

[Service]
Type=forking
Environment=HOME=%h
WorkingDirectory=%h
PIDFile=%h/.vnc/%H:%i.pid
ExecStart=/usr/bin/vncserver-virtual :%i -geometry 1280x800
ExecStop=/usr/bin/vncserver-virtual -kill :%i
Restart=on-failure
RestartSec=2

[Install]
WantedBy=default.target
EOF

sudo loginctl enable-linger "$USER"
systemctl --user daemon-reload
systemctl --user enable --now vnc-virtual@1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment