Commit | Line | Data |
---|---|---|
a09e091a JB |
1 | /* |
2 | * Copyright 2002 Red Hat Inc., Durham, North Carolina. | |
3 | * | |
4 | * All Rights Reserved. | |
5 | * | |
6 | * Permission is hereby granted, free of charge, to any person obtaining | |
7 | * a copy of this software and associated documentation files (the | |
8 | * "Software"), to deal in the Software without restriction, including | |
9 | * without limitation on the rights to use, copy, modify, merge, | |
10 | * publish, distribute, sublicense, and/or sell copies of the Software, | |
11 | * and to permit persons to whom the Software is furnished to do so, | |
12 | * subject to the following conditions: | |
13 | * | |
14 | * The above copyright notice and this permission notice (including the | |
15 | * next paragraph) shall be included in all copies or substantial | |
16 | * portions of the Software. | |
17 | * | |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
21 | * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS | |
22 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | |
23 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
25 | * SOFTWARE. | |
26 | */ | |
27 | ||
28 | /* | |
29 | * Authors: | |
30 | * Rickard E. (Rik) Faith <faith@redhat.com> | |
31 | * | |
32 | */ | |
33 | ||
34 | #include <stdio.h> | |
35 | #include <stdlib.h> | |
36 | #include <X11/Xlib.h> | |
37 | ||
38 | static void | |
39 | pkc(XKeyboardControl * kc, unsigned long vm) | |
40 | { | |
41 | if (vm & KBKeyClickPercent) | |
42 | printf(" key_click_percent = %d\n", kc->key_click_percent); | |
43 | if (vm & KBBellPercent) | |
44 | printf(" bell_percent = %d\n", kc->bell_percent); | |
45 | if (vm & KBBellPitch) | |
46 | printf(" bell_pitch = %d\n", kc->bell_pitch); | |
47 | if (vm & KBBellDuration) | |
48 | printf(" bell_duration = %d\n", kc->bell_duration); | |
49 | if (vm & KBLed) | |
50 | printf(" led = 0x%x\n", kc->led); | |
51 | if (vm & KBLedMode) | |
52 | printf(" led_mode = %d\n", kc->led_mode); | |
53 | if (vm & KBKey) | |
54 | printf(" key = %d\n", kc->key); | |
55 | if (vm & KBAutoRepeatMode) | |
56 | printf(" auto_repeat_mode = %d\n", kc->auto_repeat_mode); | |
57 | } | |
58 | ||
59 | static void | |
60 | pks(XKeyboardState * ks) | |
61 | { | |
62 | printf(" key_click_percent = %d\n", ks->key_click_percent); | |
63 | printf(" bell_percent = %d\n", ks->bell_percent); | |
64 | printf(" bell_pitch = %u\n", ks->bell_pitch); | |
65 | printf(" bell_duration = %u\n", ks->bell_duration); | |
66 | printf(" led_mask = 0x%lx\n", ks->led_mask); | |
67 | printf(" global_auto_repeat = %d\n", ks->global_auto_repeat); | |
68 | } | |
69 | ||
70 | int | |
71 | main(int argc, char **argv) | |
72 | { | |
73 | Display *display = XOpenDisplay(NULL); | |
74 | XKeyboardControl kc; | |
75 | XKeyboardState ks; | |
76 | unsigned long vm; | |
77 | ||
78 | if (argc != 5) { | |
79 | printf("Usage: xbell percent baseVolume pitch duration\n"); | |
80 | return 1; | |
81 | } | |
82 | ||
83 | vm = (KBBellPercent | KBBellPitch | KBBellDuration); | |
84 | kc.key_click_percent = atoi(argv[1]); | |
85 | kc.bell_percent = atoi(argv[2]); | |
86 | kc.bell_pitch = atoi(argv[3]); | |
87 | kc.bell_duration = atoi(argv[4]); | |
88 | ||
89 | printf("Setting:\n"); | |
90 | pkc(&kc, vm); | |
91 | XChangeKeyboardControl(display, vm, &kc); | |
92 | ||
93 | printf("Have:\n"); | |
94 | XGetKeyboardControl(display, &ks); | |
95 | pks(&ks); | |
96 | ||
97 | XBell(display, 100); | |
98 | ||
99 | XCloseDisplay(display); | |
100 | return 0; | |
101 | } |