Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions actkbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static int usage() {
" -D, --daemon Launch in daemon mode\n"
" -d, --device <device> Specify the device to use\n"
" -h, --help Show this help text\n"
" -g, --grab Start with device grabbed\n"
" -n, --noexec Do not execute any commands\n"
" -p, --pidfile <file> Use a file to store the PID\n"
" -q, --quiet Suppress all console messages\n"
Expand Down Expand Up @@ -155,13 +156,14 @@ int main(int argc, char **argv) {
key_cmd *cmd;

/* Options */
int help = 0, noexec = 0, version = 0, showexec = 0, showkey = 0;
int grab = 0, help = 0, noexec = 0, version = 0, showexec = 0, showkey = 0;

struct option options[] = {
{ "config", required_argument, 0, 'c' },
{ "daemon", no_argument, 0, 'D' },
{ "device", required_argument, 0, 'd' },
{ "help", no_argument, 0, 'h' },
{ "grab", no_argument, 0, 'g' },
{ "noexec", no_argument, 0, 'n' },
{ "pidfile", required_argument, 0, 'p' },
{ "quiet", no_argument, 0, 'q' },
Expand All @@ -176,7 +178,7 @@ int main(int argc, char **argv) {
while (1) {
int c, option_index = 0;

c = getopt_long (argc, argv, "c:Dd:hp:qnv::Vxsl", options, &option_index);
c = getopt_long (argc, argv, "c:Dd:ghp:qnv::Vxsl", options, &option_index);
if (c == -1)
break;

Expand All @@ -203,7 +205,10 @@ int main(int argc, char **argv) {
case 'h':
help = 1;
break;
case 'n':
case 'g':
grab = 1;
break;
case 'n':
noexec = 1;
break;
case 'p':
Expand Down Expand Up @@ -290,6 +295,9 @@ int main(int argc, char **argv) {
if ((ret = open_dev()) != OK)
return ret;

if (grab)
grab_dev();

/* Verbosity levels over 2 make showkey redundant */
if (verbose > 2)
showkey = 0;
Expand Down