#!/bin/sh

###########################################################################
# Helper script for the remote-assistant menu.
# Not to be called as a standalone script.
#
# Copyright (C) 2011 Alkis Georgopoulos <alkisg@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# On Debian GNU/Linux systems, the complete text of the GNU General
# Public License can be found in `/usr/share/common-licenses/GPL'.
###########################################################################

if [ -n "$1" ]; then
    exec x11vnc -q -nopw -connect_or_exit "$1" -afteraccept "$0 &"
fi

echo "message:Remote assistance connection established" \
  | zenity --notification --window-icon=/usr/share/icons/gnome/scalable/apps/gnome-remote-desktop.svg --listen
zenity --notification --window-icon=/usr/share/icons/gnome/scalable/apps/gnome-remote-desktop.svg --text="Remote assistance connection established"
test -n "$RFB_X11VNC_PID" && kill "$RFB_X11VNC_PID"
