1#!/bin/sh 2#- 3# Copyright (c) 2012 Devin Teske 4# All Rights Reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# 15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE 17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# 27# $FreeBSD$ 28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_include $BSDCFG_SHARE/dialog.subr 34f_include $BSDCFG_SHARE/mustberoot.subr 35f_include $BSDCFG_SHARE/sysrc.subr 36 37BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console" 38f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 39 40ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) 41[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm" 42 43############################################################ FUNCTIONS 44 45# dialog_menu_main 46# 47# Display the dialog(1)-based application main menu. 48# 49dialog_menu_main() 50{ 51 local menu_list size 52 local hline="$hline_choose_a_font" 53 local prompt="$msg_font_menu_text" 54 55 menu_list=" 56 '1 $msg_none' '$msg_use_hardware_default_font' 57 '2 $msg_ibm_437' '$msg_ibm_437_desc' 58 '3 $msg_ibm_850' '$msg_ibm_850_desc' 59 '4 $msg_ibm_865' '$msg_ibm_865_desc' 60 '5 $msg_ibm_866' '$msg_ibm_866_desc' 61 '6 $msg_ibm_866u' '$msg_ibm_866u_desc' 62 '7 $msg_ibm_1251' '$msg_ibm_1251_desc' 63 '8 $msg_iso_8859_1' '$msg_iso_8859_1_desc' 64 '9 $msg_iso_8859_2' '$msg_iso_8859_2_desc' 65 'a $msg_iso_8859_4' '$msg_iso_8859_4_desc' 66 'b $msg_iso_8859_7' '$msg_iso_8859_7_desc' 67 'c $msg_iso_8859_8' '$msg_iso_8859_8_desc' 68 'd $msg_iso_8859_15' '$msg_iso_8859_15_desc' 69 'e $msg_swiss' '$msg_swiss_desc' 70 " # END-QUOTE 71 72 size=$( eval f_dialog_menu_size \ 73 \"\$DIALOG_TITLE\" \ 74 \"\$DIALOG_BACKTITLE\" \ 75 \"\$prompt\" \ 76 \"\$hline\" \ 77 $menu_list ) 78 79 local dialog_menu 80 dialog_menu=$( eval $DIALOG \ 81 --clear --title \"\$DIALOG_TITLE\" \ 82 --backtitle \"\$DIALOG_BACKTITLE\" \ 83 --hline \"\$hline\" \ 84 --ok-label \"\$msg_ok\" \ 85 --cancel-label \"\$msg_cancel\" \ 86 --menu \"\$prompt\" $size \ 87 $menu_list \ 88 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 89 ) 90 local retval=$? 91 setvar DIALOG_MENU_$$ "$dialog_menu" 92 return $retval 93} 94 95############################################################ MAIN 96 97# Incorporate rc-file if it exists 98[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc" 99 100# 101# Process command-line arguments 102# 103while getopts hSX flag; do 104 case "$flag" in 105 h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";; 106 esac 107done 108shift $(( $OPTIND - 1 )) 109 110# 111# Initialize 112# 113f_dialog_init 114f_dialog_title "$msg_system_console_font" 115f_dialog_backtitle "${ipgm:+bsdconfig }$pgm" 116f_mustberoot_init 117 118# 119# Launch application main menu 120# 121while :; do 122 dialog_menu_main 123 retval=$? 124 mtag=$( f_dialog_menutag ) 125 126 [ $retval -eq 0 ] || f_die 127 128 case "$mtag" in 129 "1 $msg_none") # Use hardware default font 130 f_sysrc_set font8x8 "NO" || f_die 131 f_sysrc_set font8x14 "NO" || f_die 132 f_sysrc_set font8x16 "NO" || f_die 133 break ;; 134 "2 $msg_ibm_437") # English and others, VGA default 135 f_sysrc_set font8x8 "cp437-8x8" || f_die 136 f_sysrc_set font8x14 "cp437-8x14" || f_die 137 f_sysrc_set font8x16 "cp437-8x16" || f_die 138 break ;; 139 "3 $msg_ibm_850") # Western Europe, IBM encoding 140 f_sysrc_set font8x8 "cp850-8x8" || f_die 141 f_sysrc_set font8x14 "cp850-8x14" || f_die 142 f_sysrc_set font8x16 "cp850-8x16" || f_die 143 break ;; 144 "4 $msg_ibm_865") # Norwegian, IBM encoding 145 f_sysrc_set font8x8 "cp865-8x8" || f_die 146 f_sysrc_set font8x14 "cp865-8x14" || f_die 147 f_sysrc_set font8x16 "cp865-8x16" || f_die 148 break ;; 149 "5 $msg_ibm_866") # Russian, IBM encoding (use with KOI8-R screenmap) 150 f_sysrc_set font8x8 "cp866-8x8" || f_die 151 f_sysrc_set font8x14 "cp866-8x14" || f_die 152 f_sysrc_set font8x16 "cp866b-8x16" || f_die 153 f_sysrc_set mousechar_start 3 || f_die 154 break ;; 155 "6 $msg_ibm_866u") # Ukrainian, IBM encoding (use w/ KOI8-U screenmap) 156 f_sysrc_set font8x8 "cp866u-8x8" || f_die 157 f_sysrc_set font8x14 "cp866u-8x14" || f_die 158 f_sysrc_set font8x16 "cp866u-8x16" || f_die 159 f_sysrc_set mousechar_start 3 || f_die 160 break ;; 161 "7 $msg_ibm_1251") # Cyrillic, MS Windows encoding 162 f_sysrc_set font8x8 "cp1251-8x8" || f_die 163 f_sysrc_set font8x14 "cp1251-8x14" || f_die 164 f_sysrc_set font8x16 "cp1251-8x16" || f_die 165 f_sysrc_set mousechar_start 3 || f_die 166 break ;; 167 "8 $msg_iso_8859_1") # Western Europe, ISO encoding 168 f_sysrc_set font8x8 "iso-8x8" || f_die 169 f_sysrc_set font8x14 "iso-8x14" || f_die 170 f_sysrc_set font8x16 "iso-8x16" || f_die 171 break ;; 172 "9 $msg_iso_8859_2") # Eastern Europe, ISO encoding 173 f_sysrc_set font8x8 "iso02-8x8" || f_die 174 f_sysrc_set font8x14 "iso02-8x14" || f_die 175 f_sysrc_set font8x16 "iso02-8x16" || f_die 176 break ;; 177 "a $msg_iso_8859_4") # Baltic, ISO encoding 178 f_sysrc_set font8x8 "iso04-8x8" || f_die 179 f_sysrc_set font8x14 "iso04-8x14" || f_die 180 f_sysrc_set font8x16 "iso04-8x16" || f_die 181 break ;; 182 "b $msg_iso_8859_7") # Greek, ISO encoding 183 f_sysrc_set font8x8 "iso07-8x8" || f_die 184 f_sysrc_set font8x14 "iso07-8x14" || f_die 185 f_sysrc_set font8x16 "iso07-8x16" || f_die 186 break ;; 187 "c $msg_iso_8859_8") # Hebrew, ISO encoding 188 f_sysrc_set font8x8 "iso08-8x8" || f_die 189 f_sysrc_set font8x14 "iso08-8x14" || f_die 190 f_sysrc_set font8x16 "iso08-8x16" || f_die 191 break ;; 192 "d $msg_iso_8859_15") # Europe, ISO encoding 193 f_sysrc_set font8x8 "iso15-8x8" || f_die 194 f_sysrc_set font8x14 "iso15-8x14" || f_die 195 f_sysrc_set font8x16 "iso15-8x16" || f_die 196 break ;; 197 "e $msg_swiss") # English, better resolution 198 f_sysrc_set font8x8 "swiss-8x8" || f_die 199 f_sysrc_set font8x14 "NO" || f_die 200 f_sysrc_set font8x16 "swiss-8x16" || f_die 201 break ;; 202 esac 203 204done 205 206exit $SUCCESS 207 208################################################################################ 209# END 210################################################################################ 211