1238438Sdteske#!/bin/sh 2238438Sdteske#- 3249746Sdteske# Copyright (c) 2012-2013 Devin Teske 4252980Sdteske# All rights reserved. 5238438Sdteske# 6238438Sdteske# Redistribution and use in source and binary forms, with or without 7238438Sdteske# modification, are permitted provided that the following conditions 8238438Sdteske# are met: 9238438Sdteske# 1. Redistributions of source code must retain the above copyright 10238438Sdteske# notice, this list of conditions and the following disclaimer. 11238438Sdteske# 2. Redistributions in binary form must reproduce the above copyright 12238438Sdteske# notice, this list of conditions and the following disclaimer in the 13238438Sdteske# documentation and/or other materials provided with the distribution. 14238438Sdteske# 15238438Sdteske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16252987Sdteske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17238438Sdteske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18238438Sdteske# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19238438Sdteske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20252987Sdteske# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21238438Sdteske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22238438Sdteske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23238438Sdteske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24238438Sdteske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25238438Sdteske# SUCH DAMAGE. 26238438Sdteske# 27238438Sdteske# $FreeBSD: releng/11.0/usr.sbin/bsdconfig/mouse/port 259054 2013-12-07 00:31:01Z dteske $ 28238438Sdteske# 29238438Sdteske############################################################ INCLUDES 30238438Sdteske 31240684SdteskeBSDCFG_SHARE="/usr/share/bsdconfig" 32240684Sdteske. $BSDCFG_SHARE/common.subr || exit 1 33244675Sdteskef_dprintf "%s: loading includes..." "$0" 34240684Sdteskef_include $BSDCFG_SHARE/dialog.subr 35240684Sdteskef_include $BSDCFG_SHARE/mustberoot.subr 36240684Sdteskef_include $BSDCFG_SHARE/sysrc.subr 37238438Sdteske 38240684SdteskeBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse" 39238438Sdteskef_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 40238438Sdteske 41259054Sdteskef_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm && 42259054Sdteske pgm="${ipgm:-$pgm}" 43238438Sdteske 44238438Sdteske############################################################ FUNCTIONS 45238438Sdteske 46238438Sdteske# dialog_menu_main 47238438Sdteske# 48238438Sdteske# Display the dialog(1)-based application main menu. 49238438Sdteske# 50238438Sdteskedialog_menu_main() 51238438Sdteske{ 52238438Sdteske local prompt="$msg_port_menu_text" 53251264Sdteske local menu_list=" 54238438Sdteske '1 $msg_ps2' '$msg_ps2_desc' 55238438Sdteske '2 $msg_com1' '$msg_com1_desc' 56238438Sdteske '3 $msg_com2' '$msg_com2_desc' 57238438Sdteske '4 $msg_com3' '$msg_com3_desc' 58238438Sdteske '5 $msg_com4' '$msg_com4_desc' 59238438Sdteske '6 $msg_busmouse' '$msg_busmouse_desc' 60238438Sdteske " # END-QUOTE 61251264Sdteske local defaultitem= # Calculated below 62251264Sdteske local hline= 63238438Sdteske 64251190Sdteske local height width rows 65251190Sdteske eval f_dialog_menu_size height width rows \ 66251190Sdteske \"\$DIALOG_TITLE\" \ 67251190Sdteske \"\$DIALOG_BACKTITLE\" \ 68251190Sdteske \"\$prompt\" \ 69251190Sdteske \"\$hline\" \ 70251190Sdteske $menu_list 71238438Sdteske 72249751Sdteske case "$( f_sysrc_get moused_port )" in 73249751Sdteske /dev/psm0) defaultitem="1 $msg_ps2" ;; 74249751Sdteske /dev/cuau0) defaultitem="2 $msg_com1" ;; 75249751Sdteske /dev/cuau1) defaultitem="3 $msg_com2" ;; 76249751Sdteske /dev/cuau2) defaultitem="4 $msg_com3" ;; 77249751Sdteske /dev/cuau3) defaultitem="5 $msg_com4" ;; 78249751Sdteske /dev/mse0) defaultitem="6 $msg_busmouse" ;; 79249751Sdteske esac 80249751Sdteske 81251236Sdteske local menu_choice 82251236Sdteske menu_choice=$( eval $DIALOG \ 83249751Sdteske --title \"\$DIALOG_TITLE\" \ 84238438Sdteske --backtitle \"\$DIALOG_BACKTITLE\" \ 85238438Sdteske --hline \"\$hline\" \ 86238438Sdteske --ok-label \"\$msg_ok\" \ 87238438Sdteske --cancel-label \"\$msg_cancel\" \ 88249751Sdteske --default-item \"\$defaultitem\" \ 89251190Sdteske --menu \"\$prompt\" \ 90251190Sdteske $height $width $rows \ 91238438Sdteske $menu_list \ 92240768Sdteske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 93240768Sdteske ) 94240768Sdteske local retval=$? 95251236Sdteske f_dialog_menutag_store -s "$menu_choice" 96240768Sdteske return $retval 97238438Sdteske} 98238438Sdteske 99238438Sdteske############################################################ MAIN 100238438Sdteske 101238438Sdteske# Incorporate rc-file if it exists 102238438Sdteske[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc" 103238438Sdteske 104238438Sdteske# 105238438Sdteske# Process command-line arguments 106238438Sdteske# 107250633Sdteskewhile getopts h$GETOPTS_STDARGS flag; do 108238438Sdteske case "$flag" in 109252178Sdteske h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm" ;; 110238438Sdteske esac 111238438Sdteskedone 112238438Sdteskeshift $(( $OPTIND - 1 )) 113238438Sdteske 114238438Sdteske# 115238438Sdteske# Initialize 116238438Sdteske# 117238438Sdteskef_dialog_title "$msg_select_your_mouse_port_from_the_following_menu" 118238438Sdteskef_dialog_backtitle "${ipgm:+bsdconfig }$pgm" 119238438Sdteskef_mustberoot_init 120238438Sdteske 121238438Sdteske# 122238438Sdteske# Launch application main menu 123238438Sdteske# 124251915Sdteskedialog_menu_main || f_die 125251915Sdteskef_dialog_menutag_fetch mtag 126238438Sdteske 127251915Sdteskemoused_port_to_set= 128251915Sdteskecase "$mtag" in 129251915Sdteske"1 $msg_ps2") # PS/2 style mouse (/dev/psm0) 130251915Sdteske moused_port_to_set="/dev/psm0" ;; 131251915Sdteske"2 $msg_com1") # Serial mouse on COM1 (/dev/cuau0) 132251915Sdteske moused_port_to_set="/dev/cuau0" ;; 133251915Sdteske"3 $msg_com2") # Serial mouse on COM2 (/dev/cuau1) 134251915Sdteske moused_port_to_set="/dev/cuau1" ;; 135251915Sdteske"4 $msg_com3") # Serial mouse on COM3 (/dev/cuau2) 136251915Sdteske moused_port_to_set="/dev/cuau2" ;; 137251915Sdteske"5 $msg_com4") # Serial mouse on COM4 (/dev/cuau3) 138251915Sdteske moused_port_to_set="/dev/cuau3" ;; 139251915Sdteske"6 $msg_busmouse") # Logitech, ATI or MS bus mouse (/dev/mse0) 140251915Sdteske moused_port_to_set="/dev/mse0" ;; 141251915Sdteskeesac 142238438Sdteske 143251915Sdteskeif [ "$moused_port_to_set" ]; then 144259054Sdteske f_eval_catch "$0" f_sysrc_set \ 145259054Sdteske 'f_sysrc_set moused_port "%s"' "$moused_port_to_set" || f_die 146251915Sdteskeelse 147251915Sdteske f_die 1 "$msg_unknown_mouse_port_selection" 148251915Sdteskefi 149251915Sdteske 150238438Sdteskeexit $SUCCESS 151238438Sdteske 152238438Sdteske################################################################################ 153238438Sdteske# END 154238438Sdteske################################################################################ 155