2009-07-19 13:57:48 +00:00
#!/bin/bash
2009-07-18 11:48:28 +00:00
2009-07-18 19:57:12 +00:00
# This file is part of the german Neo keyboard layout
#
# GUI to combine several Compose modules written by Neo keyboard layout
2009-08-11 17:13:43 +00:00
# This file has been originally written by Pascal Hauck <neo at pascalhauck dot de>
2009-07-18 11:48:28 +00:00
2009-07-18 19:57:12 +00:00
SRC = ./src # Source directory
2009-08-11 17:13:43 +00:00
CONFFILE = .config # config file for selected modules
2009-07-18 11:48:28 +00:00
2009-08-11 14:35:42 +00:00
# colours in the Bash
normal = "\033[0m"
red = "\033[31m"
orange = "\033[33m"
green = "\033[32m"
2009-08-11 17:13:43 +00:00
# different subroutines for kdialog, zenity and dialog
2009-08-11 16:42:50 +00:00
if [ " X: $KDE_FULL_SESSION " = "X:true" ] ; then
2009-08-11 17:13:43 +00:00
NL = "<br>" # new line (can be different in kdialog and zenity)
ADD_TO_LIST( ) { # make list of modules, descriptions and default values (not for zenity)
2009-07-31 13:10:21 +00:00
list = ( " ${ list [@] } " " $1 " " $2 " " $3 " )
}
2009-07-19 07:46:04 +00:00
CHECKLIST( ) {
2009-08-11 16:42:50 +00:00
kdialog --title Compose-Module --checklist " $1 " " ${ list [@] } "
2009-07-19 07:46:04 +00:00
}
2009-07-20 12:11:23 +00:00
MSGBOX( ) {
kdialog --title Compose-Module --msgbox " $1 "
}
YESNO( ) {
kdialog --title Compose-Module --yesno " $1 "
}
2009-08-01 12:34:58 +00:00
elif [ -n "`which zenity 2>/dev/null`" ] && [ ${ DISPLAY } ] ; then
2009-08-11 16:42:50 +00:00
NL = "\n"
2009-07-31 13:10:21 +00:00
ADD_TO_LIST( ) {
list = ( " ${ list [@] } " " $1 " " $2 " )
}
2009-07-19 07:46:04 +00:00
CHECKLIST( ) {
2009-08-11 16:42:50 +00:00
zenity --title Compose-Module --width= 610 --height= 320 --list --multiple --column Modulname --column Modulebeschreibung --separator= _ --text " $1 ${ NL } $2 " " ${ list [@] } "
2009-07-20 12:11:23 +00:00
}
MSGBOX( ) {
zenity --title Compose-Module --info --text " $1 "
}
YESNO( ) {
zenity --title Compose-Module --question --text " $1 "
2009-07-19 07:46:04 +00:00
}
2009-08-01 12:19:34 +00:00
elif [ -n "`which dialog 2>/dev/null`" ] ; then
2009-08-11 16:42:50 +00:00
NL = "\n"
2009-08-01 12:19:34 +00:00
ADD_TO_LIST( ) {
list = ( " ${ list [@] } " " $1 " " $2 " " $3 " )
}
CHECKLIST( ) {
2009-08-11 16:42:50 +00:00
dialog --title Compose-Module --checklist " $1 " 20 70 10 " ${ list [@] } " 3>& 1 1>& 2 2>& 3 3>& - || exit 1
clear
2009-08-01 12:19:34 +00:00
}
MSGBOX( ) {
dialog --title Compose-Module --msgbox " $1 " 8 60
2009-08-11 16:42:50 +00:00
clear
2009-08-01 12:19:34 +00:00
}
YESNO( ) {
2009-08-11 16:42:50 +00:00
dialog --title Compose-Module --yesno " $1 " 0 0 || exit 1
clear
2009-08-01 12:19:34 +00:00
}
2009-08-11 17:13:43 +00:00
else # none of them (kdialog, zenity, dialog) exists → tell user to use make config && make install
2009-08-11 14:35:42 +00:00
echo -e ${ red } "Es wurde weder kdialog noch zenity noch dialog gefunden." ${ normal }
echo -e ${ red } "Die graphische Konfiguration kann nicht verwendet werden." ${ normal }
echo -e ${ red } "Bitte benutzen Sie stattdessen › make config && make install‹ ." ${ normal }
2009-08-01 12:19:34 +00:00
exit 1
2009-07-19 07:46:04 +00:00
fi
2009-08-11 17:13:43 +00:00
while [ ! " $nohelp " ] ; do # options for »compose_gui.sh« (at the moment just --help)
2009-07-31 13:10:21 +00:00
case ${ 1 - " " } in
" " )
nohelp = ok
; ;
*)
echo Aufruf: compose.sh
echo Mit »compose.sh« können die Compose-Module von Neo zusammengesetzt werden.
echo Folgende Module sind verfügbar:
2009-08-11 17:13:43 +00:00
for j in ` ls $SRC /*.module` ; do # show all available Compose modules and descriptions
2009-08-01 11:01:18 +00:00
i = $( basename $j .module)
2009-08-01 12:19:34 +00:00
if [ ! " $i " = "base" ] && [ ! " $i " = "enUS" ] ; then
2009-08-01 11:01:18 +00:00
sed -n "
2009-07-31 13:10:21 +00:00
/^#configinfo[ \t ] */{
s///
b print
}
\$ ! b
s/.*/( ohne Beschreibung) /
: print
x
s/^/$i /
G
s/^\( .\{ 9\} \) .*\n \( .\{ 1,69\} \) .*/\1 \2 / # 80-Zeichen-Terminal-Grenze
p
q
" ${ SRC } / ${ i } .module
2009-08-01 11:01:18 +00:00
fi
2009-07-31 13:10:21 +00:00
done
exit; ;
esac
done
2009-07-20 12:11:23 +00:00
2009-08-11 17:13:43 +00:00
auswahl = XCompose_enUS_base # enUS and base cannot be deselected
2009-07-18 11:48:28 +00:00
2009-08-01 12:19:34 +00:00
for i in src/*.module; do
2009-08-11 17:13:43 +00:00
name = $( basename $i .module) # get name of modul
if [ ! " $name " = "base" -a ! " $name " = "enUS" ] ; then # enUS and base annot be deselected
2009-07-31 13:10:21 +00:00
description = $( sed -n "
2009-07-18 19:57:12 +00:00
/^#configinfo[ \t ] */{
s///
2009-07-31 13:10:21 +00:00
b print
2009-07-18 19:57:12 +00:00
}
2009-07-18 11:48:28 +00:00
2009-07-31 13:10:21 +00:00
\$ ! b
s/.*/( ohne Beschreibung) /
: print
p
q
2009-08-11 17:13:43 +00:00
" $SRC / $name .module) # get description of module
2009-08-01 12:19:34 +00:00
if grep -qs $name $CONFFILE ; then
2009-08-11 17:13:43 +00:00
default = on # get default value for this module
2009-07-18 19:57:12 +00:00
else
2009-07-31 13:10:21 +00:00
default = off
2009-07-18 19:57:12 +00:00
fi
2009-07-31 13:10:21 +00:00
ADD_TO_LIST " $name " " $description " " $default "
2009-07-18 19:57:12 +00:00
fi
done
2009-07-18 11:48:28 +00:00
2009-07-31 13:10:21 +00:00
2009-08-11 17:13:43 +00:00
if [ -f $HOME /.XCompose ] ; then # warn if ~/.XCompose already exists
2009-08-11 16:42:50 +00:00
YESNO "Es gibt bereits eine Compose-Datei (z.B. durch eine ältere Neo-Installation).\nSollten Sie eigene Definitionen in der Datei ~/.XCompose vorgenommen haben, dann brechen Sie jetzt ab und schreiben Ihre eigenen Definitionen in eine Datei (z.B. user.module) im Ordner src.\n\nAnderenfalls können Sie das Skript bedenkenlos fortsetzen.\nWollen Sie fortfahren?" || exit 1
2009-07-31 13:10:21 +00:00
fi
2009-08-11 16:42:50 +00:00
menu = ` CHECKLIST " Die Neo-Tastaturbelegung hat etliche Erweiterungen für Compose (Mod3+Tab) erstellt, ${ NL } wodurch Zeichen wie ≙ έ ʒ ermöglicht werden. ${ NL } Wählen Sie die Compose-Module von Neo aus, die Sie verwenden möchten. " "Für mehrere Module STRG bzw. CTRL gedrückt halten." | sed -e 's/\"//g' | sed -e 's/\ /_/g' `
2009-07-18 11:48:28 +00:00
2009-08-01 12:19:34 +00:00
if [ $menu ] ; then
2009-07-19 00:08:11 +00:00
fertig = "Die neue Compose-Datei wurde erfolgreich erstellt.\nSie wird für alle neu gestarteten Programme sowie nach dem nächsten Login wirksam."
2009-07-21 10:22:14 +00:00
echo " USER_XCOMPOSE = ${ auswahl } _ ${ menu } " > .config && make install && MSGBOX " $fertig "
2009-07-18 11:48:28 +00:00
fi