Debian Codegraph @

scripts/fcitx-fbterm-helper

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!/bin/bash
2
3 function Usage()
4 {
5 echo -e "$0 - Fcitx Fbterm launch helper"
6 echo -e "\t-d [display number]\t\tspecify display number (For example 0)"
7 echo -e "\t-l\t\t\t\tLaunch Fcitx automatically"
8 echo -e "\t-h\t\t\t\tPrint this help"
9 }
10
11 LAUNCH=0
12 FCITX_RUN=0
13
14 if [ "x$SHELL" = "x" ]; then
15 echo "\$SHELL is not set"
16 fi
17
18 while getopts "d:lh" opt; do
19 case $opt in
20 d)
21 DISPLAY_NUM=$OPTARG
22 ;;
23 l)
24 LAUNCH=1
25 ;;
26 *)
27 Usage
28 exit 0
29 ;;
30 esac
31 done
32
33 if [ "x$DISPLAY_NUM" != "x" ]; then
34 export DISPLAY=":$DISPLAY_NUM"
35 fi
36
37 if [ "x$DISPLAY" != "x" ]; then
38 number=`echo $DISPLAY | sed 's|\:\([0-9]\+\)\(\..*\)\?|\1|g'`
39 if [ "x$number" == "x" ]; then
40 echo '$DISPLAY parse error'
41 exit 1
42 fi
43 echo "Your display number is $number"
44 else
45 number=0
46 fi
47
48 echo "Test whether fcitx is running correctly with dbus..."
49 fcitx-remote > /dev/null 2>&1
50
51 if [ $? == "1" ]; then
52 echo "Cannot communicate fcitx with DBus."
53 FCITX_RUN=0
54 else
55 echo "Fcitx is running correctly."
56 FCITX_RUN=1
57 fi
58
59 echo ''
60 echo '========================================================='
61
62 if [ "$FCITX_RUN" == "0" -a "$LAUNCH" == "1" ]; then
63 echo "Try launch fcitx..."
64 pgrep -u `whoami` '^fcitx$' > /dev/null 2>&1
65 if [ $? == "0" ]; then
66 echo "There is already a fcitx running, Fcitx cannot support multi instance currently"
67 exit 1
68 fi
69 echo "Launch Fcitx..."
70 fcitx -D > /dev/null 2>&1 &
71 fcitxpid=$!
72 FCITX_RUN=1
73 fi
74
75 if [ $FCITX_RUN == "1" ]; then
76 echo "Launch fbterm..."
77 fbterm -i fcitx-fbterm
78 if [ "$LAUNCH" == "1" ] ; then
79 if ! test -z "$fcitxpid" ; then
80 kill $fcitxpid
81 fi
82 fi
83 else
84 echo '========================================================='
85 echo 'Fcitx is not running, you may setup it mannually'
86 echo 'The easiest way is set $DISPLAY, start fcitx from X'
87 echo 'Then try this helper'
88 echo '========================================================='
89 fi