Add GUI to trigger connection

Reading width and height is not implemented yet
master
Mikhail Novosyolov 3 years ago
parent 0e0647a195
commit 9898a953f0
  1. 3
      .gear/doskast.spec
  2. 2
      Makefile
  3. 3
      server-watcher/doskast-server-watcher.sh
  4. 11
      student-connect/doskast-student-connect.desktop
  5. 36
      student-connect/doskast-student-connect.sh

@ -40,6 +40,7 @@ Requires(pre): apache2-base
Summary: Doskast for client (student)
Group: Graphical desktop/Other
Requires: curl
Requires: xdpyinfo
Requires: xpra
Requires: zenity
Requires: %{_bindir}/pkexec
@ -49,11 +50,13 @@ Requires: %{_bindir}/pkexec
%files student
%{_bindir}/doskast-student-config
%{_bindir}/doskast-student-connect
%{_bindir}/doskast-xpra-shadow
%{_sbindir}/doskast-student-config
%{_unitdir}/doskast-xpra-shadow.service
%{_unitdir}/doskast-xpra-shadow.socket
%{_datadir}/applications/doskast-student-config.desktop
%{_datadir}/applications/doskast-student-connect.desktop
%{_datadir}/polkit-1/actions/ru.mos.doskast-student-config.policy
%{_sysconfdir}/xdg/autostart/doskast-xpra-shadow.desktop
%config(noreplace) %{_sysconfdir}/systemd/system/doskast-xpra-shadow.service.d/xpra-shadow-firewall.conf

@ -27,6 +27,7 @@ install:
echo -e '#!/bin/sh\npkexec $(SBINDIR)/doskast-student-config "$$@"' > $(DESTDIR)$(BINDIR)/doskast-student-config
chmod 0755 $(DESTDIR)$(BINDIR)/doskast-student-config
install -m0755 xpra-shadow/doskast-xpra-shadow.sh $(DESTDIR)$(BINDIR)/doskast-xpra-shadow
install -m0755 student-connect/doskast-student-connect.sh $(DESTDIR)$(BINDIR)/doskast-student-connect
mkdir -p --mode=0755 $(DESTDIR)$(SYSCONFDIR)/xdg/autostart
install -m0644 server-watcher/doskast-server-watcher.desktop $(DESTDIR)$(SYSCONFDIR)/xdg/autostart
@ -37,3 +38,4 @@ install:
mkdir -p --mode=0755 $(DESTDIR)$(DATADIR)/applications
install -m0644 student-config/doskast-student-config.desktop $(DESTDIR)$(DATADIR)/applications
install -m0644 student-connect/doskast-student-connect.desktop $(DESTDIR)$(DATADIR)/applications

@ -17,6 +17,9 @@ _main_server_watcher(){
local target
target="$(head -n 1 "$dir/$line" | _safe_param_stdin)"
test -n "$target"
# TODO: calculate scale factor for xpra based on width and height
# https://unix.stackexchange.com/a/400791
#IFS=', =' read -a area < <(xprop -root '_NET_WORKAREA')
# log how xpra is run into ~/.xsession-errors*
( set -x ; xpra attach tcp://"$target":4648 ) &
# XXX TODO: this fails for now, fix permissions and try to avoid 777

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Doskast Connect
Name[ru]=Соединение Doskast
Comment=Make board cast screen of this computer
Comment[ru]=Запуск трансляции экрана этого компьютера на доске
Exec=doskast-student-connect
# TODO: a better icon
Icon=network-wireless-hotspot
Type=Application
Terminal=false
Categories=Education;

@ -1,2 +1,38 @@
#!/bin/bash
set -e
set -f
set -u
set -o pipefail
_zenity(){
zenity --width=250 --title="Doskast" "$@"
}
readonly config="/etc/doskastrc"
if ! . /etc/doskastrc ; then
# || : to stabilize return code if clicking "Cancel" in zenity
_zenity --error --text="Нет файла с настройками Doskast, запустите программу настройки!" || :
exit 1
fi
if [ -z "${board:-}" ]; then
_zenity --error --text="Неправильный файл настроек Doskast, запустите программу настройки!" || :
exit 1
fi
IFS='x' read -a area < <(xdpyinfo | grep -oP 'dimensions:\s+\K\S+')
width="${area[0]}"
height="${area[1]}"
if [ -z "$width" ] || [ -z "$height" ]; then
_zenity --error --text="Ошибка получения геометрии экрана." || :
exit 1
fi
if ! curl --fail "http://${board}/cgi-bin/doskast-trigger-connect.cgi?width=${width}&height=${height}"; then
_zenity --error --text="Ошибка отправки запроса на доску." || :
exit 1
fi
_zenity --info --text="На доску отправлен запрос на трансляцию экрана этого компьютера." || :

Loading…
Cancel
Save