Contents of /mcore-src/trunk/mcore-tools/src/modules/citrix/citrix-session.in
Parent Directory | Revision Log
Revision 2319 -
(show annotations)
(download)
Thu Jul 3 11:18:35 2014 UTC (10 years, 2 months ago) by niro
File size: 3271 byte(s)
Thu Jul 3 11:18:35 2014 UTC (10 years, 2 months ago) by niro
File size: 3271 byte(s)
-generate fluxbox menuentries with the citrix-session helper program if fluxbox was provided
1 | #!/bin/bash |
2 | |
3 | MCORE_LIBDIR="@@MCORE_LIBDIR@@" |
4 | source @@SYSCONFDIR@@/mcore/mcore.conf |
5 | source ${MCORE_LIBDIR}/include/common.global.class |
6 | |
7 | ICADIR="${MCORE_CONFIG_PATH}/citrix/ica" |
8 | ICASUFFIX="ica" |
9 | |
10 | die() { echo "ERROR: $@"; exit 1; } |
11 | |
12 | # very basic getops |
13 | for argv in $* |
14 | do |
15 | case $1 in |
16 | --add|--del|--print|--query) method="${1//--}" ;; |
17 | --name) shift; name="$1" ;; |
18 | --session) shift; session="$1" ;; |
19 | --mode) shift; mode="$1" ;; |
20 | --user) shift; user="$1" ;; |
21 | --domain) shift; domain="$1" ;; |
22 | --password) shift; password="$1" ;; |
23 | esac |
24 | shift |
25 | done |
26 | |
27 | [[ -n ${method} ]] || die "No method given" |
28 | |
29 | case "${method}" in |
30 | add) |
31 | # requires name |
32 | [[ -n ${name} ]] || die "No name given" |
33 | # action 'add' requires mode too |
34 | [[ -n ${mode} ]] || die "No mode given" |
35 | # and session |
36 | [[ -n ${session} ]] || die "No session given" |
37 | |
38 | # other sanity checks |
39 | case "${mode}" in |
40 | fullscreen) ;; |
41 | seamless) ;; |
42 | *x*) ;; |
43 | *) die "unknown mode '${mode}'" |
44 | esac |
45 | |
46 | icafile="${ICADIR}/${name}.${ICASUFFIX}" |
47 | CONFIG="${MROOT}/${icafile}" |
48 | clearconfig |
49 | |
50 | addconfig '[WFClient]' |
51 | addconfig 'Version=2' |
52 | |
53 | serverlist=$(NOCOLORS=true ${MCORE_LIBDIR}/citrix-serverlist --print) |
54 | declare -i i=0 |
55 | for server in ${serverlist} |
56 | do |
57 | (( i++ )) |
58 | server_num="${i}" |
59 | [[ ${i} -eq 1 ]] && server_num="" |
60 | addconfig "TcpBrowserAddress${server_num}=${server}" |
61 | done |
62 | addconfig 'ScreenPercent=0' |
63 | addconfig '[ApplicationServers]' |
64 | addconfig "${session}=" |
65 | addconfig "[${session}]" |
66 | addconfig "Address=${session}" |
67 | addconfig "InitialProgram=#${session}" |
68 | |
69 | # mapping table xorg -> citrix |
70 | # citrix 1 = 16 colors |
71 | # citrix 2 = 256 colors |
72 | # citrix 4 = 16 bit |
73 | # citrix 8 = 32 bit |
74 | # try always 16 bit |
75 | addconfig "DesiredColor=4" |
76 | |
77 | addconfig 'TransportDriver=TCP/IP' |
78 | addconfig 'WinStationDriver=ICA 3.0' |
79 | |
80 | [[ -n ${user} ]] && addconfig "Username=${user}" |
81 | [[ -n ${domain} ]] && addconfig "Domain=${domain}" |
82 | [[ -n ${password} ]] && addconfig "ClearPassword=${password}" |
83 | |
84 | # use the right display settings |
85 | case "${mode}" in |
86 | # fullscreen mode |
87 | fullscreen) |
88 | addconfig 'UseFullScreen=Yes' |
89 | addconfig 'NoWindowManager=True' |
90 | addconfig "DesiredHRES=65535" |
91 | addconfig "DesiredVRES=65535" |
92 | ;; |
93 | # seamless window mode |
94 | seamless) |
95 | addconfig 'TWIMode=On' |
96 | ;; |
97 | # a desired resolution |
98 | *x*) |
99 | addconfig "DesiredHRES=${mode%x*}" |
100 | addconfig "DesiredVRES=${mode#*x}" |
101 | ;; |
102 | esac |
103 | |
104 | if is_provided fluxbox |
105 | then |
106 | # generate fluxbox menu entry |
107 | ${MCORE_LIBDIR}/fluxbox-menuitem --add --name "${name}" --exec "wfica ${icafile}" && |
108 | ${MCORE_LIBDIR}/fluxbox-rebuild-menu |
109 | fi |
110 | ;; |
111 | |
112 | del) |
113 | [[ -n ${name} ]] || die "No name given" |
114 | if [ -f ${MROOT}/${ICADIR}/"${name}".${ICASUFFIX} ] |
115 | then |
116 | rm ${MROOT}/${ICADIR}/"${name}".${ICASUFFIX} |
117 | if is_provided fluxbox |
118 | then |
119 | ${MCORE_LIBDIR}/fluxbox-menuitem --del --name "${name}" && |
120 | ${MCORE_LIBDIR}/fluxbox-rebuild-menu |
121 | fi |
122 | else |
123 | eecho "No configured session named '${name}' exists." |
124 | fi |
125 | ;; |
126 | |
127 | print) |
128 | list_files_in_directory ${MROOT}/${ICADIR} |
129 | ;; |
130 | |
131 | query) |
132 | eval sessionlist=( $(${MCORE_LIBDIR}/query-citrix-browser --session) ) |
133 | sessioncount="${#sessionlist[*]}" |
134 | for (( i=0; i<sessioncount; i++)) |
135 | do |
136 | rvecho -n "${sessionlist[${i}]};" |
137 | done |
138 | rvecho |
139 | ;; |
140 | esac |