slitaz-tools view tinyutils/tazkeymap @ rev 1011
Add sdt SliTaz Distro Tracker
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat Feb 11 23:41:23 2017 +0100 (2017-02-11) |
parents | 3be081525506 |
children |
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-2015 SliTaz GNU/Linux - BSD License
7 #
8 # Author: Christophe Lincoln <pankso@slitaz.org>
9 #
11 . /lib/libtaz.sh
12 export TEXTDOMAIN='slitaz-tools' #i18n
15 # List all keymaps.
17 list_keymaps() {
18 cd /usr/share/kbd/keymaps/i386
19 # We first need a list to sort and then use \n for Yad list.
20 for i in $(find *rty *rtz dvorak -name *.map.gz); do
21 keymap=$(basename $i)
22 type=$(dirname $i)
23 echo "${keymap%.map.gz} $type"
24 done
25 }
28 # Load the selected kmap file from /usr/share/kbd/keymaps or Busybox kmaps.
30 load_keymap() {
31 if [ -x /bin/loadkeys ]; then
32 loadkeys -u $kmap
33 else
34 loadkmap < /usr/share/kmap/$kmap.kmap
35 fi
36 }
39 # Config /etc/keymap.conf and update Xorg keyboard config
41 system_config() {
42 echo "$kmap" > /etc/keymap.conf
43 tazx keyboard
44 }
47 case "$1" in
48 info)
49 _ 'Config file: %s' '/etc/keymap.conf'
50 _ 'Current keymap: %s' "$(cat /etc/keymap.conf)" ;;
51 list)
52 list_keymaps | sort ;;
53 "")
54 # Default to text mode dialog.
55 : ${DIALOG=dialog --timeout 60}
56 check_root
57 exec 3>&1
58 value=$($DIALOG --clear \
59 --title "{ $(_n 'SliTaz keyboard setting') }" \
60 --menu "" 20 72 14 \
61 $(list_keymaps | sort) \
62 2>&1 1>&3)
63 retval=$?
64 exec 3>&-
65 case $retval in
66 0) continue ;;
67 1|255) exit 0 ;;
68 esac
69 # If it's a reconfiguration give an info message.
70 if [ -s /etc/keymap.conf ]; then
71 $DIALOG --clear --title " $(_n 'Information') " \
72 --msgbox "$(_n 'Please logout of your current session and login again to use new keyboard.')" 16 70
73 fi
74 kmap=$value
75 system_config
76 load_keymap ;;
77 *)
78 # Used to configure keymap from cmdline or scripts
79 kmap=$1
80 check_root
81 system_config
82 load_keymap ;;
83 esac
85 exit 0