slitaz-tools view tinyutils/tazkeymap @ rev 939

tazbox: fix subox icon when ~/.local/share/applications is absent; fix working with freegeoip; write full list of icons used; all other files: 2015 and insert blank lines.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Apr 17 07:35:02 2015 +0300 (2015-04-17)
parents 5bb075010572
children 3be081525506
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 $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 _n 'Config file:'; echo " /etc/keymap.conf"
50 _n 'Current keymap:'; echo " $(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