slitaz-tools view tinyutils/tazkeymap @ rev 813

Current state, features stabilized and open for bugfixes and translations.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Sep 09 03:27:04 2013 +0300 (2013-09-09)
parents 494b03aad433
children c79e656b37a5
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-2013 SliTaz GNU/Linux - BSD License
7 #
8 # Author: Christophe Lincoln <pankso@slitaz.org>
9 #
10 . /lib/libtaz.sh
11 export TEXTDOMAIN='slitaz-tools' #i18n
13 # List all keymaps.
14 list_keymaps() {
15 cd /usr/share/kbd/keymaps/i386
16 # We first need a list to sort and then use \n for Yad list.
17 for i in $(find *rty *rtz dvorak -name *.map.gz); do
18 keymap=$(basename $i)
19 type=$(dirname $i)
20 echo "${keymap%.map.gz} $type"
21 done
22 }
24 # Load the selected kmap file from /usr/share/kbd/keymaps or Busybox kmaps.
25 load_keymap() {
26 if [ -x /bin/loadkeys ]; then
27 loadkeys $kmap
28 else
29 loadkmap < /usr/share/kmap/$kmap.kmap
30 fi
31 }
33 # Config /etc/keymap.conf
34 system_config() {
35 #gettext "Setting system keymap to:"; echo -n " $kmap"
36 echo "$kmap" > /etc/keymap.conf
37 #status
38 }
40 case "$1" in
41 info)
42 _n 'Config file:'; echo " /etc/keymap.conf"
43 _n 'Current keymap:'; echo " $(cat /etc/keymap.conf)" ;;
44 list)
45 list_keymaps | sort ;;
46 "")
47 # Default to text mode dialog.
48 : ${DIALOG=dialog}
49 check_root
50 exec 3>&1
51 value=$($DIALOG --clear \
52 --title " $(_n 'SliTaz keymap configuration') " \
53 --menu "" 15 70 5 \
54 $(list_keymaps | sort) \
55 2>&1 1>&3)
56 retval=$?
57 exec 3>&-
58 case $retval in
59 0) continue ;;
60 1|255) exit 0 ;;
61 esac
62 # If it's a reconfiguration give an info message.
63 if [ -s /etc/keymap.conf ]; then
64 $DIALOG --clear --title " $(_n 'Information') " \
65 --msgbox "$(_n 'Please logout of your current session and login again to use new keyboard.')" 16 70
66 fi
67 kmap=$value
68 system_config
69 load_keymap ;;
70 *)
71 # Used to configure keymap from cmdline or scripts
72 kmap=$1
73 check_root
74 system_config
75 load_keymap ;;
76 esac
78 exit 0