tools: add enlightenment_input_key CLI tool for generating key event(s) 68/217068/2 accepted/tizen/unified/20191107.052013 submit/tizen_5.5/20191107.041841
authorSung-Jin Park <sj76.park@samsung.com>
Wed, 6 Nov 2019 05:13:58 +0000 (14:13 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Wed, 6 Nov 2019 05:19:59 +0000 (05:19 +0000)
Change-Id: I44ffbafd83f2bdb3e8dc82c4cc4c7ce8fafbaeab
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
data/tools/Makefile.mk
data/tools/enlightenment_input_key [new file with mode: 0644]
packaging/enlightenment.spec

index 60394ca..90e6d8a 100644 (file)
@@ -1,6 +1,8 @@
 enlightenment_remotedir = $(bindir)
-
 enlightenment_remote_SCRIPTS = data/tools/enlightenment_remote
-
 EXTRA_DIST += data/tools/enlightenment_remote
 
+enlightenment_input_keydir = $(bindir)
+enlightenment_input_key_SCRIPTS = data/tools/enlightenment_input_key
+EXTRA_DIST += data/tools/enlightenment_input_key
+
diff --git a/data/tools/enlightenment_input_key b/data/tools/enlightenment_input_key
new file mode 100644 (file)
index 0000000..78fddc7
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+set -e
+
+DBUS_SEND="/usr/bin/dbus-send"
+
+usage()
+{
+       echo "USAGE> input_keyevent {key name} {down | up}"
+       echo ""
+       echo "example>"
+       echo "  input_keyevent XF86Back"
+       echo "  -> Generate a 'down'+'up' event of XF86Back key"
+       echo "  input_keyevent XF86Back down"
+       echo "  -> Generate a 'down' event of XF86Back key
+       echo "  input_keyevent XF86Back up"
+       echo "  -> Generate a 'up' event of XF86Back key
+}
+
+failed_on_sending_dbus()
+{
+       echo "Failed on sending key generation request ! (key name : $1)"
+       exit 1
+}
+
+if [ $# -lt 1 ]; then
+       echo "Arguments are required."
+       usage
+       exit 1
+fi
+
+if [ $# -gt 2 ]; then
+       echo "Number of arguments are exceed."
+       usage
+       exit 1
+fi
+
+if [ ! -x ${DBUS_SEND} ]; then
+       echo "Tool doesn't exist or permission denied."
+       exit 1
+fi
+
+if [ "$#" = "1" ]; then
+       dbus-send --system --type=method_call --print-reply --dest=org.enlightenment.wm /org/enlightenment/wm org.enlightenment.wm.Test.EventKey uint32:1 string:"$1" > /dev/null || failed_on_sending_dbus $1
+       dbus-send --system --type=method_call --print-reply --dest=org.enlightenment.wm /org/enlightenment/wm org.enlightenment.wm.Test.EventKey uint32:0 string:"$1" > /dev/null || failed_on_sending_dbus $1
+else
+       if [ "$#" = "2" ]; then
+               case $2 in
+                       down)
+                               dbus-send --system --type=method_call --print-reply --dest=org.enlightenment.wm /org/enlightenment/wm org.enlightenment.wm.Test.EventKey uint32:1 string:"$1" > /dev/null || failed_on_sending_dbus $1
+                               ;;
+                       up)
+                               dbus-send --system --type=method_call --print-reply --dest=org.enlightenment.wm /org/enlightenment/wm org.enlightenment.wm.Test.EventKey uint32:0 string:"$1" > /dev/null || failed_on_sending_dbus $1
+                               ;;
+                       *)
+                               usage
+                               exit 1
+               esac
+
+       fi
+fi
index ecb8b1d..c5c1728 100644 (file)
@@ -90,6 +90,7 @@ make %{?_smp_mflags}
 %install
 %make_install
 ln -sf %{_bindir}/enlightenment_info %{buildroot}%{_bindir}/winfo
+ln -sf %{_bindir}/enlightenment_input_key %{buildroot}%{_bindir}/input_keyevent
 
 %files
 %manifest %{name}.manifest
@@ -97,6 +98,7 @@ ln -sf %{_bindir}/enlightenment_info %{buildroot}%{_bindir}/winfo
 %license COPYING
 %attr(550,root,root) %{_bindir}/enlightenment*
 %attr(550,root,root) %{_bindir}/winfo*
+%attr(550,root,root) %{_bindir}/input_keyevent*
 %{_libdir}/enlightenment/*
 %{_datadir}/enlightenment/*
 %exclude %{_bindir}/enlightenment_remote