# $Id$ provide citrix ica # needs fluxbox! require fluxbox basic-video help_citrix_serverlist() { mecho "get citrix.serverlist" mecho " Shows all hosts added on the serverlist." mecho mecho "set citrix.serverlist [action] [host]" mecho " Adds or deletes a server from the ica serverlist." mecho " [actions]:" mecho " add - adds a server" mecho " del - deletes a server" mecho mecho " host - dns hostname or ip of the server" mecho mecho " If no [host] was given, all entries are deleted." } help_citrix_session() { mecho "get citrix.session" mecho " Shows all configured ICA sessions" mecho mecho "set citrix.session [action] [session] [mode] [user] [domain] [password]" mecho " Adds or delets a ICA session." mecho " Available actions:" mecho " add - adds a new ica session" mecho " del - deletes ica session with file name [file]" mecho " if no [file] given, all sessions will be deleted" mecho mecho " Available modes:" mecho " fullscreen - fullscreen session" mecho " seamless - seamless windows session" mecho " *x* - windowed session with given resolution" mecho " any resonable resolution is fine like:" mecho " 1024x768, 1280x1024, 1440x900 etc" mecho mecho " session - name of the Citrix session" mecho " user - user inside the session - optional" mecho " domain - logon domain of the user - optional" mecho " password - password of the user - optional" } set_citrix_session() { local action="$1" local session="$2" local mode="$3" local user="$4" local domain="$5" local password="$6" local serverlist local server local server_num local icafile local CONFIG local i [[ -z ${action} ]] && help_citrix_session && return 1 [[ -z ${session} ]] && help_citrix_session && return 1 case "${action}" in add) # action 'add' need mode too [[ -z ${mode} ]] && help_citrix_session && return 1 # other sanity checks case "${mode}" in fullscreen) ;; seamless) ;; *x*) ;; *) help_citrix_session && return 1 esac icafile="${MCORE_CONFIG_PATH}/citrix/ica/${session}.ica" CONFIG="${MROOT}/${icafile}" clearconfig addconfig '[WFClient]' addconfig 'Version=2' serverlist=$(NOCOLORS=true get_citrix_serverlist) declare -i i=0 for server in ${serverlist} do (( i++ )) server_num="${i}" [[ ${i} -eq 1 ]] && server_num="" addconfig "TcpBrowserAddress${server_num}=${server}" done addconfig 'ScreenPercent=0' addconfig '[ApplicationServers]' addconfig "${session}=" addconfig "[${session}]" addconfig "Address=${session}" addconfig "InitialProgram=#${session}" # mapping table xorg -> citrix # citrix 1 = 16 colors # citrix 2 = 256 colors # citrix 4 = 16 bit # citrix 8 = 32 bit # try always 16 bit addconfig "DesiredColor=4" addconfig 'TransportDriver=TCP/IP' addconfig 'WinStationDriver=ICA 3.0' [[ -n ${user} ]] && addconfig "Username=${user}" [[ -n ${domain} ]] && addconfig "Domain=${domain}" [[ -n ${password} ]] && addconfig "ClearPassword=${password}" # use the right display settings case "${mode}" in # fullscreen mode fullscreen) addconfig 'UseFullScreen=Yes' addconfig 'NoWindowManager=True' addconfig "DesiredHRES=65535" addconfig "DesiredVRES=65535" ;; # seamless window mode seamless) addconfig 'TWIMode=On' ;; # a desired resolution *x*) addconfig "DesiredHRES=${mode%x*}" addconfig "DesiredVRES=${mode#*x}" ;; esac # generate fluxbox menu entry set_fluxbox_menuitem add "${session}" "wfica ${icafile}" ;; del) if [[ -f ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica/${session}.ica ]] then rm ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica/"${session}".ica set_fluxbox_menuitem del "${session}" elif [[ -z ${file} ]] then # delete all items, needed to loop through every session # or we delete *all* fluxbox menuitem too for i in $(find ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica -type f) do rm ${i} set_fluxbox_menuitem del "$(basename ${i} .ica)" done fi ;; *) help_citrix_session && return 1 ;; esac } get_citrix_session() { list_files_in_directory ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica } set_citrix_serverlist() { local action="$1" local server="$2" local CONFIG [[ -z ${action} ]] && help_citrix_serverlist && return 1 case "${action}" in add) [[ -z ${server} ]] && help_citrix_serverlist && return 1 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist/${server}" clearconfig addconfig "${server}" ;; del) if [[ -f ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist/${server} ]] then rm ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist/"${server}" elif [[ -z ${server} ]] then # delete all items find ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist -type f | xargs --no-run-if-empty rm fi ;; *) help_citrix_serverlist && return 1 ;; esac } get_citrix_serverlist() { list_files_in_directory ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist }