alterator-xkb-2.0/000075500000000000000000000000001106567174100141405ustar00rootroot00000000000000alterator-xkb-2.0/Makefile000064400000000000000000000007501106567174100156020ustar00rootroot00000000000000NAME=xkb all: build-tools clean: clean-tools install: install-module install-tools include /usr/share/alterator/build/module.mak build-tools: for i in tools/*; do [ ! -d $$i ] || make -C $$i; done; clean-tools: for i in tools/*; do [ ! -d $$i ] || make -C $$i clean; done; install-tools:build-tools for i in tools/*; do [ ! -d $$i ] || $(INSTALL) -Dpm 755 $$i/$${i##*/} $(bindir)/$${i##*/};done for i in tools/*; do [ -d $$i ] || $(INSTALL) -Dpm 755 $$i $(bindir)/$${i##*/};done alterator-xkb-2.0/applications/000075500000000000000000000000001106567174100166265ustar00rootroot00000000000000alterator-xkb-2.0/applications/xkb.desktop000064400000000000000000000002351106567174100210050ustar00rootroot00000000000000[Desktop Entry] Encoding=UTF-8 Type=Application Categories=X-Alterator-Xorg Icon=xkb Terminal=false Name=Keyboard X-Alterator-URI=/xkb X-Alterator-Weight=10 alterator-xkb-2.0/backend3/000075500000000000000000000000001106567174100156125ustar00rootroot00000000000000alterator-xkb-2.0/backend3/xkb000075500000000000000000000106611106567174100163300ustar00rootroot00000000000000#!/bin/sh #this module can work for all users, so I use common directories alterator_api_version=1 po_domain="alterator-xkb" cachedir= ticketdir="/var/lib/alterator/tickets" if [ -n "$TMPDIR" ]; then cachedir="$TMPDIR/alterator-xkb" else cachedir="/var/cache/alterator/alterator-xkb" fi #turn off auto expansion set -f . alterator-sh-functions dump_cache() { local langlist="$(write_language "$in_language")" local firstlang="${langlist%%:*}" LC_ALL="$firstlang" LANGUAGE="$langlist" xkbdatadump } clear_cache() { rm -rf "$cachedir" } init_cache() { local rc=0 local msg= [ -d "$cachedir/$1" ] && return 0 mkdir -p "$cachedir/$1" cd "$cachedir/$1" msg="$(dump_cache 2>&1)" rc=$? cd - >/dev/null [ "$rc" -eq 0 ] || write_error "$msg" return $rc } read_current_layout() { if [ -f "$cachedir/current_layout" ];then cat "$cachedir/current_layout" else xkbmapconf -l|tee "$cachedir/current_layout" fi } list_current_layout() { read_current_layout| while read layout; do local name="$(grep -m1 "^$layout[[:space:]]" "$cachedir/$1/layouts" | cut -f2)" [ -n "$name" ] || name="$layout" printf '%s\t%s\n' "$layout" "$name" done } list_avail_variant() { grep "^$2\((\|[[:space:]]\)" "$cachedir/$1/layouts" } list_avail_layout() { grep '^\([[:alnum:]]\+\)[[:space:]]\+' "$cachedir/$l/layouts"| LANG="${in_language%%:*}.UTF-8" sort -k 2,2 2>/dev/null } write_add() { grep -qs "^$1\$" "$cachedir/current_layout" || echo "$1" >>"$cachedir/current_layout" } write_remove() { ed -s "$cachedir/current_layout" 2>/dev/null </dev/null </dev/null <"$name"<"$cachedir/selected_layout" if [ -n "$in_remove" ];then write_remove "$in_layout" elif [ -n "$in_up" ];then write_up "$in_layout" elif [ -n "$in_down" ];then write_down "$in_layout" elif [ -n "$in_submit" ];then xkbmapconf -s -- \ -model "$in_model" \ -option "$in_grp" \ -layout "$(cat "$cachedir/current_layout" | tr '\n' ','| sed s/,$//)" [ "$in_update" = "#t" ] && setxkbmap -option && setxkbmap $(cat /etc/X11/xinit/Xkbmap) >/dev/null 2>/dev/null fi ;; esac ;; esac } message_loop alterator-xkb-2.0/interfaces/000075500000000000000000000000001106567174100162635ustar00rootroot00000000000000alterator-xkb-2.0/interfaces/guile/000075500000000000000000000000001106567174100173705ustar00rootroot00000000000000alterator-xkb-2.0/interfaces/guile/workflow/000075500000000000000000000000001106567174100212425ustar00rootroot00000000000000alterator-xkb-2.0/interfaces/guile/workflow/xkb.scm000064400000000000000000000011141106567174100225270ustar00rootroot00000000000000(define-module (alterator workflow xkb) :use-module (alterator algo) :use-module (alterator woo) :use-module (alterator configd html) :use-module (alterator configd form) :export (workflow)) (define (workflow url url-args template-args) (let ((action (cond-assq 'action template-args))) (woo-catch (thunk (if (cond-assoc "add" url-args) (html:redirect "/xkb/avail_layout") (workflow-form url action url-args template-args))) (lambda(reason) (html:error (workflow-form url "read" url-args template-args) reason))))) alterator-xkb-2.0/templates/000075500000000000000000000000001106567174100161365ustar00rootroot00000000000000alterator-xkb-2.0/templates/xkb/000075500000000000000000000000001106567174100167225ustar00rootroot00000000000000alterator-xkb-2.0/templates/xkb/avail_layout/000075500000000000000000000000001106567174100214135ustar00rootroot00000000000000alterator-xkb-2.0/templates/xkb/avail_layout/index.html000064400000000000000000000014311106567174100234070ustar00rootroot00000000000000
Country:
Available layouts:
alterator-xkb-2.0/templates/xkb/index.html000064400000000000000000000032011106567174100207130ustar00rootroot00000000000000
Layouts:
   
 
Layout switching:
Model:
 
   
alterator-xkb-2.0/tools/000075500000000000000000000000001106567174100153005ustar00rootroot00000000000000alterator-xkb-2.0/tools/xkbdatadump/000075500000000000000000000000001106567174100176045ustar00rootroot00000000000000alterator-xkb-2.0/tools/xkbdatadump/Makefile000064400000000000000000000001431106567174100212420ustar00rootroot00000000000000CFLAGS=-Wall -pedantic $(RPM_OPT_FLAGS) LDLIBS= -lexpat all:xkbdatadump clean: $(RM) xkbdatadump alterator-xkb-2.0/tools/xkbdatadump/xkbdatadump.c000064400000000000000000000075711106567174100222660ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include #include #define _(string) gettext (string) const char datafile[]="/usr/share/X11/xkb/rules/xorg.xml"; const char po_domain[]="xkeyboard-config"; typedef struct user_data_struct { char *el; FILE *file; int mode; char *layname; char *name; char *laydescription; char *description; } user_data; void do_free(char **item) { if (*item) free(*item); *item = 0; } void do_assign(char **target,const char *destination,int len) { do_free(target); if (destination && (len > 0)) { *target=malloc(len+1); strncpy(*target,destination,len); (*target)[len]=0; } } FILE * xfopen(const char *name,const char *mode) { FILE *f=fopen(name,mode); if (!f) error(EXIT_FAILURE,errno,"unable to open file %s for writing",name); return f; } void do_reset(user_data *u) { do_free(&u->description); } static void XMLCALL element_start(void *data, const char *el, const char **attr) { user_data *u = data; u->el = strdup(el); if (!strcmp(el,"modelList")) u->file = xfopen("./models","w"); else if (!strcmp(el,"layoutList")) u->file = xfopen("./layouts","w"); else if (!strcmp(el,"optionList")) u->file = xfopen("./options","w"); else if (!strcmp(el,"layout") || !strcmp(el,"group")) u->mode = 1; else if (!strcmp(el,"variant") || !strcmp(el,"option")) u->mode = 0; } static void XMLCALL element_stop(void *data, const char *el) { user_data *u = data; do_free(&u->el); if (!strcmp(el,"modelList") || !strcmp(el,"layoutList") || !strcmp(el,"optionList")) fclose(u->file); else if (!strcmp(el,"layout")) { fprintf(u->file,"%s\t%s\n", u->layname, _(u->laydescription)); do_reset(u); } else if (!strcmp(el,"variant")) { u->mode = 1; fprintf(u->file,"%s(%s)\t%s - %s\n", u->layname, u->name, _(u->laydescription), _(u->description)); do_reset(u); } else if (!strcmp(el,"option") && !strcmp(u->layname,"grp")) { u->mode = 1; fprintf(u->file,"%s\t%s\n", u->name, _(u->description)); do_reset(u); } else if (!strcmp(el,"model")) { fprintf(u->file,"%s\t%s\n", u->name, _(u->description)); do_reset(u); } } static void XMLCALL cdata_handler(void *data,const char *buffer, int len) { user_data *u = data; if (!u->el) return; if (!strcmp(u->el,"name")) do_assign(u->mode?&u->layname:&u->name,buffer,len); else if (!strcmp(u->el,"description")) do_assign(u->mode?&u->laydescription:&u->description,buffer,len); } int main(int argc,char **argv) { int fd; char buffer[BUFSIZ]; size_t len; XML_Parser parser; user_data *data; setlocale(LC_ALL,""); textdomain(po_domain); bindtextdomain(po_domain, "/usr/share/locale"); if (!(parser = XML_ParserCreate(NULL))) error(EXIT_FAILURE,0,"couldn't allocate memory for parser"); if (!(data = calloc(1,sizeof(user_data)))) error(EXIT_FAILURE,errno,"couldn't allocate memory for user_data"); if ((fd = open(datafile,O_RDONLY)) < 0) error(EXIT_FAILURE,errno,"unable to open database file %s",datafile); XML_SetElementHandler(parser, element_start, element_stop); XML_SetCharacterDataHandler(parser,cdata_handler); XML_SetUserData(parser, data); while ((len = read(fd,buffer,(sizeof buffer) - 1)) > 0) { if (XML_Parse(parser, buffer, len, XML_FALSE) == XML_STATUS_ERROR) { fprintf(stderr,"Parse error at line %lu:%s", XML_GetCurrentLineNumber(parser), XML_ErrorString(XML_GetErrorCode(parser))); return EXIT_FAILURE; } } XML_Parse(parser, buffer, 0, XML_TRUE); XML_ParserFree(parser); return EXIT_SUCCESS; } alterator-xkb-2.0/tools/xkbmapconf000075500000000000000000000057051106567174100173650ustar00rootroot00000000000000#!/bin/sh PROG="${0##*/}" SYSTEM_CONFIG="/etc/X11/xinit/Xkbmap" LOCAL_CONFIG="$HOME/.Xkbmap" ### config cat_config() { touch "$SYSTEM_CONFIG" 2>/dev/null if [ -w "$SYSTEM_CONFIG" ];then cat "$SYSTEM_CONFIG" else cat "$LOCAL_CONFIG" fi } echo_config() { if [ -w "$SYSTEM_CONFIG" ];then echo "$@" > "$SYSTEM_CONFIG" else echo "$@" > "$LOCAL_CONFIG" fi } ### read operations read_layout() { local layout="$1";shift local variant="$1";shift local count=1 local IFS=, set -- $variant for lay in $layout;do local var="$(eval echo \$$count)" if [ -n "$var" ];then printf '%s(%s)\n' "$lay" "$var" else printf '%s\n' "$lay" fi count=$((count + 1)) done } read_grp() { local IFS=, set -- $1 for i in "$@";do if [ "$i" != "${i#grp:}" ];then echo "$i" break fi done } read_config() { local action="$1" local layout= variant= model= option= eval set -- $(cat_config) while [ $# -gt 0 ];do case "$1" in -layout) layout="$2";shift;shift;; -variant) variant="$2";shift;shift;; -model) model="$2";shift;shift;; -option) option="$2";shift;shift;; esac done case "$action" in model) echo "$model";; grp) read_grp "$option";; layout) read_layout "$layout" "$variant";; esac exit } # write operations write_variant() { echo "$1"|sed -r 's/([^,()]+)\(?([^,()]*)\)?/\2/g' } write_layout() { echo "$1"|sed -r 's/([^,()]+)\(?([^,()]*)\)?/\1/g' } write_config() { local layout= variant= model= while [ $# -gt 0 ];do case "$1" in -layout) layout="$2";shift;shift;; -variant) variant="$2";shift;shift;; -model) model="$2";shift;shift;; *) args="$args $1 $2";shift;shift;; esac done #try to extract variant from layout if [ -z "$variant" -a -n "$layout" ];then variant="$(write_variant "$layout")" layout="$(write_layout "$layout")" fi [ -z "$variant" ] || args="$args -variant $variant" [ -z "$layout" ] || args="$args -layout $layout" [ -z "$model" ] || args="$args -model $model" eval echo_config $args } show_help() { cat <