From 48052ab40d8b98f1454fa3ff4e7032ca1ffca760 Mon Sep 17 00:00:00 2001 From: gnidorah Date: Wed, 26 Feb 2020 18:39:45 +0300 Subject: [PATCH] use makefile --- Makefile | 21 +++++++++++++++++++++ README.md | 16 ++++++---------- build.sh | 14 -------------- 3 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 Makefile delete mode 100755 build.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6e3a964 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +CC = gcc +PREFIX = /usr/local +BINDIR = $(DESTDIR)$(PREFIX)/bin +UDEVDIR = $(DESTDIR)/etc/udev/rules.d + +all: k380_conf + +k380_conf: + $(CC) k380_conf.c -o k380_conf + +reload: + udevadm control --reload + +install: k380_conf + install -d $(BINDIR) + install k380_conf fn_on.sh $(BINDIR) + install -d $(UDEVDIR) + echo "ACTION==\"add\", KERNEL==\"hidraw[0-9]*\", RUN+=\"$(BINDIR)/fn_on.sh /dev/%k\"" > $(UDEVDIR)/80-k380.rules + +clean: + rm k380_conf diff --git a/README.md b/README.md index 8f00ab6..c6a309b 100644 --- a/README.md +++ b/README.md @@ -3,32 +3,28 @@ Make function keys default on Logitech k380 bluetooth keyboard. ## Instructions -1) First install `gcc`. On Ubuntu run: +1) First install `gcc` and `make`. On Ubuntu run: ``` -sudo apt install gcc +sudo apt install gcc make ``` 2) Download installation files https://github.com/jergusg/k380-function-keys-conf/releases/ (Source code). 3) Connect your K380 keyboard via bluetooth to your computer. -4) Run `build.sh` - -``` -./build.sh -``` +4) Run `make install` 5) To switch keyboard's upper keys to F-keys run: ``` -sudo ./k380_conf -d /dev/hidrawX -f on +sudo k380_conf -d /dev/hidrawX -f on ``` Where X is number of your keyboard hidraw interface. Possibly `0, 1, 2, 3`. ### Switch keys to F-keys automatically -Follow instructions your received when you built `k380_conf`: +After install do the following: ``` -sudo cp /your-build-path/80-k380.rules /etc/udev/rules.d/ && sudo udevadm control --reload +sudo make reload ``` Now, when you reconnect your keyboard it will be automatically switched to F-keys mode. diff --git a/build.sh b/build.sh deleted file mode 100755 index ae76be8..0000000 --- a/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -file=k380_conf -gcc -o $file $file.c - -BUILD_SH=$(readlink -f "$0") -BUILD_PATH=$(dirname "$BUILD_SH") -FN_ON="$BUILD_PATH/fn_on.sh" -UDEV_RULES="$BUILD_PATH/80-k380.rules" - -echo "ACTION==\"add\", KERNEL==\"hidraw[0-9]*\", RUN+=\"$FN_ON /dev/%k\"" > $UDEV_RULES -echo "To automatically turn on fn using udev rules, run the following command" -echo " sudo cp $UDEV_RULES /etc/udev/rules.d/ && sudo udevadm control --reload" -