diff --git a/README.md b/README.md index 7615e84..a4b449f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,11 @@ and TTYs. With `go`, `libxkbcommon-dev` and `scdoc` installed, run: - sudo ./install.sh + ./build.sh && sudo ./build.sh install + +And to trigger the udev rule, run: + + sudo udevadm control --reload && sudo udevadm trigger ## Usage diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..1cd653f --- /dev/null +++ b/build.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# ./build.sh ['install'] +: "${DOTOOL_VERSION=$(git describe --long --abbrev=12 --tags --dirty 2>/dev/null || echo 1.3)}" +: "${DOTOOL_DESTDIR=}" +: "${DOTOOL_BINDIR=usr/local/bin}" +: "${DOTOOL_UDEV_RULES_DIR=etc/udev/rules.d}" + +if [ "$*" != '' ] && [ "$*" != install ]; then + echo bad usage + exit 1 +fi + +if ! [ "$1" ]; then + go build -ldflags "-X main.Version=$DOTOOL_VERSION" || exit + echo Built Successfully. +else + install -Dm755 dotool dotoolc dotoold -t "$DOTOOL_DESTDIR/$DOTOOL_BINDIR" || exit + install -Dm644 80-dotool.rules -t "$DOTOOL_DESTDIR/$DOTOOL_UDEV_RULES_DIR" || exit + mkdir -p "$DOTOOL_DESTDIR/usr/share/man/man1" || exit + scdoc < doc/dotool.1.scd > "$DOTOOL_DESTDIR/usr/share/man/man1/dotool.1" || exit + echo Installed Successfully. +fi diff --git a/install.sh b/install.sh deleted file mode 100755 index 3055dca..0000000 --- a/install.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -# ./install.sh [DESTDIR] [BINDIR] -: "${DOTOOL_VERSION=$(git describe --long --abbrev=12 --tags --dirty 2>/dev/null || echo 1.3)}" - -go build -buildvcs=false -ldflags "-X main.Version=$DOTOOL_VERSION" || exit -mkdir -p "$1/${2:-usr/local/bin}" || exit -cp -v dotool dotoolc dotoold "$1/${2:-usr/local/bin}" || exit -mkdir -p "$1/etc/udev/rules.d" || exit -cp -v 80-dotool.rules "$1/etc/udev/rules.d" || exit - -# Remove files from before the keyboard layout approach changed -rm -f "$1/usr/share/X11/xorg.conf.d/50-dotool.conf" -rm -f "$1/etc/sway/config.d/dotool" - -# Make the new/updated udev rule effective -udevadm control --reload -udevadm trigger diff --git a/uninstall.sh b/uninstall.sh index b723ee2..d1ec5dd 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,3 +1,4 @@ #!/bin/sh rm -vf /usr/local/bin/dotool /usr/local/bin/dotoolc /usr/local/bin/dotoold rm -vf /etc/udev/rules.d/80-dotool.rules +rm -vf /usr/share/man/man1/dotool.1