From f81361e980121b28e2ea088f9dc997d442d5af97 Mon Sep 17 00:00:00 2001
From: Diego Giovane Pasqualin <dpasqualin@c3sl.ufpr.br>
Date: Wed, 12 Feb 2014 19:26:29 -0200
Subject: [PATCH] le-proinfodata: Fix exec_dialog.sh

This script had lots of problems:
1. Fixed disable/enable mouse button
2. Moved code from stop_screen.sh to exec_dialog.sh
3. Fixed code moved..

Signed-off-by: Diego Giovane Pasqualin <dpasqualin@c3sl.ufpr.br>
---
 .../package/usr/local/bin/exec_dialog.sh      | 53 ++++++++++++++-----
 .../usr/share/gnome/autostart/stop_screen.sh  | 30 -----------
 2 files changed, 41 insertions(+), 42 deletions(-)
 delete mode 100644 le-proinfodata/package/usr/share/gnome/autostart/stop_screen.sh

diff --git a/le-proinfodata/package/usr/local/bin/exec_dialog.sh b/le-proinfodata/package/usr/local/bin/exec_dialog.sh
index 7411dc3c..6269f41f 100755
--- a/le-proinfodata/package/usr/local/bin/exec_dialog.sh
+++ b/le-proinfodata/package/usr/local/bin/exec_dialog.sh
@@ -17,6 +17,7 @@
 # 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_LOCK="/tmp/.dialog.lock"
 F_INEP="/opt/seed_mec/SEED2/client/conf/inep"
@@ -24,13 +25,13 @@ BACKGROUND="/usr/share/backgrounds/le5-wallpaper1600X1200.png"
 LE_EDUBAR_POS="/usr/share/gnome/autostart/le-edubar_position.sh"
 
 function enable_mouse () {
-    xmodmap -e "pointer = 1 2 3 4 5 6 7 8 9" &
-    xmodmap -e "keycode 64 = Alt_L Meta_L Alt_L Meta_L Alt_L Meta_L" &
+    xmodmap -e "pointer = default"
+    xmodmap -e "keycode 64 = Alt_L Meta_L Alt_L Meta_L Alt_L Meta_L"
 }
 
 function disable_mouse () {
-    xmodmap -e "pointer = 1 2 11 4 5 6 7 8 9" &
-    xmodmap -e "keycode 64 = " &
+    xmodmap -e  "pointer = 1 2 32 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 3"
+    xmodmap -e "keycode 64 = "
 }
 
 function call_dialog_inep_mult_off () {
@@ -45,17 +46,45 @@ function call_dialog_inep_mult_off () {
     enable_mouse
 }
 
+# Disable user interaction with gnome panel
+function disable_gnome() {
+    local P_EDUBAR=""
+    local P_EDUBAR_POS=""
+    local P_GPANEL=""
+
+    while [[ -z "$P_EDUBAR" ]] || [[ -z "$P_GPANEL" ]] || [[ -z "$P_EDUBAR_POS" ]]; do
+        # Get PID
+        P_EDUBAR_POS=$(ps aux | grep "le-edubar_position.sh" | awk '{print $2}')
+        P_EDUBAR=$(pgrep le-edubar)
+        P_GPANEL=$(pgrep gnome-panel)
+        sleep 1
+    done
+
+    # Disable Edubar and Panel
+    kill $P_EDUBAR
+    kill -stop $P_EDUBAR_POS $P_GPANEL
+}
+
+# Enable user interaction with gnome panel
+function enable_gnome() {
+    # Get PID
+    local P_EDUBAR_POS=$(ps aux | grep "le-edubar_position.sh" | awk '{print $2}')
+    local P_GPANEL=$(pgrep gnome-panel)
+
+    # Enable Edubar and Panel
+    # NOTE: le-edubar_position.sh will automatically open le-edubar
+    kill -cont $P_GPANEL $P_EDUBAR_POS
+}
+
 function call_dialog_inep_mult_on () {
-    #Disable mouse right-click
+    # Disable user interaction
     disable_mouse
+    disable_gnome
+
     dialog_inep.sh
-    #Get PID
-    P_EDUBAR=$(ps aux | grep $LE_EDUBAR_POS | tr -s -t " " "|" | cut -d"|" -f2)
-    P_GPANEL=$(pgrep gnome-panel)
-    #Enable Edubar and Panel
-    kill -cont $P_GPANEL
-    kill -cont $P_EDUBAR
-    #Enable mouse right-click
+
+    # Enable user interaction
+    enable_gnome
     enable_mouse
 }
 
diff --git a/le-proinfodata/package/usr/share/gnome/autostart/stop_screen.sh b/le-proinfodata/package/usr/share/gnome/autostart/stop_screen.sh
deleted file mode 100644
index 0e9c0c18..00000000
--- a/le-proinfodata/package/usr/share/gnome/autostart/stop_screen.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash
-# Copyright (C) 2004-2012 Centro de Computacao Cientifica e Software Livre
-# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
-#session-setup-script = exec_dialog.sh
-# 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_LOCK="/tmp/.dialog.lock"
-P_EDUBAR=$(ps aux | grep "/usr/share/gnome/autostart/le-edubar_position.sh" | tr -s -t " " "|" | cut -d"|" -f2)
-P_GPANEL=$(pgrep -u $USER gnome-panel)
-NUM=$(cat $F_LOCK)
-#Disable Edubar and Panel in Multiterminal
-if [ $NUM -eq 0 ]; then
-	kill -stop $P_EDUBAR
-	pkill le-edubar
-	kill -stop $P_GPANEL
-fi
-- 
GitLab