port revision 249746
1272343Sngie#!/bin/sh 2272343Sngie#- 3272343Sngie# Copyright (c) 2012-2013 Devin Teske 4272343Sngie# All Rights Reserved. 5272343Sngie# 6272343Sngie# Redistribution and use in source and binary forms, with or without 7272343Sngie# modification, are permitted provided that the following conditions 8272343Sngie# are met: 9272343Sngie# 1. Redistributions of source code must retain the above copyright 10272343Sngie# notice, this list of conditions and the following disclaimer. 11272343Sngie# 2. Redistributions in binary form must reproduce the above copyright 12272343Sngie# notice, this list of conditions and the following disclaimer in the 13272343Sngie# documentation and/or other materials provided with the distribution. 14272343Sngie# 15272343Sngie# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16272343Sngie# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE 17272343Sngie# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18272343Sngie# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19272343Sngie# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20272343Sngie# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21272343Sngie# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22272343Sngie# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23272343Sngie# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24272343Sngie# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25272343Sngie# SUCH DAMAGE. 26272343Sngie# 27272343Sngie# $FreeBSD: head/usr.sbin/bsdconfig/mouse/port 249746 2013-04-22 05:02:34Z dteske $ 28272343Sngie# 29272343Sngie############################################################ INCLUDES 30272343Sngie 31272343SngieBSDCFG_SHARE="/usr/share/bsdconfig" 32272343Sngie. $BSDCFG_SHARE/common.subr || exit 1 33272343Sngief_dprintf "%s: loading includes..." "$0" 34272343Sngief_include $BSDCFG_SHARE/dialog.subr 35272343Sngief_include $BSDCFG_SHARE/mustberoot.subr 36272343Sngief_include $BSDCFG_SHARE/sysrc.subr 37272343Sngie 38272343SngieBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse" 39272343Sngief_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 40272343Sngie 41272343Sngieipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) 42272343Sngie[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm" 43272343Sngie 44272343Sngie############################################################ FUNCTIONS 45272343Sngie 46272343Sngie# dialog_menu_main 47272343Sngie# 48272343Sngie# Display the dialog(1)-based application main menu. 49272343Sngie# 50272343Sngiedialog_menu_main() 51272343Sngie{ 52272343Sngie local menu_list size 53272343Sngie local hline="" 54272343Sngie local prompt="$msg_port_menu_text" 55272343Sngie 56272343Sngie menu_list=" 57272343Sngie '1 $msg_ps2' '$msg_ps2_desc' 58272343Sngie '2 $msg_com1' '$msg_com1_desc' 59272343Sngie '3 $msg_com2' '$msg_com2_desc' 60272343Sngie '4 $msg_com3' '$msg_com3_desc' 61272343Sngie '5 $msg_com4' '$msg_com4_desc' 62272343Sngie '6 $msg_busmouse' '$msg_busmouse_desc' 63272343Sngie " # END-QUOTE 64272343Sngie 65272343Sngie size=$( eval f_dialog_menu_size \ 66272343Sngie \"\$DIALOG_TITLE\" \ 67272343Sngie \"\$DIALOG_BACKTITLE\" \ 68272343Sngie \"\$prompt\" \ 69272343Sngie \"\$hline\" \ 70272343Sngie $menu_list ) 71272343Sngie 72272343Sngie local dialog_menu 73272343Sngie dialog_menu=$( eval $DIALOG \ 74272343Sngie --clear --title \"\$DIALOG_TITLE\" \ 75272343Sngie --backtitle \"\$DIALOG_BACKTITLE\" \ 76272343Sngie --hline \"\$hline\" \ 77272343Sngie --ok-label \"\$msg_ok\" \ 78272343Sngie --cancel-label \"\$msg_cancel\" \ 79272343Sngie --menu \"\$prompt\" $size \ 80272343Sngie $menu_list \ 81272343Sngie 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 82272343Sngie ) 83272343Sngie local retval=$? 84272343Sngie setvar DIALOG_MENU_$$ "$dialog_menu" 85272343Sngie return $retval 86272343Sngie} 87272343Sngie 88272343Sngie############################################################ MAIN 89272343Sngie 90272343Sngie# Incorporate rc-file if it exists 91272343Sngie[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc" 92272343Sngie 93272343Sngie# 94272343Sngie# Process command-line arguments 95272343Sngie# 96272343Sngiewhile getopts dD:hSX flag; do 97272343Sngie case "$flag" in 98 h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";; 99 esac 100done 101shift $(( $OPTIND - 1 )) 102 103# 104# Initialize 105# 106f_dialog_title "$msg_select_your_mouse_port_from_the_following_menu" 107f_dialog_backtitle "${ipgm:+bsdconfig }$pgm" 108f_mustberoot_init 109 110# 111# Launch application main menu 112# 113while :; do 114 dialog_menu_main 115 retval=$? 116 mtag=$( f_dialog_menutag ) 117 118 [ $retval -eq 0 ] || f_die 119 120 case "$mtag" in 121 "1 $msg_ps2") # PS/2 style mouse (/dev/psm0) 122 f_sysrc_set moused_port "/dev/psm0" || f_die 123 break ;; 124 "2 $msg_com1") # Serial mouse on COM1 (/dev/cuau0) 125 f_sysrc_set moused_port "/dev/cuau0" || f_die 126 break ;; 127 "3 $msg_com2") # Serial mouse on COM2 (/dev/cuau1) 128 f_sysrc_set moused_port "/dev/cuau1" || f_die 129 break ;; 130 "4 $msg_com3") # Serial mouse on COM3 (/dev/cuau2) 131 f_sysrc_set moused_port "/dev/cuau2" || f_die 132 break ;; 133 "5 $msg_com4") # Serial mouse on COM4 (/dev/cuau3) 134 f_sysrc_set moused_port "/dev/cuau3" || f_die 135 break ;; 136 "6 $msg_busmouse") # Logitech, ATI or MS bus mouse (/dev/mse0) 137 f_sysrc_set moused_port "/dev/mse0" || f_die 138 break ;; 139 esac 140 141done 142 143exit $SUCCESS 144 145################################################################################ 146# END 147################################################################################ 148