slitaz-tools view tinyutils/tazkeymap @ rev 938

tazbox tz: freegeoip.net not uses quotes in the CSV response anymore.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Apr 11 16:46:26 2015 +0300 (2015-04-11)
parents 3dd4838c69c6
children 5d80f6fdbdb7
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-2014 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 and update Xorg keyboard config
34 system_config() {
35 echo "$kmap" > /etc/keymap.conf
36 tazx keyboard
37 }
39 case "$1" in
40 info)
41 _n 'Config file:'; echo " /etc/keymap.conf"
42 _n 'Current keymap:'; echo " $(cat /etc/keymap.conf)" ;;
43 list)
44 list_keymaps | sort ;;
45 "")
46 # Default to text mode dialog.
47 : ${DIALOG=dialog --timeout 60}
48 check_root
49 exec 3>&1
50 value=$($DIALOG --clear \
51 --title "{ $(_n 'SliTaz keyboard setting') }" \
52 --menu "" 20 72 14 \
53 $(list_keymaps | sort) \
54 2>&1 1>&3)
55 retval=$?
56 exec 3>&-
57 case $retval in
58 0) continue ;;
59 1|255) exit 0 ;;
60 esac
61 # If it's a reconfiguration give an info message.
62 if [ -s /etc/keymap.conf ]; then
63 $DIALOG --clear --title " $(_n 'Information') " \
64 --msgbox "$(_n 'Please logout of your current session and login again to use new keyboard.')" 16 70
65 fi
66 kmap=$value
67 system_config
68 load_keymap ;;
69 *)
70 # Used to configure keymap from cmdline or scripts
71 kmap=$1
72 check_root
73 system_config
74 load_keymap ;;
75 esac
77 exit 0