1252995Sdteske#!/bin/sh 2252995Sdteske#- 3252995Sdteske# Copyright (c) 2012-2013 Devin Teske 4252995Sdteske# All rights reserved. 5252995Sdteske# 6252995Sdteske# Redistribution and use in source and binary forms, with or without 7252995Sdteske# modification, are permitted provided that the following conditions 8252995Sdteske# are met: 9252995Sdteske# 1. Redistributions of source code must retain the above copyright 10252995Sdteske# notice, this list of conditions and the following disclaimer. 11252995Sdteske# 2. Redistributions in binary form must reproduce the above copyright 12252995Sdteske# notice, this list of conditions and the following disclaimer in the 13252995Sdteske# documentation and/or other materials provided with the distribution. 14252995Sdteske# 15252995Sdteske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16252995Sdteske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17252995Sdteske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18252995Sdteske# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19252995Sdteske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20252995Sdteske# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21252995Sdteske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22252995Sdteske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23252995Sdteske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24252995Sdteske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25252995Sdteske# SUCH DAMAGE. 26252995Sdteske# 27252995Sdteske# $FreeBSD$ 28252995Sdteske# 29252995Sdteske############################################################ INCLUDES 30252995Sdteske 31252995SdteskeBSDCFG_SHARE="/usr/share/bsdconfig" 32252995Sdteske. $BSDCFG_SHARE/common.subr || exit 1 33252995Sdteskef_dprintf "%s: loading includes..." "$0" 34252995Sdteskef_include $BSDCFG_SHARE/dialog.subr 35252995Sdteskef_include $BSDCFG_SHARE/mustberoot.subr 36252995Sdteske 37252995SdteskeBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse" 38252995Sdteskef_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 39252995Sdteske 40263791Sdteskef_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm && 41263791Sdteske pgm="${ipgm:-$pgm}" 42252995Sdteske 43252995Sdteske############################################################ FUNCTIONS 44252995Sdteske 45252995Sdteske# dialog_menu_main 46252995Sdteske# 47252995Sdteske# Display the dialog(1)-based application main menu. 48252995Sdteske# 49252995Sdteskedialog_menu_main() 50252995Sdteske{ 51252995Sdteske local prompt="$msg_menu_text" 52252995Sdteske local menu_list=" 53252995Sdteske 'X $msg_exit' '$msg_exit_this_menu' 54252995Sdteske '2 $msg_enable' '$msg_test_and_run_the_mouse_daemon' 55252995Sdteske '3 $msg_type' '$msg_select_mouse_protocol_type' 56252995Sdteske '4 $msg_port' '$msg_select_mouse_port' 57252995Sdteske '5 $msg_flags' '$msg_set_additional_flags' 58252995Sdteske '6 $msg_disable' '$msg_disable_the_mouse_daemon' 59252995Sdteske " # END-QUOTE 60252995Sdteske local defaultitem= # Calculated below 61252995Sdteske local hline= 62252995Sdteske 63252995Sdteske local height width rows 64252995Sdteske eval f_dialog_menu_size height width rows \ 65252995Sdteske \"\$DIALOG_TITLE\" \ 66252995Sdteske \"\$DIALOG_BACKTITLE\" \ 67252995Sdteske \"\$prompt\" \ 68252995Sdteske \"\$hline\" \ 69252995Sdteske $menu_list 70252995Sdteske 71252995Sdteske # Obtain default-item from previously stored selection 72252995Sdteske f_dialog_default_fetch defaultitem 73252995Sdteske 74252995Sdteske local menu_choice 75252995Sdteske menu_choice=$( eval $DIALOG \ 76252995Sdteske --title \"\$DIALOG_TITLE\" \ 77252995Sdteske --backtitle \"\$DIALOG_BACKTITLE\" \ 78252995Sdteske --hline \"\$hline\" \ 79252995Sdteske --ok-label \"\$msg_ok\" \ 80252995Sdteske --cancel-label \"\$msg_cancel\" \ 81252995Sdteske --default-item \"\$defaultitem\" \ 82252995Sdteske --menu \"\$prompt\" \ 83252995Sdteske $height $width $rows \ 84252995Sdteske $menu_list \ 85252995Sdteske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 86252995Sdteske ) 87252995Sdteske local retval=$? 88252995Sdteske f_dialog_data_sanitize menu_choice 89252995Sdteske f_dialog_menutag_store "$menu_choice" 90252995Sdteske f_dialog_default_store "$menu_choice" 91252995Sdteske return $retval 92252995Sdteske} 93252995Sdteske 94252995Sdteske############################################################ MAIN 95252995Sdteske 96252995Sdteske# Incorporate rc-file if it exists 97252995Sdteske[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc" 98252995Sdteske 99252995Sdteske# 100252995Sdteske# Process command-line arguments 101252995Sdteske# 102252995Sdteskewhile getopts h$GETOPTS_STDARGS flag; do 103252995Sdteske case "$flag" in 104252995Sdteske h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm" ;; 105252995Sdteske esac 106252995Sdteskedone 107252995Sdteskeshift $(( $OPTIND - 1 )) 108252995Sdteske 109252995Sdteske# 110252995Sdteske# Initialize 111252995Sdteske# 112252995Sdteskef_dialog_title "$msg_please_configure_your_mouse" 113252995Sdteskef_dialog_backtitle "${ipgm:+bsdconfig }$pgm" 114252995Sdteskef_mustberoot_init 115252995Sdteske 116252995Sdteske# 117252995Sdteske# Launch application main menu 118252995Sdteske# 119252995Sdteskewhile :; do 120252995Sdteske dialog_menu_main || f_die 121252995Sdteske f_dialog_menutag_fetch mtag 122252995Sdteske 123252995Sdteske command= 124252995Sdteske case "$mtag" in 125252995Sdteske "X $msg_exit") break ;; 126252995Sdteske "2 $msg_enable") command=enable ;; # Test and run the mouse daemon 127252995Sdteske "3 $msg_type") command=type ;; # Select mouse protocol type 128252995Sdteske "4 $msg_port") command=port ;; # Select mouse port 129252995Sdteske "5 $msg_flags") command=flags ;; # Set additional flags 130252995Sdteske "6 $msg_disable") command=disable ;; # Disable the mouse daemon 131252995Sdteske esac 132252995Sdteske 133252995Sdteske if [ "$command" ]; then 134252995Sdteske $BSDCFG_LIBE/$APP_DIR/$command ${USE_XDIALOG:+-X} 135252995Sdteske else 136252995Sdteske f_die 1 "$msg_unknown_mouse_menu_selection" 137252995Sdteske fi 138252995Sdteskedone 139252995Sdteske 140252995Sdteskeexit $SUCCESS 141252995Sdteske 142252995Sdteske################################################################################ 143252995Sdteske# END 144252995Sdteske################################################################################ 145