exec_dialog.sh 3.36 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
#!/bin/bash
# Copyright (C) 2004-2018 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
# This file is part of le-proinfodata
#
# exec_dialog.sh 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 2
# 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.

F_MULT="/tmp/.mult.lock"
F_INEP="/opt/seed_mec/SEED2/client/conf/inep"
DIALOG_INEP="/usr/lib/le-proinfodata/dialog_inep.sh"

function enable_mouse () {
    # Enable mouse right-click and left-click
    xmodmap -e "pointer = default"
}

function disable_mouse () {
    #if [[ -z "$1" ]]; then
        # Disable mouse right-click
        xmodmap -e "pointer = 1 2 0 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32"
        xmodmap -e "keycode 64 = "
    # else
    #     # Disable mouse right-click and left-click
    #     xmodmap -e "pointer = 0 2 0 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32"
    #     xmodmap -e "keycode 64 = "
    # fi
}

function disable_keyboard () {
    # Disable keyboard control-button and alt-button
    xmodmap -e "remove Control = Control_L"
    xmodmap -e "keycode 64 = "
}

function enable_keyboard () {
    # Enable keyboard control-button and alt-button
    xmodmap -e "add Control = Control_L"
    xmodmap -e "keycode 64 = Alt_L Meta_L Alt_L Meta_L Alt_L Meta_L"
}

function call_dialog_inep () {
    # Disable mouse right-click
    disable_mouse
    # Disable keyboard control-button and alt-button
    disable_keyboard
59 60 61 62
    # Authorise the user of the session being opened to display applications
    xhost "si:localuser:$USER"
    # Set background (running as user)
    eval "su -p \"$USER\" -c \"$DIALOG_INEP\""
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
    # Reset background to default
    xli -onroot -background black
    # Enable mouse right-click
    enable_mouse
    # Enable keyboard control-button and alt-button
    enable_keyboard
}

export LANG="pt_BR.UTF-8"
# SANITY CHECK -------------------------------------------------------
# Do not run script if we are on live-cd
# or the INEP code is already set
# or we are logging out
if dpkg --get-selections "ubiquity" | grep -q 'install$' ||
   [ -f $F_INEP ]; then
    exit 0
fi
# --------------------------------------------------------------------

82 83 84 85 86 87
# If the version is Particular, dont call exec_dialog
version=$(cat /etc/default/version)
if [ "$version" == "Particular" ]; then
    exit 0
fi

88 89 90 91 92 93 94 95 96 97 98 99 100 101
# Check whether the computer is running on a the multiterminal
if dpkg --get-selections "le-multiterminal" | grep -q 'install$'; then
    # In the first call (lightdm) in multiterminal this is script must leave, to be called again after.
    (
	#if  it got multerminal lock
        if flock -n 200  ; then
            call_dialog_inep
        fi
    ) 200>"$F_MULT"
else
    call_dialog_inep
fi

exit 0