Initial import
[grml-quickconfig.git] / grml-quickconfig.8
1 .TH grml-quickconfig 8
2 .SH "NAME"
3 grml-quickconfig \- get fast access to some basic grml-scripts
4 .SH SYNOPSIS
5 .B grml-quickconfig [menudir]
6 .SH DESCRIPTION
7 This manual page documents briefly the
8 .B grml-quickconfig
9 command.
10 .SH OPTIONS
11 .TP
12 .B menudir
13 Directory to load the menu files from. Menu files have to end in *.sh.
14
15 If menudir is a directory files will be directly loaded from specified directory.
16 If it is not a directory it will be loaded from
17 .B /usr/share/grml-quickconfig/MENUDIR/
18 (if exists)
19
20 If no option is provided the bootparameter
21 .B menu
22 is used as directory
23 .SH NOTES
24 grml-quickconfig provides a console based interface to get fast
25 access to some basic grml-scripts like for example grml-network,
26 netcardconfig, grml-lang, grml-x and grml2hd.
27 .SH USAGE EXAMPLES
28 .TP
29 .B grml-quickconfig
30 Invoke the interface.
31 .TP
32 .B grml-quickconfig /opt/my_menu/
33 Invoke the interface and load all files ending in *.sh
34 .TP
35 .B grml-quickconfig network
36 Test if dir is a directory and load all files edning in *.sh from it. If dir is not a valid directory
37 .B /usr/share/grml-quickconfig/network/
38 is used.
39 .SH Writing own menu entries
40 A menu script is a shell script with some necessary informations described in this section.
41
42 .SS API
43 Following predefined functions are available to write a script displaying a menu entry:
44 .TP
45 .B print_line text
46 Print the text in one line inside the menu. Shell
47 .TP
48 .B print_starting_line
49 Print the first line for a menu
50 .TP
51 .B print_closing_line
52 Print the closing line for a menu
53 .TP
54 .B print_delim
55 Print a delimiter line for a menu
56 .TP
57 .B run COMMAND
58 Print command before executing it
59 .TP
60 .B get_key VARIABLE_NAME
61 Get one key from user
62 .TP
63 .B Example
64
65  # get user input
66    get_key INPUT
67    [ "$INPUT" == "c" ] && echo "C pressed"
68
69  # print && execute grml-lang de
70    run grml-lang de
71
72 .SS Predefined Variables
73 Following variables are predefined and could be used in a menu script:
74 .TP
75 .B NORMAL
76 Switch back to normal color
77 .TP
78 .B HILIGHT
79 Shall be used to hilight the used key for a menu
80 .TP
81 .B Example
82  print_line "Configure ${HILIGHT}n${NORMAL}etwork"
83 .SS MUST Provide
84 .TP
85 .B display_entry
86 A function named display_entry to determine if this entry shall be displayed.
87 .LP
88 .RS
89 .B Example
90 .LP
91 # Always display menu item
92   display_entry() { return 0 }
93
94 # Only display menu item if specified program is available
95   display_entry() {
96       . /etc/grml/script-functions
97       check4progs PROGRAM >/dev/null
98       return $?
99   }
100
101 .RE 1
102 .TP
103 .B LINE
104 A variable used to determine what shall be done to generate a menu entry. Typically
105 used in combination with print_line. Only used if display_entry returns 0.
106 .LP
107 .RS
108 .B \ Example
109  # print Configure network (grml-network)
110  LINE='print_line "Configure ${HILIGHT}n${NORMAL}etwork (${HILIGHT_NAME}grml-network${NORMAL})"'
111 .RE 1
112 .SS Optional entries
113 Following variables are optional and can be defined in a script but must not.
114 .TP
115 .B FUNCTION
116 A variable specifing the code which shall be executed if user selects this menu entry.
117 The variable $INPUT can be used to get the user input.
118 .RS
119 .B \ Example
120  # Print the key from the user
121  FUNCTION='echo $INPUT'
122
123  # create a submenu
124  submenu() { ... }
125  FUNCTION='submenu'
126 .RE 1
127
128 .TP
129 .B KEY, array
130 An array containig all possible keys for executing the code specified in the FUNCTION variable, e.g:
131 .RS
132  # execute code in FUNCTION if c, d or e is pressed.
133 KEY=(c d e)
134
135 .SS Complete Example
136  # language module for grml-quickconfig
137  LINE='print_line "Set keyboard layout (${HILIGHT_NAME}grml-lang${NORMAL}): \\
138  ${HILIGHT}d${NORMAL}e ${HILIGHT}a${NORMAL}t ${HILIGHT}c${NORMAL}h e${HILIGHT}s${NORMAL} ${HILIGHT}u${NORMAL}s"'
139
140  typeset -A lang_mapping
141
142  # map keys to language
143  lang_mapping=(
144      d de
145      a at
146      c ch
147      s es
148      u us
149  )
150
151  # get all keys from assoc array
152  KEY=(${(k)lang_mapping})
153
154  # $INPUT is the user input
155  FUNCTION='run grml-lang ${lang_mapping[$INPUT]}'
156
157  # always display entry
158  display_entry() {
159      return 0
160  }
161
162  ## END OF FILE ################################################################# 
163  # vim:foldmethod=marker expandtab ai ft=zsh shiftwidth=3
164
165
166 .SH AUTHOR
167 Current grml-quickconfig was written by the Grml Team <team@grml.org> and is based on the
168 idea of Michael Schierl.
169
170 The originaly grml-quickconfig was written by Michael Schierl <schierlm-public@gmx.de>.
171 .PP
172 This manual page was written by Michael Prokop
173 <mika@grml.org> for the grml project (but may be used by others).