pax_global_header00006660000000000000000000000064142561424300014513gustar00rootroot0000000000000052 comment=774fcef8eee92fb3281d70fc71bfd837e6ce1007 xkbset-0.8/000077500000000000000000000000001425614243000126625ustar00rootroot00000000000000xkbset-0.8/COPYRIGHT000066400000000000000000000030211425614243000141510ustar00rootroot00000000000000Copyright (c) 2000, 2002, 2020, 2021 Stephen Montgomery-Smith All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of Stephen Montgomery-Smith nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE STEPHEN MONTGOMERY-SMITH AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STEPHEN MONTGOMERY-SMITH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. xkbset-0.8/Makefile000066400000000000000000000025641425614243000143310ustar00rootroot00000000000000X11PREFIX=/usr/local X11BASE=/usr/local INSTALL_BIN=${DESTDIR}${X11PREFIX}/bin INSTALL_MAN1=${DESTDIR}${X11PREFIX}/man/man1 INC_PATH=-I${X11BASE}/include LIB_PATH=-L${X11BASE}/lib LIBS=-lX11 all: xkbset xkbset.1 xkbset: getargs.o print.o usage.o main.o misc.o ${CC} ${CFLAGS} ${LDFLAGS} ${INC_PATH} ${LIB_PATH} getargs.o print.o usage.o main.o misc.o -o $@ ${LIBS} getargs.o: getargs.c xkbset.h ${CC} ${CPPFLAGS} ${CFLAGS} ${INC_PATH} -c getargs.c print.o: print.c xkbset.h ${CC} ${CPPFLAGS} ${CFLAGS} ${INC_PATH} -c print.c usage.o: usage.c xkbset.h ${CC} ${CPPFLAGS} ${CFLAGS} ${INC_PATH} -c usage.c main.o: main.c xkbset.h ${CC} ${CPPFLAGS} ${CFLAGS} ${INC_PATH} -c main.c misc.o: misc.c xkbset.h ${CC} ${CPPFLAGS} ${CFLAGS} ${INC_PATH} -c misc.c getargs.c: create_getargs config_getargs perl create_getargs print.c: create_print config_print perl create_print usage.c: create_usage config_usage perl create_usage config_usage: config_getargs rm -f config_usage ln -s config_getargs config_usage xkbset.1: xkbset.man cp xkbset.man xkbset.1 INSTALL= install -c INSTALL_DATA= ${INSTALL} INSTALL_SCRIPT= ${INSTALL} INSTALL_PROGRAM=${INSTALL} -s install: all ${INSTALL_PROGRAM} xkbset ${INSTALL_BIN} ${INSTALL_SCRIPT} xkbset-gui ${INSTALL_BIN} ${INSTALL_DATA} xkbset.1 ${INSTALL_MAN1} clean: rm -f *.o getargs.c print.c usage.c *.core xkbset config_usage xkbset.1 xkbset-0.8/README000066400000000000000000000023341425614243000135440ustar00rootroot00000000000000xkbset is a program rather like xset in that it allows you to set various features of the X window interface. It allows one to configure most of the options connected with the XKB extensions. They are described in Section 10 of XKBlib.ps. This includes customizing the following: MouseKeys: using the numeric pad keys to move the mouse; StickyKeys: where modifiers like control and shift will lock until the next key press (good for one finger typing); SlowKeys: The keys will not work unless they are pressed for a certain amount of time; BounceKeys: If a key is pressed more than once rapidly, only one key press will be registered. I also include a gui program xkbset-gui which is a GUI program to play with the mousekeys acceleration parameters. It is written in Perl/Tk, so Perl/Tk will need to be installed on your machine. If you have any improvents or ideas, please send them to me. Also, if you use this program and like it, please tell me so. If I don't get much feedback, I will assume no one is interested, and I won't develop it further (in particular I won't finish the man page). Stephen Montgomery-Smith stephen@missouri.edu https://stephenmontgomerysmith.github.io xkbset-0.8/TODO000066400000000000000000000000241425614243000133460ustar00rootroot00000000000000Finish the man page xkbset-0.8/VERSIONS000066400000000000000000000003361425614243000140570ustar00rootroot00000000000000xkbset-0.0 The very first version. xkbset-0.5 A later version. xkbset-0.6 A little cleaning up. xkbset-0.7 Remove "save to .xsession" option, as it didn't work. (Thanks to Samuel Thibault .) xkbset-0.8/config_getargs000066400000000000000000000151771425614243000156010ustar00rootroot00000000000000# Copyright (c) 2000, 2002 Stephen Montgomery-Smith # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of Stephen Montgomery-Smith nor the names of his # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE STEPHEN MONTGOMERY-SMITH AND CONTRIBUTORS # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STEPHEN MONTGOMERY-SMITH OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. #C To switch the bell on or off: bell | b: MASK_XkbAudibleBellMask enabled_ctrls XkbControlsEnabledMask; #C To switch one key to autorepeat or not: repeatkeys %d|r %d: BIT32 per_key_repeat XkbPerKeyRepeatMask; #C To send a hex mask for all keys to autorepeat or not perkeyrepeat %64x: CHAR_ARRAY32 per_key_repeat XkbPerKeyRepeatMask; #C To switch autorepeat on or off, and optionally set the delay before #C the first repeat and the interval between repeats (times in milliseconds): repeatkeys|r: MASK_XkbRepeatKeysMask enabled_ctrls XkbControlsEnabledMask { rate %d: USHORT repeat_delay XkbRepeatKeysMask { %d: USHORT repeat_interval XkbRepeatKeysMask; } } #C To switch mousekeys on or off, and optionally set the default #C button (whatever that is): mousekeys | m: MASK_XkbMouseKeysMask enabled_ctrls XkbControlsEnabledMask { %d: UCHAR mk_dflt_btn XkbMouseKeysMask; } #C To switch mousekeys acceleration on or off, and optionally set #C the acceleration characteristics: mousekeysaccel | ma: MASK_XkbMouseKeysAccelMask enabled_ctrls XkbControlsEnabledMask { %d %d %d %d %d: USHORT mk_delay XkbMouseKeysAccelMask, USHORT mk_interval XkbMouseKeysAccelMask, USHORT mk_time_to_max XkbMouseKeysAccelMask, USHORT mk_max_speed XkbMouseKeysAccelMask, SHORT mk_curve XkbMouseKeysAccelMask; } #C To switch AccessX on (so pressing shift five times starts sticky keys #C and pressing the shift key down 8 seconds starts slow keys): accessx | a: MASK_XkbAccessXKeysMask enabled_ctrls XkbControlsEnabledMask; #C To switch sticky keys on or off, and optionally set or reset: #C () two keys pressed at the same time stops sticky keys; #C () a modifier pressed twice will be locked: sticky | st: MASK_XkbStickyKeysMask enabled_ctrls XkbControlsEnabledMask { twokey: MASK_XkbAX_TwoKeysMask ax_options XkbStickyKeysMask; latchlock: MASK_XkbAX_LatchToLockMask ax_options XkbStickyKeysMask; } #C To switch on slowkeys, and optionally set the slow key delay (in #C milliseconds): slowkeys | sl: MASK_XkbSlowKeysMask enabled_ctrls XkbControlsEnabledMask { %d: USHORT slow_keys_delay XkbSlowKeysMask; } #C To switch on bouncekeys, and optionally set the time (in milliseconds) for #C which if the key is pressed again in that time it will not work: bouncekeys | bo: MASK_XkbBounceKeysMask enabled_ctrls XkbControlsEnabledMask { %d: USHORT debounce_delay XkbBounceKeysMask; } #C To switch on audible feedback, and optionally set which features #C cause the feedback (note [-]feature means that switching #C one of the AccessX features on of off causes feedback): feedback | f: MASK_XkbAccessXFeedbackMask enabled_ctrls XkbControlsEnabledMask { dumbbell: MASK_XkbAX_DumbBellFBMask ax_options XkbAccessXFeedbackMask; led: MASK_XkbAX_IndicatorFBMask ax_options XkbAccessXFeedbackMask; feature: MASK_XkbAX_FeatureFBMask ax_options XkbAccessXFeedbackMask; slowwarn: MASK_XkbAX_SlowWarnFBMask ax_options XkbAccessXFeedbackMask; slowpress: MASK_XkbAX_SKPressFBMask ax_options XkbAccessXFeedbackMask; slowaccept: MASK_XkbAX_SKAcceptFBMask ax_options XkbAccessXFeedbackMask; slowreject: MASK_XkbAX_SKRejectFBMask ax_options XkbAccessXFeedbackMask; slowrelease: MASK_XkbAX_SKReleaseFBMask ax_options XkbAccessXFeedbackMask; bouncereject: MASK_XkbAX_BKRejectFBMask ax_options XkbAccessXFeedbackMask; stickybeep: MASK_XkbAX_StickyKeysFBMask ax_options XkbAccessXFeedbackMask; } #C To switch keyboard overlays 1 or 2 on or off: overlay1 | ov1: MASK_XkbOverlay1Mask enabled_ctrls XkbControlsEnabledMask; overlay2 | ov2: MASK_XkbOverlay2Mask enabled_ctrls XkbControlsEnabledMask; #C To select the group wrap type (now what is that)? groupswrap %e { redirect = XkbRedirectIntoRange; clamp = XkbClampIntoRange; wrap = XkbWrapIntoRange }: HIGH_NIBBLE_ENUM groups_wrap XkbGroupsWrapMask { %d: LOW_NIBBLE groups_wrap XkbGroupsWrapMask; } #C What is this? ignoregrouplock: MASK_XkbIgnoreGroupLockMask enabled_ctrls XkbControlsEnabledMask; #C To cause some of the key modifiers (like shift, num-lock=mod2, etc) #C to not work: nullify: { shift: MASK_ShiftMask "internal.real_mods" XkbInternalModsMask; lock: MASK_LockMask "internal.real_mods" XkbInternalModsMask; control: MASK_ControlMask "internal.real_mods" XkbInternalModsMask; mod1: MASK_Mod1Mask "internal.real_mods" XkbInternalModsMask; mod2: MASK_Mod2Mask "internal.real_mods" XkbInternalModsMask; mod3: MASK_Mod3Mask "internal.real_mods" XkbInternalModsMask; mod4: MASK_Mod4Mask "internal.real_mods" XkbInternalModsMask; mod5: MASK_Mod5Mask "internal.real_mods" XkbInternalModsMask; } #C What is this? ignorelock: { shift: MASK_ShiftMask "ignore_lock.real_mods" XkbIgnoreLockModsMask; lock: MASK_LockMask "ignore_lock.real_mods" XkbIgnoreLockModsMask; control: MASK_ControlMask "ignore_lock.real_mods" XkbIgnoreLockModsMask; mod1: MASK_Mod1Mask "ignore_lock.real_mods" XkbIgnoreLockModsMask; mod2: MASK_Mod2Mask "ignore_lock.real_mods" XkbIgnoreLockModsMask; mod3: MASK_Mod3Mask "ignore_lock.real_mods" XkbIgnoreLockModsMask; mod4: MASK_Mod4Mask "ignore_lock.real_mods" XkbIgnoreLockModsMask; mod5: MASK_Mod5Mask "ignore_lock.real_mods" XkbIgnoreLockModsMask; } xkbset-0.8/config_print000066400000000000000000000115331425614243000152710ustar00rootroot00000000000000# Copyright (c) 2000, 2002 Stephen Montgomery-Smith # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of Stephen Montgomery-Smith nor the names of his # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE STEPHEN MONTGOMERY-SMITH AND CONTRIBUTORS # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STEPHEN MONTGOMERY-SMITH OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -b MASK_XkbAudibleBellMask enabled_ctrls Audible Bell -r MASK_XkbRepeatKeysMask enabled_ctrls Repeat Keys rate USHORT repeat_delay Repeat Delay USHORT repeat_interval Repeat Interval perkeyrepeat CHAR_ARRAY_32 per_key_repeat Per Key Repeat -m MASK_XkbMouseKeysMask enabled_ctrls Mouse-Keys UCHAR mk_dflt_btn Mouse-Keys Default Button -ma MASK_XkbMouseKeysAccelMask enabled_ctrls Mouse-Keys Acceleration USHORT mk_delay Mouse-Keys Acceleration Delay USHORT mk_interval Mouse-Keys Acceleration Interval USHORT mk_time_to_max Mouse-Keys Acceleration Time to Max USHORT mk_max_speed Mouse-Keys Acceleration Max Speed SHORT mk_curve Mouse-Keys Acceleration Curve -a MASK_XkbAccessXKeysMask enabled_ctrls Accessibility Features (AccessX) -st MASK_XkbStickyKeysMask enabled_ctrls Sticky-Keys -twokey MASK_XkbAX_TwoKeysMask ax_options Two Keys Mask -latchlock MASK_XkbAX_LatchToLockMask ax_options Latch to Lock Mask -sl MASK_XkbSlowKeysMask enabled_ctrls Slow-Keys USHORT slow_keys_delay Slow Keys Delay -bo MASK_XkbBounceKeysMask enabled_ctrls Bounce-Keys USHORT debounce_delay Debounce Delay -f MASK_XkbAccessXFeedbackMask enabled_ctrls AccessX Feedback -dumbbell MASK_XkbAX_DumbBellFBMask ax_options Use Fixed Pitch Bell -led MASK_XkbAX_IndicatorFBMask ax_options Beep when LED changes -feature MASK_XkbAX_FeatureFBMask ax_options Beep on Controls on/off -slowwarn MASK_XkbAX_SlowWarnFBMask ax_options Beep if Slow/Bounce-Keys about to be turned off -slowpress MASK_XkbAX_SKPressFBMask ax_options Beep on Slow-Key Press -slowaccept MASK_XkbAX_SKAcceptFBMask ax_options Beep on Slow-Key Accept -slowreject MASK_XkbAX_SKRejectFBMask ax_options Beep on Slow-Key Reject -slowrelease MASK_XkbAX_SKReleaseFBMask ax_options Beep on Slow-Key Release -bouncereject MASK_XkbAX_BKRejectFBMask ax_options Beep on Bounce-Key Reject -stickybeep MASK_XkbAX_StickyKeysFBMask ax_options Beep on Sticky-Key Actions -ov1 MASK_XkbOverlay1Mask enabled_ctrls Keyboard Overlay 1 -ov2 MASK_XkbOverlay2Mask enabled_ctrls Keyboard Overlay 2 +groupswrap HIGH_NIBBLE_ENUM groups_wrap Groups Wrap Type redirect=XkbRedirectIntoRange,clamp=XkbClampIntoRange,wrap=XkbWrapIntoRange LOW_NIBBLE_IF_HIGH_NIBBLE_ENUM groups_wrap Groups Wrap Value redirect=XkbRedirectIntoRange,clamp=XkbClampIntoRange,wrap=XkbWrapIntoRange #finish later -ignoregrouplock MASK_XkbIgnoreGroupLockMask enabled_ctrls Ignore Group Lock nullify -shift MASK_ShiftMask internal.real_mods Nullify Shift -lock MASK_LockMask internal.real_mods Nullify Caps-Lock -control MASK_ControlMask internal.real_mods Nullify Control -mod1 MASK_Mod1Mask internal.real_mods Nullify Mod1 -mod2 MASK_Mod2Mask internal.real_mods Nullify Mod2 -mod3 MASK_Mod3Mask internal.real_mods Nullify Mod3 -mod4 MASK_Mod4Mask internal.real_mods Nullify Mod4 -mod5 MASK_Mod5Mask internal.real_mods Nullify Mod5 ignorelock -shift MASK_ShiftMask ignore_lock.real_mods Ignore Lock of Shift -lock MASK_LockMask ignore_lock.real_mods Ignore Lock of Caps-Lock -control MASK_ControlMask ignore_lock.real_mods Ignore Lock of Control -mod1 MASK_Mod1Mask ignore_lock.real_mods Ignore Lock of Mod1 -mod2 MASK_Mod2Mask ignore_lock.real_mods Ignore Lock of Mod2 -mod3 MASK_Mod3Mask ignore_lock.real_mods Ignore Lock of Mod3 -mod4 MASK_Mod4Mask ignore_lock.real_mods Ignore Lock of Mod4 -mod5 MASK_Mod5Mask ignore_lock.real_mods Ignore Lock of Mod5 xkbset-0.8/create_getargs000066400000000000000000000261521425614243000155720ustar00rootroot00000000000000#!/usr/bin/perl -w # Copyright (c) 2000, 2002, 2021 Stephen Montgomery-Smith # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of Stephen Montgomery-Smith nor the names of his # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE STEPHEN MONTGOMERY-SMITH AND CONTRIBUTORS # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STEPHEN MONTGOMERY-SMITH OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # Split configuration file into atoms in @atomlist. sub fetchatoms { @atomlist = (); open(CONFIG,"config_getargs"); while ($line = ) { if ($line !~ /^\#/) { # ignore comments. while (1) { next if ($line =~ s/^\s+//); # Remove whitespace. if ($line =~ s/^\"([^\"]*)\"//) {} # get things in quotes verbatum. elsif ($line =~ s/^([a-zA-Z\_][a-zA-Z\_0-9]*)//) {} # get c-style variable names. elsif ($line =~ s/^(\%\d*[a-zA-Z])//) {} # get printf style tokens. elsif ($line =~ s/^(\S)//) {} # get a single non-whitespace character. else { last } push(@atomlist,$1); } } } close(CONFIG); push(@atomlist,"end"); $atom = shift @atomlist; } sub enum_value { my $enum = ''; $atom = shift @atomlist; $enum = $atom; $atom = shift @atomlist; die if $atom ne '='; $atom = shift @atomlist; $enum .= '=' . $atom; $atom = shift @atomlist; return $enum; } sub sub_title_item { my $item; if ($atom =~ /^[a-zA-Z0-9]/) { $item = "strcmp(ARG,\"$atom\")==0" } elsif ($atom eq '%d') { $item = "get_number(ARG,LOW,HIGH,&VAL)" } elsif ($atom eq '%64x') { $item = "get_64_hex(ARG,char_array_32)" } elsif ($atom eq '%e') { $atom = shift @atomlist; die "'{' expected at beginning of enum list\n" if $atom ne '{'; $item = "ENUM(ARG," . enum_value; while ($atom eq ';') { $item .= "," . enum_value; } die "'}' expected at end of enum list - got $atom\n" if $atom ne '}'; $item .= ')'; } $atom = shift @atomlist if defined($item); return $item; } sub title_item { my $title_item = sub_title_item; my $next_item; my $n = 1; die "syntax error in title\n" if !defined($title_item); $title_item =~ s/ARG/argv[i]/; while(defined($next_item = sub_title_item)) { $next_item =~ s/ARG/argv\[i+$n\]/; $title_item = "$title_item && $next_item"; $n++; } return "(i+$n<=argc && $title_item && (inc=$n))"; } sub substitute { @t=(); foreach $t (split /\|\|/,$_[0]) { $t =~ s/LOW/$_[1]/; $t =~ s/HIGH/$_[2]/; $t =~ s/VAL/val$_[3]/; push(@t,$t); } return join '||',@t; } $n_max = 0; sub process_item { my $title_item; $title_item = title_item; while ($atom eq '|') { $atom = shift @atomlist; $title_item .= " ||\n " . title_item; } die "expected ':'\n" if $atom ne ':'; my $execute = ''; my %maskhash = (); my $n = 1; while ($atom =~ /^(\:|\,)$/) { $atom = shift @atomlist; my $type = $atom; last if $atom eq '{'; $atom = shift @atomlist; my $field = $atom; $atom = shift @atomlist; my $mask = $atom; $atom = shift @atomlist; die "expected three fields\n" if !defined($atom); #$execute .= "printf(\"executing for $type $field $mask\\n\");\n"; $maskhash{$mask} = 1; if ($type =~ /^MASK\_(.*)$/) { $execute .= "if (argv[i][0] == '-') ctrls->$field &= ~$1;\n" . "else ctrls->$field |= $1;\n"; } elsif ($type eq 'USHORT') { $title_item = substitute($title_item,0,65535,$n); $execute .= "ctrls->$field = val$n;\n"; $n++; } elsif ($type eq 'SHORT') { $title_item = substitute($title_item,-32767,32767,$n); $execute .= "ctrls->$field = val$n;\n"; $n++; } elsif ($type eq 'UCHAR') { $title_item = substitute($title_item,0,255,$n); $execute .= "ctrls->$field = val$n;\n"; $n++; } elsif ($type eq 'LOW_NIBBLE') { $title_item = substitute($title_item,0,255,$n); $execute .= "ctrls->$field &= 0xF0;\n" . "ctrls->$field |= 0x0F & val$n;\n"; $n++; } elsif ($type eq 'BIT32') { $title_item = substitute($title_item,0,255,$n); $execute .= "if (argv[i][0] == '-') ctrls->$field\[val$n>>3] &= ~(1<<(val$n&7));\n" . "else ctrls->$field\[val$n>>3] |= (1<<(val$n&7));\n"; $n++; } elsif ($type eq 'CHAR_ARRAY32') { $execute .= "memcpy(ctrls->$field,char_array_32,32);\n"; } elsif ($type eq 'HIGH_NIBBLE_ENUM') { $title_item =~ s/ENUM\(([^\)]*)\)/1/; @enum_list = split ',',$1; $arg = shift(@enum_list); $first = 1; foreach $enum (@enum_list) { ($code,$value) = split '=',$enum; $execute .= (!$first?"else ":"") . "if (strcmp($arg,\"$code\")==0) {\n" . " ctrls->$field &= 0x0F;\n" . " ctrls->$field |= $value;\n" . "}\n"; $first = 0; } $execute .= "else return 0;\n"; } else { die "Unknown type $type"; } if ($type eq 'BIT32' || $type =~ /^MASK\_/) { $temp = $title_item; $temp =~ s/strcmp\(([^\,]+)\,\"([^\"]+)\"\)/strcmp\($1,\"-$2\"\)/g; $title_item .= " ||\n $temp"; } } $n_max = $n-1 if $n-1>$n_max; foreach $i (@_) { $maskhash{$i} = 0; } $masklist = join '|',grep $maskhash{$_}==1, keys %maskhash; $execute .= "*mask |= $masklist;\n" if $masklist; $execute .= "i += inc;\n"; my $inner; my $inner_count = 0; if ($atom eq '{') { $atom = shift @atomlist; $inner = process_item(keys %maskhash); $inner_count++ if $inner; while ($atom ne '}') { $t = process_item(keys %maskhash); if ($t) { $inner .= "else " . $t; $inner_count++; } } } else { die "expected ';' or '{' got $atom" if $atom ne ';'; } if ($inner_count==1) { $execute .= $inner; } elsif ($inner_count>=2) { $inner .= "else break;\n"; $inner =~ s/^/ /gm; $execute .= "while (1) {\n$inner}\n"; } $atom = shift @atomlist; $execute =~ s/^/ /gm; #$t=$title_item; #$t =~ s/\n/\\n/sg; #$t =~ s/\"/\\\"/g; #$title_item = "(printf(\"checking $t i = %d (%s)\\n\",i,argv[i])||1) && ($title_item)"; $execute = "if ($title_item) {\n$execute}\n"; return $execute; } sub process_expire { my $title_item; $title_item = title_item; while ($atom eq '|') { $atom = shift @atomlist; $title_item .= " ||\n " . title_item; } die "expected ':'\n" if $atom ne ':'; my $type; my $execute = ''; while ($atom =~ /^(\:|\,)$/) { $atom = shift @atomlist; $type = $atom; last if $atom eq '{'; $atom = shift @atomlist; my $field = $atom; $atom = shift @atomlist; my $mask = $atom; $atom = shift @atomlist; die "expected three fields\n" if !defined($atom); #$execute .= "printf(\"executing for $type $field $mask\\n\");\n"; if ($type =~ /^MASK\_(.*)$/) { if ($field eq 'enabled_ctrls') { ($axmask,$axvalues) = ('axt_ctrls_mask','axt_ctrls_values'); } elsif ($field eq 'ax_options') { ($axmask,$axvalues) = ('axt_opts_mask','axt_opts_values'); } else { ($axmask,$axvalues) = ('',''); } if ($axmask) { $execute .= "if (argv[i][0] == '-') {\n" . " ctrls->$axmask |= $1;\n" . " ctrls->$axvalues &= ~$1;\n" . "}\n" . "else if (argv[i][0] == '=') {\n" . " ctrls->$axmask &= ~$1;\n" . " ctrls->$axvalues &= ~$1;\n" . "}\n" . "else {\n" . " ctrls->$axmask |= $1;\n" . " ctrls->$axvalues |= $1;\n" . "}\n"; $temp1 = $title_item; $temp1 =~ s/strcmp\(([^\,]+)\,\"([^\"]+)\"\)/strcmp\($1,\"-$2\"\)/g; $temp2 = $title_item; $temp2 =~ s/strcmp\(([^\,]+)\,\"([^\"]+)\"\)/strcmp\($1,\"\=$2\"\)/g; $title_item .= " ||\n $temp1 ||\n $temp2"; } } } $execute .= "i += inc;\n"; my $inner; my $inner_count = 0; if ($atom eq '{') { $atom = shift @atomlist; $inner = process_expire(); $inner_count++ if $inner; while ($atom ne '}') { $t = process_expire(); if ($t) { $inner .= "else " . $t; $inner_count++; } } } else { die "expected ';' or '{'" if $atom ne ';'; } if ($inner_count==1) { $execute .= $inner; } elsif ($inner_count>=2) { $inner .= "else break;\n"; $inner =~ s/^/ /gm; $execute .= "while (1) {\n$inner}\n"; } $atom = shift @atomlist; $execute =~ s/^/ /gm; #$t=$title_item; #$t =~ s/\n/\\n/sg; #$t =~ s/\"/\\\"/g; #$title_item = "(printf(\"checking $t i = %d (%s)\\n\",i,argv[i])||1) && ($title_item)"; $execute = "if ($title_item) {\n$execute}\n"; return $type =~ /^MASK\_/ ? $execute : ""; } ############ main fetchatoms; $output .= process_item; while ($atom ne 'end') { $output .= "else " . process_item; } $output .= "else return 0;"; $output =~ s/^/ /gm; $vallist = join(', ', map "val$_",(1..$n_max)); fetchatoms; $output_expire = process_expire; while ($atom ne 'end') { $t = process_expire; $output_expire .= "else " . $t if $t; } $output_expire .= "else if ((i+1<=argc && get_number(argv[i],0,65535,&val1) && (inc=1))) {\n" . " ctrls->ax_timeout = val1;\n" . " i += inc;\n" . "}\n" . "else return 0;"; $output_expire =~ s/^/ /gm; open(GETC,">getargs.c"); open(COPY,"COPYRIGHT"); $copy = join '',; print GETC <print.c"); open(CONFIG,"config_print"); $output = ''; $outputline = ''; $last_needs_mask = ''; $last_needs_enum = ''; while ($line = ) { next if $line =~ /^\#/ || $line =~ /^\s*$/; if ($line =~ /^[A-Z]/) { ($type,$field,@title) = split ' ',$line; $title = join ' ',@title; if ($type =~ /^MASK\_(.*)$/) { $output .= "printf(\"$title = %s\\n\", (ctrls->$field & $1)?\"On\":\"Off\");\n"; die "mask error\n" if !$last_needs_mask; $last_needs_mask_head = substr $last_needs_mask, 0, 1; $last_needs_mask_tail = substr $last_needs_mask, 1; $outputline .= "printf(\" %s%s\", ctrls->$field & $1?\"\":\"$last_needs_mask_head\", \"$last_needs_mask_tail\");\n"; $last_needs_mask = ''; } elsif ($last_needs_mask) { die "mask error\n"; } elsif ($type =~/^(USHORT|SHORT|UCHAR)$/) { $output .= "printf(\"$title = %d\\n\", ctrls->$field);\n"; $outputline .= "printf(\" %d\", ctrls->$field);\n"; } elsif ($type eq 'CHAR_ARRAY_32') { $output .= "printf(\"$title =\");\n" . "for (i=0;i<32;i++) {\n" . " if (i%8==0) printf(\"\\n \");\n" . " printf(\"%x%x\",ctrls->$field\[i]>>4,ctrls->$field\[i]&15);\n" . "}\n" . "printf(\"\\n\");\n"; $outputline .= "printf(\" \");\n" . "for (i=0;i<32;i++)\n" . " printf(\"%x%x\",ctrls->$field\[i]>>4,ctrls->$field\[i]&15);\n"; } elsif ($type eq 'HIGH_NIBBLE_ENUM') { die "enum error\n" if !$last_needs_enum; $output .= "printf(\"$title = \");\n"; $outputline .= "s = NULL;\n"; $line = ; $line =~ s/\s//g; $first = 1; foreach $enum (split ',',$line) { ($code,$value) = split '=',$enum; $output .= (!$first?"else ":"") . "if ((ctrls->$field & 0xF0) == $value) printf(\"$code\\n\");\n"; $outputline .= (!$first?"else ":"") . "if ((ctrls->$field & 0xF0)== $value) s = \"$code\";\n"; $first = 0; } $output .= "else printf(\"undefined\\n\");\n"; $outputline .= "if (s!=NULL) printf(\" " . substr($last_needs_enum,1) . " %s\",s);\n"; $last_needs_enum = 0; } elsif ($type eq 'LOW_NIBBLE_IF_HIGH_NIBBLE_ENUM') { $output .= "printf(\"$title = %d\\n\", ctrls->$field & 0x0F);\n"; $outputline .= "print_nibble = 0;\n"; $line = ; $line =~ s/\s//g; $first = 1; foreach $enum (split ',',$line) { ($code,$value) = split '=',$enum; $outputline .= (!$first?"else ":"") . "if ((ctrls->$field & 0xF0)== $value) print_nibble = 1;\n"; $first = 0; } $outputline .= "if (print_nibble) printf(\" %d\", ctrls->$field & 0x0F);\n"; $last_needs_enum = 0; } else { die "syntax error"; } } else { chomp($line); if ($line =~ /^\-/) { $last_needs_mask = $line; } elsif ($line =~ /^\+/) { $last_needs_enum = $line; } else { $outputline .= "printf(\" $line\");\n"; } } } $output =~ s/^/ /gm; $outputline =~ s/^/ /gm; close CONFIG; open(COPY,"COPYRIGHT"); $copy = join '',; print PRINTC <) { next if $line =~ /^\#/ || $line =~ /^\s*$/; if ($line =~ /^[A-Z]/) { ($type,$field,@title) = split ' ',$line; $title = join ' ',@title; if ($type =~ /^MASK\_(.*)$/) { if ($field eq 'enabled_ctrls') { ($axmask,$axvalues) = ('axt_ctrls_mask','axt_ctrls_values'); } elsif ($field eq 'ax_options') { ($axmask,$axvalues) = ('axt_opts_mask','axt_opts_values'); } else { ($axmask,$axvalues) = ('',''); } if ($axmask) { $output .= "printf(\"Upon Expiry $title will be: %s\\n\",\n" . " (ctrls->$axmask & $1)?((ctrls->$axvalues & $1)?\"On\":\"Off\"):\"Unchanged\");\n"; $t = substr $last_needs_mask,1; $outputline .= "printf(\" %s$t\",\n" . " (ctrls->$axmask & $1)?((ctrls->$axvalues & $1)?\"\":\"-\"):\"=\");\n"; $last_needs_mask = ''; } } elsif ($last_needs_mask) { die "mask error\n"; } } else { chomp($line); if ($line =~ /^\-/) { $last_needs_mask = $line; } } } $output =~ s/^/ /gm; $outputline =~ s/^/ /gm; close CONFIG; print PRINTC <ax_timeout); $output } void print_expire_controls_in_line(XkbControlsPtr ctrls) { printf(\"xkbset exp %d\",ctrls->ax_timeout); $outputline printf(\"\\n\"); } EOM xkbset-0.8/create_usage000066400000000000000000000213501425614243000152350ustar00rootroot00000000000000#!/usr/bin/perl -w # Copyright (c) 2000, 2002, 2021 Stephen Montgomery-Smith # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of Stephen Montgomery-Smith nor the names of his # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE STEPHEN MONTGOMERY-SMITH AND CONTRIBUTORS # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STEPHEN MONTGOMERY-SMITH OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # Split configuration file into atoms in @atomlist. sub fetchatoms { @atomlist = (); open(CONFIG,"config_getargs"); while ($line = ) { if ($line =~ /^\#/) { # store comments verbatum. push(@atomlist,$line); } else { while (1) { next if ($line =~ s/^\s+//); # Remove whitespace. if ($line =~ s/^\"([^\"]*)\"//) {} # get things in quotes verbatum. elsif ($line =~ s/^([a-zA-Z\_][a-zA-Z\_0-9]*)//) {} # get c-style variable names. elsif ($line =~ s/^(\%\d*[a-zA-Z])//) {} # get printf style tokens. elsif ($line =~ s/^(\S)//) {} # get a single non-whitespace character. else { last } push(@atomlist,$1); } } } close(CONFIG); push(@atomlist,"end"); $atom = shift @atomlist; } sub enum_value { my $enum = ''; $atom = shift @atomlist; $enum = $atom; $atom = shift @atomlist; die if $atom ne '='; $atom = shift @atomlist; $atom = shift @atomlist; return $enum; } sub sub_title_item { my $item; if ($atom =~ /^[a-zA-Z0-9]/) { $item = $atom; } elsif ($atom eq '%d') { $item = "" } elsif ($atom eq '%64x') { $item = "" } elsif ($atom eq '%e') { $atom = shift @atomlist; die "'{' expected at beginning of enum list\n" if $atom ne '{'; $item = enum_value; while ($atom eq ';') { $item .= "|" . enum_value; } $item = "{$item}"; die "'}' expected at end of enum list - got $atom\n" if $atom ne '}'; } $atom = shift @atomlist if defined($item); return $item; } sub title_item { my $title_item = sub_title_item; my $next_item; die "syntax error in title - atom is $atom" if !defined($title_item); while(defined($next_item = sub_title_item)) { $title_item = "$title_item $next_item"; } return $title_item; } sub substitute { @t=(); foreach $t (split /\|/,$_[0]) { $t =~ s/VAL/$_[1]/; push(@t,$t); } return join '|',@t; } sub process_item { my $comment=""; while ($atom =~ /^\#/) { $comment .= "#$1\n" if $atom =~ /^\#C\s*(.*)/; $atom = shift @atomlist; } my $title_item; $title_item = title_item; while ($atom eq '|') { $atom = shift @atomlist; $title_item .= "|" . title_item; } die "expected ':'\n" if $atom ne ':'; my $minus = 0; while ($atom =~ /^(\:|\,)$/) { $atom = shift @atomlist; my $type = $atom; last if $atom eq '{'; $atom = shift @atomlist; my $field = $atom; $atom = shift @atomlist; my $mask = $atom; $atom = shift @atomlist; die "expected three fields\n" if !defined($atom); #$execute .= "printf(\"executing for $type $field $mask\\n\");\n"; if ($type !~ /^MASK\_(.*)$/) { $title_item = substitute($title_item,$field); } $minus = 1 if $type eq 'BIT32' || $type =~ /^MASK\_/; } $t = $title_item; while ($t=~s/\{[^\}]*\}//) {} $title_item = "{$title_item}" if $t =~/\|/; $title_item = "[-]$title_item" if $minus; my $inner; my $inner_count = 0; if ($atom eq '{') { $atom = shift @atomlist; $inner = process_item(); $inner_count++ if $inner; while ($atom ne '}') { $t = process_item(); if ($t) { $inner .= "|" . $t; $inner_count++; } } } else { die "expected ';' or '{'\n" if $atom ne ';'; } if ($inner_count==1) { $execute = " [$inner]"; } elsif ($inner_count>=2) { $execute = " [$inner]..."; } else { $execute = ""; } $atom = shift @atomlist; #$t=$title_item; #$t =~ s/\n/\\n/sg; #$t =~ s/\"/\\\"/g; #$title_item = "(printf(\"checking $t i = %d (%s)\\n\",i,argv[i])||1) && ($title_item)"; $comment = "\n$comment\n" if $comment; $execute = "$comment$title_item$execute"; return $execute; } sub process_expire { while ($atom =~ /^\#/) { $atom = shift @atomlist; } my $title_item; $title_item = title_item; while ($atom eq '|') { $atom = shift @atomlist; $title_item .= "|" . title_item; } die "expected ':'\n" if $atom ne ':'; my $minus = 0; my $execute = ''; while ($atom =~ /^(\:|\,)$/) { $atom = shift @atomlist; my $type = $atom; last if $atom eq '{'; $atom = shift @atomlist; my $field = $atom; $atom = shift @atomlist; my $mask = $atom; $atom = shift @atomlist; die "expected three fields\n" if !defined($atom); #$execute .= "printf(\"executing for $type $field $mask\\n\");\n"; $minus = 1 if $type =~ /^MASK\_(.*)$/; } $t = $title_item; while ($t=~s/\{[^\}]*\}//) {} $title_item = "{$title_item}" if $t =~/\|/; $title_item = "[-|=]$title_item" if $minus; my $inner; my $inner_count = 0; if ($atom eq '{') { $atom = shift @atomlist; $inner = process_expire(); $inner_count++ if $inner; while ($atom ne '}') { $t = process_expire(); if ($t) { $inner .= "|" . $t; $inner_count++; } } } else { die "expected ';' or '{'\n" if $atom ne ';'; } if ($inner_count==1) { $execute = " [$inner]"; } elsif ($inner_count>=2) { $execute = " [$inner]..."; } else { $execute = ""; } $atom = shift @atomlist; #$t=$title_item; #$t =~ s/\n/\\n/sg; #$t =~ s/\"/\\\"/g; #$title_item = "(printf(\"checking $t i = %d (%s)\\n\",i,argv[i])||1) && ($title_item)"; $execute = "$title_item$execute"; return $minus ? $execute : ""; } ############ main fetchatoms; $output .= process_item; while ($atom ne 'end') { $output .= "\n" . process_item; } fetchatoms; $output_expire = "\n" . process_expire; while ($atom ne 'end') { $t = process_expire; $output_expire .= "\n" . $t if $t; } my @output = (); foreach $line(split "\n",$output) { if ($line =~ /\#(.*)/) { push(@output,$1); } else { while (length($line) > 70) { for($i=69;substr($line,$i,1) !~ /\|| /;$i--) {} push(@output," " . substr($line,0,$i+1)); $line = " " . substr($line,$i+1); } push(@output," " . $line); } } $output = join "\n",@output; @output = (); foreach $line(split "\n",$output_expire) { while (length($line) > 70) { for($i=69;substr($line,$i,1) !~ /\|| / || substr($line,$i-1,3) =~ /\-\|\=/;$i--) {} push(@output," " . substr($line,0,$i+1)); $line = " " . substr($line,$i+1); } push(@output," " . $line); } $output_expire = join "\n",@output; $usage = < where may be all or any of (the '-' switches the feature off, otherwise it is switched on): $output To set the AccessX expire controls: xkbset exp where may be all or any of ( is the timeout (in seconds) after which no user activity on X will cause the expiry; '-' indicates the feature will be switched off, '=' incicates the feature will be left unchanged, otherwise it will be switched on): $output_expire To see the current values of the controls: xkbset q To see the current values of what controls will expire: xkbset q exp To have these values written as a command line: xkbset w [exp] To print this help message xkbset [h] EOM $usage =~ s/^(.*)$/ printf\(\"$1\\n\"\);/mg; open(GETC,">usage.c"); open(COPY,"COPYRIGHT"); $copy = join '',; print GETC <=2 && strcmp(argv[1],"exp")==0; /* if (query || write_line) mask = XkbAllControlsMask; The first time we call get_arguments is just to get mask No we don't - XkbGetControls seems buggy with repect to getting ax_options if the mask is selective else if (query_expire || write_line_expire) mask = XkbAccessXTimeoutMask; else if (expire) { if (!get_expire_arguments(argc,argv, &junk, &mask)) { print_usage(); exit(1); } } else if (!get_arguments(argc,argv, &junk, &mask)) { print_usage(); exit(1); } */ display = XkbOpenDisplay(NULL, &event_rtrn, &error_rtrn, &major_in_out, &minor_in_out, &reason_rtrn); if (reason_rtrn != XkbOD_Success) { switch(reason_rtrn) { case XkbOD_BadLibraryVersion: case XkbOD_BadServerVersion: case XkbOD_NonXkbServer: fprintf(stderr,"Non-existent or incompatible XKB library version\n"); break; case XkbOD_ConnectionRefused: fprintf(stderr, "Unable to open display\n"); break; default: fprintf(stderr, "Unknown error in XkbOpenDisplay\n"); break; } exit(1); } xkb = XkbGetKeyboard(display,XkbControlsMask,XkbUseCoreKbd); if (xkb == 0) { fprintf(stderr, "XKB not supported for display %s\n", getenv("DISPLAY")); exit(1); } status = XkbGetControls(display, XkbAccessXTimeoutMask|XkbAllControlsMask, xkb); switch(status) { case Success: break; case BadAlloc: fprintf(stderr,"Allocation error in XkbGetControls\n"); exit(1); case BadMatch: fprintf(stderr,"Bad match in XkbGetControls\n"); exit(1); case BadImplementation: fprintf(stderr,"Bad implementation in XkbGetControls\n"); exit(1); default: fprintf(stderr,"Unknown error in XkbGetControls\n"); exit(1); } if (query) { print_controls(xkb->ctrls); } else if (write_line) { print_controls_in_line(xkb->ctrls); } else if (query_expire) { print_expire_controls(xkb->ctrls); } else if (write_line_expire) { print_expire_controls_in_line(xkb->ctrls); } else if (expire) { if (!get_expire_arguments(argc,argv, xkb->ctrls, &mask)) { print_usage(); exit(1); } XkbSetControls(display, mask, xkb); } else { if (!get_arguments(argc,argv, xkb->ctrls, &mask)) { print_usage(); exit(1); } XkbSetControls(display, mask, xkb); } XCloseDisplay(display); exit(0); } xkbset-0.8/misc.c000066400000000000000000000042731425614243000137670ustar00rootroot00000000000000/* Copyright (c) 2000, 2002 Stephen Montgomery-Smith All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of Stephen Montgomery-Smith nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE STEPHEN MONTGOMERY-SMITH AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STEPHEN MONTGOMERY-SMITH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "xkbset.h" Bool get_number(char *arg, int low, int high, int *val) { int i; for (i=0;i<(int)strlen(arg);i++) if ((arg[i]<'0' || arg[i]>'9') && (i!=0 || arg[0]!='-')) return 0; *val = atoi(arg); if (*valhigh) return 0; return 1; } #define digit(c) ( ((c)>='0'&&(c)<='9')?(c)-'0': \ ((c)>='a'&&(c)<='f')?(c)-'a'+10: \ ((c)>='A'&&(c)<='F')?(c)-'A'+10: \ (success = 0) ) Bool get_64_hex(char *arg, char array[32]) { int i, success = 1; for(i=0;i<64&&success;i++) if (i%2==0) array[i/2] = digit(arg[i])*16; else array[i/2] += digit(arg[i]); return success; } xkbset-0.8/xkbset-gui000077500000000000000000000233601425614243000146760ustar00rootroot00000000000000#!/usr/bin/perl -w # Copyright (c) 2000, 2002 Stephen Montgomery-Smith # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of Stephen Montgomery-Smith nor the names of his # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE STEPHEN MONTGOMERY-SMITH AND CONTRIBUTORS # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STEPHEN MONTGOMERY-SMITH OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. use Tk; my $mousekeys = 0; my $mousekeysaccel = 1; my $mk_delay = 160; my $mk_interval = 40; my $mk_time_to_max = 30; my $mk_max_speed = 30; my $mk_curve = 500; my $mw = MainWindow->new; $mw->title("MouseKeys Acceleration Management"); read_values(`xkbset w`); do_widgets(); MainLoop; sub do_widgets { $outer_frame_mk_delay = $mw->Frame(-borderwidth=>5)->pack; $frame_mk_delay = $outer_frame_mk_delay->Frame(-borderwidth=>2,-relief=>"groove")->pack; $outer_frame_mk_interval = $mw->Frame(-borderwidth=>5)->pack; $frame_mk_interval = $outer_frame_mk_interval->Frame(-borderwidth=>2,-relief=>"groove")->pack; $outer_frame_mk_time_to_max = $mw->Frame(-borderwidth=>5)->pack; $frame_mk_time_to_max = $outer_frame_mk_time_to_max->Frame(-borderwidth=>2,-relief=>"groove")->pack; $outer_frame_mk_max_speed = $mw->Frame(-borderwidth=>5)->pack; $frame_mk_max_speed = $outer_frame_mk_max_speed->Frame(-borderwidth=>2,-relief=>"groove")->pack; $outer_frame_mk_curve = $mw->Frame(-borderwidth=>5)->pack; $frame_mk_curve = $outer_frame_mk_curve->Frame(-borderwidth=>2,-relief=>"groove")->pack; $outer_frame_mouse_buttons = $mw->Frame(-borderwidth=>5)->pack; $frame_mouse_buttons = $outer_frame_mouse_buttons->Frame(-borderwidth=>2,-relief=>"groove")->pack; $outer_frame_canvas = $mw->Frame(-borderwidth=>5)->pack; $frame_canvas = $outer_frame_canvas->Frame(-borderwidth=>2,-relief=>"groove")->pack; $frame_canvas->Label(-textvariable=>\$inform,-justify=>"left") ->pack(-anchor=>"w"); $canvas = $frame_canvas->Canvas(-height=>220,width=>500,-borderwidth=>0) ->pack; $outer_frame_set_buttons = $mw->Frame(-borderwidth=>5)->pack; $frame_set_buttons = $outer_frame_set_buttons->Frame(-borderwidth=>2,-relief=>"groove")->pack; $frame_set_buttons->Button(-text=>"Rescale scales",-command=>\&do_scale_widgets) ->pack(-side=>"left",-expand=>1); $frame_set_buttons->Button(-text=>"Restore values", -command=>sub{read_values(`xkbset w`);do_scale_widgets()}) ->pack(-side=>"left",-expand=>1); $frame_set_buttons->Button(-text=>"Apply Changes",-command=>\&apply_changes) ->pack(-side=>"left",-expand=>1); $frame_set_buttons->Button(-text=>"Quit", -command=>sub{exit}) ->pack(-side=>"left",-expand=>1); do_scale_widgets(); } sub do_scale_widgets { $scale_mk_delay->destroy() if Tk::Exists($scale_mk_delay); $scale_mk_delay = $frame_mk_delay->Scale(-variable=>\$mk_delay, -from=>1,-to=>10+3*$mk_delay,-resolution=>1, -orient=>"horizontal", -command=>\&draw_curve, -borderwidth=>0, -length=>500)->pack; $label_mk_delay->destroy() if Tk::Exists($label_mk_delay); $label_mk_delay = $frame_mk_delay->Label(-text=>"Delay before acceleration starts (milliseconds)" )->pack(-anchor=>"w"); $scale_mk_interval->destroy() if Tk::Exists($scale_mk_interval); $scale_mk_interval = $frame_mk_interval->Scale(-variable=>\$mk_interval, -from=>1,-to=>10+3*$mk_interval,-resolution=>1, -orient=>"horizontal", -command=>\&draw_curve, -borderwidth=>0, -length=>500)->pack; $label_mk_interval->destroy() if Tk::Exists($label_mk_interval); $label_mk_interval = $frame_mk_interval->Label(-text=>"Time between pointer movements (milliseconds)" )->pack(-anchor=>"w"); $scale_mk_time_to_max->destroy() if Tk::Exists($scale_mk_time_to_max); $scale_mk_time_to_max = $frame_mk_time_to_max->Scale(-variable=>\$mk_time_to_max, -from=>1,-to=>10+3*$mk_time_to_max,-resolution=>1, -orient=>"horizontal", -command=>\&draw_curve, -borderwidth=>0, -length=>500)->pack; $label_mk_time_to_max->destroy() if Tk::Exists($label_mk_time_to_max); $label_mk_time_to_max = $frame_mk_time_to_max->Label(-text=>"Number of pointer movements before accleration completed" )->pack(-anchor=>"w"); $scale_mk_max_speed->destroy() if Tk::Exists($scale_mk_max_speed); $scale_mk_max_speed = $frame_mk_max_speed->Scale(-variable=>\$mk_max_speed, -from=>1,-to=>10+3*$mk_max_speed,-resolution=>1, -orient=>"horizontal", -command=>\&draw_curve, -borderwidth=>0, -length=>500)->pack; $label_mk_max_speed->destroy() if Tk::Exists($label_mk_max_speed); $label_mk_max_speed = $frame_mk_max_speed->Label(-text=>"Speed (pixels per pointer movement) after acceleration completed" )->pack(-anchor=>"w"); $mk_curve_to = $mk_curve*3<5000 ? 5000 : 3*$mk_curve; $mk_curve_to = 32000 if $mk_curve_to > 32000; $scale_mk_curve->destroy() if Tk::Exists($scale_mk_curve); $scale_mk_curve = $frame_mk_curve->Scale(-variable=>\$mk_curve, -from=>-1000,-to=>$mk_curve_to,-resolution=>100, -orient=>"horizontal", -command=>\&draw_curve, -borderwidth=>0, -length=>500)->pack; $label_mk_curve->destroy() if Tk::Exists($label_mk_curve); $label_mk_curve = $frame_mk_curve->Label(-text=>"Acceleration curve factor" )->pack(-anchor=>"w"); $mousekeysinfo=$mousekeys? "MouseKeys Enabled": "MouseKeys Disabled"; $mouse_button->destroy() if Tk::Exists($mouse_button); $mouse_button = $frame_mouse_buttons->Button(-textvariable=>\$mousekeysinfo, -command=>sub{$mousekeys^=1; $mousekeysinfo=$mousekeys? "MouseKeys Enabled": "MouseKeys Disabled"}) ->pack(-side=>"left",-expand=>1); $mousekeysaccelinfo=$mousekeysaccel? "Acceleration Enabled": "Acceleration Disabled"; $mouseaccel_button->destroy() if Tk::Exists($mouseaccel_button); $mouseaccel_button = $frame_mouse_buttons->Button(-textvariable=>\$mousekeysaccelinfo, -command=>sub{$mousekeysaccel^=1; $mousekeysaccelinfo=$mousekeysaccel? "Acceleration Enabled": "Acceleration Disabled"}) ->pack(-side=>"left",-expand=>1); } sub draw_curve { my $alpha = 1 + $mk_curve/1000; my @coords; $canvas->delete("all"); $xscale = 500/($mk_delay+$mk_time_to_max*$mk_interval*1.5); @coords = (0,10+210,$mk_delay*$xscale,10+210, $mk_delay*$xscale,10+200*(1-1/$mk_max_speed)); if ($alpha == 0) { push(@coords,$mk_delay*$xscale,10,500,10); } else { if ($mk_time_to_max > 0) { # for ($n=0;$n<=$mk_time_to_max+0.05;$n+=0.1) { for ($t=0;$t<=100;$t++) { $n=$t*$mk_time_to_max/100; $x=$mk_delay+$n*$mk_interval; $y=(1+($mk_max_speed-1)*pow($n/$mk_time_to_max,$alpha))/$mk_max_speed; push(@coords,$x*$xscale,10+200*(1-$y)); } } else { # ??? push(@coords, } } push(@coords,500,10); $canvas->createLine(@coords); $canvas->createText($mk_delay*$xscale,210, -text=>$mk_delay . " ms",-anchor=>"w"); $canvas->createText(0,10+200*(1-1/$mk_max_speed), -text=>int(1000/$mk_interval) . " pix/s",-anchor=>"sw") if $mk_max_speed != 1; $canvas->createText(0,10, -text=>int(1000*$mk_max_speed/$mk_interval) . " pix/s",-anchor=>"w"); $canvas->createText(($mk_delay+$mk_time_to_max*$mk_interval)*$xscale,210, -text=>($mk_delay+$mk_time_to_max*$mk_interval)." ms"); $inform = "Total time until full acceleration is " . ($mk_delay+$mk_time_to_max*$mk_interval) . " milliseconds\n" . "Initial speed is " . int(1000/$mk_interval) . " pixels per second\n" . "Max speed is " . int(1000*$mk_max_speed/$mk_interval) . " pixels per second\n\n" . "Velocity/Time graph"; } sub pow { return $_[0] == 0 ? 0 : exp($_[1]*log($_[0])); } sub read_values { if ($_[0] =~ / (\-?)ma (\d+) (\d+) (\d+) (\d+) (\d+) /) { $mousekeysaccel = $1 ne '-'; $mk_delay = $2; $mk_interval = $3; $mk_time_to_max = $4; $mk_max_speed = $5; $mk_curve = $6; } if ($_[0] =~ / (\-?)m /) { $mousekeys = $1 ne '-'; } } sub apply_changes { system "xkbset " . ($mousekeys?"":"-") . "m " . ($mousekeysaccel?"":"-") . "ma $mk_delay $mk_interval $mk_time_to_max $mk_max_speed $mk_curve"; } xkbset-0.8/xkbset.h000066400000000000000000000041541425614243000143370ustar00rootroot00000000000000/* Copyright (c) 2000, 2002 Stephen Montgomery-Smith All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of Stephen Montgomery-Smith nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE STEPHEN MONTGOMERY-SMITH AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STEPHEN MONTGOMERY-SMITH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include Bool get_arguments(int argc, char *argv[], XkbControlsPtr ctrls, unsigned int *mask); Bool get_expire_arguments(int argc, char *argv[], XkbControlsPtr ctrls, unsigned int *mask); Bool get_number(char *arg, int low, int high, int *val); Bool get_64_hex(char *arg, char array[32]); void print_controls(XkbControlsPtr ctrls); void print_controls_in_line(XkbControlsPtr ctrls); void print_expire_controls(XkbControlsPtr ctrls); void print_expire_controls_in_line(XkbControlsPtr ctrls); void print_usage(); xkbset-0.8/xkbset.man000066400000000000000000000127261425614243000146670ustar00rootroot00000000000000.\" Copyright (c) 2000, 2002 Stephen Montgomery-Smith .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of Stephen Montgomery-Smith nor the names of his .\" contributors may be used to endorse or promote products derived from .\" this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE STEPHEN MONTGOMERY-SMITH AND CONTRIBUTORS .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STEPHEN MONTGOMERY-SMITH OR .\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, .\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT .\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" .TH XKBSET 1 "Release 6.4" "X Version 11" .SH NAME xkbset - user preference utility for XKB extensions for X .SH SYNOPSIS .B xkbset h | \fIoptions\fP | exp \fIexpire-options\fP | q [exp] | w [exp] where \fIoptions\fP are any or all of: [-]{bell | b} [-]{repeatkeys \fIper-key_repeat> | r [