Difize ekran sou plizyè aparèy sou rezo a

Difize ekran sou plizyè aparèy sou rezo a

Mwen te gen yon bezwen montre yon tablodbò ak siveyans sou plizyè ekran nan biwo a. Gen plizyè fin vye granmoun Franbwaz Pi Modèl B + ak yon hypervisor ak yon kantite lajan prèske san limit nan resous.

Aparamman Raspberry Pi Modèl B + a pa gen ase owaza pou kenbe navigatè a toujou ap kouri ak rann yon anpil nan grafik nan li, paske li rive ke paj la se pasyèlman buggy e souvan aksidan.

Te gen yon solisyon jistis senp ak elegant, ke mwen vle pataje avèk ou.

Kòm ou konnen, tout Franbwazye gen yon processeur videyo jistis pwisan, ki se gwo pou dekodaj videyo pyès ki nan konpitè. Se konsa, lide a te vin lanse yon navigatè ak yon tablodbò yon lòt kote, epi transfere yon kouran pare-fè ak yon foto rann nan Franbwaz la.

Anplis de sa, sa a ta dwe senplifye jesyon, depi nan ka sa a tout konfigirasyon yo pral fèt sou yon sèl machin vityèl, ki se pi fasil aktyalizasyon ak backup.

Pa pi bonè di pase fè.

Pati sèvè

Nou itilize pare Imaj nwaj pou Ubuntu. Pa mande pou enstalasyon, li gen tout sa ou bezwen byen vit deplwaye yon machin vityèl, ak Sipò CloudInit ede imedyatman mete kanpe yon rezo, ajoute kle ssh epi byen vit mete l nan operasyon.

Nou deplwaye yon nouvo machin vityèl epi anvan tout enstale li sou li Xorg, nodm и bwat flux:

apt-get update
apt-get install -y xserver-xorg nodm fluxbox
sed -i 's/^NODM_USER=.*/NODM_USER=ubuntu/' /etc/default/nodm

Nou pral sèvi ak konfigirasyon an tou pou Xorg, tanpri akòde nou Diego Ongaro, ajoute sèlman yon nouvo rezolisyon 1920 × 1080, paske tout monitè nou yo pral sèvi ak li:

cat > /etc/X11/xorg.conf <<EOT
Section "Device"
    Identifier      "device"
    Driver          "vesa"
EndSection

Section "Screen"
    Identifier      "screen"
    Device          "device"
    Monitor         "monitor"
    DefaultDepth    16
    SubSection "Display"
        Modes       "1920x1080" "1280x1024" "1024x768" "800x600"
    EndSubSection
EndSection

Section "Monitor"
    Identifier      "monitor"
    HorizSync       20.0 - 50.0
    VertRefresh     40.0 - 80.0
    Option          "DPMS"
EndSection

Section "ServerLayout"
    Identifier      "layout"
    Screen          "screen"
EndSection
EOT

systemctl restart nodm

Koulye a, nou pral enstale Firefox, nou pral kouri li kòm yon sèvis sistèm, kidonk pou yon sèl bagay nou pral ekri yon fichye inite pou li:

apt-get install -y firefox xdotool

cat > /etc/systemd/system/firefox.service <<EOT
[Unit]
Description=Firefox
After=network.target

[Service]
Restart=always
User=ubuntu
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/ubuntu/.Xauthority"
ExecStart=/usr/bin/firefox -url 'http://example.org/mydashboard'
ExecStartPost=/usr/bin/xdotool search --sync --onlyvisible --class "Firefox" windowactivate key F11

[Install]
WantedBy=graphical.target
EOT

systemctl enable firefox
systemctl start firefox

Nou bezwen Xdotool pou nou ka kouri firefox imedyatman nan mòd ekran plen.
Sèvi ak paramèt la -url ou ka presize nenpòt paj pou li louvri otomatikman lè navigatè a kòmanse.

Nan etap sa a, kyòs nou an pare, men kounye a nou bezwen ekspòte imaj la sou rezo a nan lòt monitè ak aparèy. Pou fè sa, nou pral sèvi ak posiblite yo Mouvman JPEG, yon fòma ki pi souvan itilize pou difizyon videyo ki soti nan pifò webcams.

Pou sa nou bezwen de bagay: Fanpèg ak modil x11grab, pou pran foto ki soti nan x ak streamEye, ki pral distribye li bay kliyan nou yo:

apt-get install -y make gcc ffmpeg 

cd /tmp/
wget https://github.com/ccrisan/streameye/archive/master.tar.gz
tar xvf master.tar.gz 
cd streameye-master/
make
make install

cat > /etc/systemd/system/streameye.service <<EOT
[Unit]
Description=streamEye
After=network.target

[Service]
Restart=always
User=ubuntu
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/ubuntu/.Xauthority"
ExecStart=/bin/sh -c 'ffmpeg -f x11grab -s 1920x1080 -i :0 -r 1 -f mjpeg -q:v 5 - 2>/dev/null | streameye'

[Install]
WantedBy=graphical.target
EOT

systemctl enable streameye
systemctl start streameye

Depi foto nou an pa mande pou yon aktyalizasyon rapid, mwen espesifye pousantaj rafrechisman an: 1 ankadreman pou chak segonn (paramèt -r 1) ak bon jan kalite konpresyon: 5 (paramèt -q:v 5)

Koulye a, ann eseye ale nan http://your-vm:8080/, an repons ou pral wè yon Ekran ki toujou ajou nan Desktop la. Gwo! - sa ki te bezwen.

Bò kliyan

Li toujou pi fasil isit la, jan mwen te di, nou pral sèvi ak Raspberry Pi Modèl B + la.

Premye a tout, se pou yo enstale li ArchLinux ARM, pou sa nou swiv enstriksyon sou sit entènèt ofisyèl lan.

Nou pral bezwen tou asiyen plis memwa pou chip videyo nou an, pou sa a nou pral edite nan /boot/config.txt

gpu_mem=128

Ann demare nouvo sistèm nou an epi pa bliye inisyalize bag kle pacman la, enstale OMXPlayer:

pacman -Sy omxplayer

Remakab, OMXPlayer ka travay san x, kidonk tout sa nou bezwen se ekri yon fichye inite pou li epi kouri:

cat > /etc/systemd/system/omxplayer.service <<EOT
[Unit]
Description=OMXPlayer
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/omxplayer -r --live -b http://your-vm:8080/ --aspect-mode full

[Install]
WantedBy=multi-user.target
EOT

systemctl enable omxplayer
systemctl start omxplayer

Kòm yon paramèt -b http://your-vm:8080/ nou ap pase url la soti nan sèvè nou an.

Sa a tout, yon foto nan sèvè nou an ta dwe imedyatman parèt sou ekran an konekte. Nan ka nenpòt pwoblèm, kouran an pral rekòmanse otomatikman ak kliyan yo pral rekonekte li.

Kòm yon bonis, ou ka enstale foto a ki kapab lakòz kòm yon ekran sou tout òdinatè nan biwo a. Pou sa w ap bezwen MPV и XScreenSaver:

mode:  one
selected: 0
programs:              
     "Monitoring Screen"  mpv --really-quiet --no-audio --fs       
      --loop=inf --no-stop-screensaver       
      --wid=$XSCREENSAVER_WINDOW        
      http://your-vm:8080/      n
    maze -root        n
    electricsheep --root 1       n

Kounye a kòlèg ou yo ap kontan anpil 🙂

Sous: www.habr.com

Add nouvo kòmantè