slitaz-tools view tinyutils/tazkeymap @ rev 753

Add info cmd to tazlocale and let users see configs)
author Christophe Lincoln <pankso@slitaz.org>
date Mon Apr 30 14:12:13 2012 +0200 (2012-04-30)
parents f73c8f4bb66c
children e232f0e1413a
line source
1 #!/bin/sh
2 #
3 # Tazkeymap - SliTaz GNU/Linux keymap config using loadkeys and dialog boxes.
4 # Configuration file is: /etc/keymap.conf
5 #
6 # Copyright (C) 2008-2012 SliTaz GNU/Linux - BSD License
7 #
8 # Author: Christophe Lincoln <pankso@slitaz.org>
9 #
10 . /lib/libtaz.sh
12 # Internationalization
13 . /usr/bin/gettext.sh
14 TEXTDOMAIN='slitaz-tools'
15 export TEXTDOMAIN
17 # List all keymaps.
18 list_keymaps() {
19 cd /usr/share/kbd/keymaps/i386
20 # We first need a list to sort and then use \n for Yad list.
21 for i in $(find *rty *rtz dvorak -name *.map.gz)
22 do
23 keymap=$(basename $i)
24 type=$(dirname $i)
25 echo "${keymap%.map.gz} $type"
26 done
27 }
29 # Load the selected kmap file from /usr/share/kbd/keymaps or Busybox kmaps.
30 load_keymap() {
31 if [ -x /bin/loadkeys ]; then
32 loadkeys $kmap
33 else
34 loadkmap < /usr/share/kmap/$kmap.kmap
35 fi
36 }
38 # Config /etc/keymap.conf
39 system_config() {
40 #gettext "Setting system keymap to:"; echo -n " $kmap"
41 echo "$kmap" > /etc/keymap.conf
42 #status
43 }
45 case "$1" in
46 info)
47 gettext "Config file :"; echo " /etc/keymap.conf"
48 gettext "Current keymap:"; echo " $(cat /etc/keymap.conf)" ;;
49 list)
50 list_keymaps | sort ;;
51 "")
52 # Default to text mode dialog.
53 : ${DIALOG=dialog}
54 check_root
55 exec 3>&1
56 value=$($DIALOG --clear \
57 --title " $(gettext "SliTaz keymap configuration") " \
58 --menu "" 15 70 5 \
59 $(list_keymaps | sort) \
60 2>&1 1>&3)
61 retval=$?
62 exec 3>&-
63 case $retval in
64 0) continue ;;
65 1|255) exit 0 ;;
66 esac
67 # If it's a reconfiguration give an info message.
68 if [ -s /etc/keymap.conf ]; then
69 msg=$(gettext "\
70 Please logout of your current session and login again to use new keyboard.")
71 $DIALOG --clear --title " Information " --msgbox "$msg" 16 70
72 fi
73 kmap=$value
74 system_config
75 load_keymap ;;
76 *)
77 # Used to configure keymap from cmdline or scripts
78 kmap=$1
79 check_root
80 system_config
81 load_keymap ;;
82 esac
84 exit 0