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