From b59a93b163e520e468bb7e57596adcca8b0b6e84 Mon Sep 17 00:00:00 2001 From: Vangamar Date: Sat, 23 Apr 2016 07:26:36 -0500 Subject: [PATCH] Created shell script to launch g13d with a .bind file (markdown) --- ...script-to-launch-g13d-with-a-.bind-file.md | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 shell-script-to-launch-g13d-with-a-.bind-file.md diff --git a/shell-script-to-launch-g13d-with-a-.bind-file.md b/shell-script-to-launch-g13d-with-a-.bind-file.md new file mode 100644 index 0000000..a0c267a --- /dev/null +++ b/shell-script-to-launch-g13d-with-a-.bind-file.md @@ -0,0 +1,39 @@ +This shell script automates running g13d from the command line and passing in a given .bind file. + +**WARNING:** It might not be the best way, but I just do a **sudo chmod +w** on a couple usb/input device folders, so that I can run g13d as normal user vs. root. + +If you disagree with this approach, delete the two **sudo chmod** lines, or never use this script, or edit this script to show a better way - this way works, though ;-) + + #!/bin/bash + + if [ ! -s "./g13d" ] ; then + echo "ERROR:" + echo " Make a sym link to this shell script in the appropriate" + echo " distro sub-dir, then run the sym link from that sub-dir." + echo "EXAMPLE:" + echo " cd Ubuntu15.10 ; ln -s ../load_bind.sh" + exit 1; + fi + + if [ "$1" == "" ] ; then + echo "ERROR:" + echo " Enter the G13 Bind File as an argument." + exit 1 + fi + + if [ -s "$1" ] ; then bindFile="$1" + elif [ -s "$1.bind" ] ; then bindFile="$1.bind" + elif [ -s "../$1" ] ; then bindFile="../$1" + elif [ -s "../$1.bind" ] ; then bindFile="../$1.bind" + else + echo "ERROR:" + echo " The G13 Bind File: \"$1\" does not exist" + exit 1 + fi + + # This /tmp config file is read in by g13d at startup + cat "$bindFile" > /tmp/g13-0 + # Fixes no write access to usb device + sudo chmod a+rw -R /dev/bus/usb/* + sudo chmod a+rw /dev/uinput + ./g13d