diff options
-rw-r--r-- | .SRCINFO | 12 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | PKGBUILD | 14 | ||||
-rw-r--r-- | shift-not-pressed.c | 42 | ||||
-rw-r--r-- | shiftpressed.c | 17 |
5 files changed, 56 insertions, 31 deletions
@@ -1,13 +1,13 @@ -pkgbase = shiftpressed - pkgdesc = Detect if shift is pressed in the console +pkgbase = shift-not-pressed + pkgdesc = Detect if shift is NOT pressed in the console pkgver = 1.0.0 pkgrel = 1 - url = https://aur.archlinux.org/packages/shiftpressed + url = https://aur.archlinux.org/packages/shift-not-pressed arch = any license = custom:Public Domain makedepends = gcc - source = shiftpressed.c - sha256sums = f0c5327edf12f63eb74fe6a88928eb926664338eb7da60c8ebce80aabccb3645 + source = shift-not-pressed.c + sha256sums = 7191bd1b8632c877d4473735d60196b6709c1bb26336065b9fd4ba4cb4ce8184 -pkgname = shiftpressed +pkgname = shift-not-pressed diff --git a/.gitignore b/.gitignore index f61b62b6a818..6366f744b0db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ * !PKGBUILD -!shiftpressed.c +!shift-not-pressed.c !.gitignore !.SRCINFO @@ -1,21 +1,21 @@ # Maintainer: Bart De Roy <de dot roy dot bart at gmail dot com> -pkgname=shiftpressed +pkgname=shift-not-pressed pkgver=1.0.0 pkgrel=1 -pkgdesc='Detect if shift is pressed in the console' +pkgdesc='Detect if shift is NOT pressed in the console' arch=('any') -url='https://aur.archlinux.org/packages/shiftpressed' +url='https://aur.archlinux.org/packages/shift-not-pressed' license=('custom:Public Domain') makedepends=('gcc') -source=(shiftpressed.c) -sha256sums=('f0c5327edf12f63eb74fe6a88928eb926664338eb7da60c8ebce80aabccb3645') +source=(shift-not-pressed.c) +sha256sums=('7191bd1b8632c877d4473735d60196b6709c1bb26336065b9fd4ba4cb4ce8184') build() { cd $srcdir - gcc -o shiftpressed shiftpressed.c + gcc -o shift-not-pressed shift-not-pressed.c } package() { cd $srcdir - install -Dm755 shiftpressed "$pkgdir/usr/bin/shiftpressed" + install -Dm755 shift-not-pressed "$pkgdir/usr/bin/shift-not-pressed" } diff --git a/shift-not-pressed.c b/shift-not-pressed.c new file mode 100644 index 000000000000..3493140a188f --- /dev/null +++ b/shift-not-pressed.c @@ -0,0 +1,42 @@ +#include <stdio.h> +#include <stdlib.h> +#include <sys/ioctl.h> +#include <getopt.h> +#include <string.h> +#include <strings.h> + +int main(int argc, char **argv) +{ + char shift_state; + const char* usage = + "Usage: shift-not-pressed [--help]\n\n" + "exit codes:\n" + " 0 (succes) shift was not pressed\n" + " 1 (succes) shift was pressed\n" + " 2 (fail) could not get shift state\n"; + + static struct option lopts[] = { + {"help", no_argument, NULL, 'h'} + }; + int c; + while (1) { + int opti; + c = getopt_long(argc, argv, "h", lopts, &opti); + if (c == -1) { + break; + } + switch (c) { + case 'h': fprintf(stdout, "%s", usage); + exit(0); + break; + default: break; + } + } + + shift_state = 6; + if (ioctl(0, TIOCLINUX, &shift_state) < 0) { + perror("ioctl TIOCLINUX 6 (get shift state)"); + exit(2); + } + exit(shift_state); +} diff --git a/shiftpressed.c b/shiftpressed.c deleted file mode 100644 index 71358ab8b9f9..000000000000 --- a/shiftpressed.c +++ /dev/null @@ -1,17 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -#include <sys/ioctl.h> - -int main() -{ - char shift_state; - - shift_state = 6; - if (ioctl(0, TIOCLINUX, &shift_state) < 0) { - perror("ioctl TIOCLINUX 6 (get shift state)"); - exit(1); - } - printf("%x\n", shift_state); - return 0; -} |