From 8b19f2f59a40dd2ba99d057fcf8200232a7e72e5 Mon Sep 17 00:00:00 2001 From: Stephen Carpenter Date: Thu, 5 Mar 2015 09:42:54 -0500 Subject: [PATCH 1/8] Update udev rules to use group g13 and mode 660 --- 91-g13.rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/91-g13.rules b/91-g13.rules index 7926d4e..e8d2d0d 100644 --- a/91-g13.rules +++ b/91-g13.rules @@ -1 +1 @@ -SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c21c", MODE="0666" \ No newline at end of file +SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c21c", MODE="0660", GROUP="g13" From 4fd93912db3c8b40a0ca2d675d03587dffb1c856 Mon Sep 17 00:00:00 2001 From: Stephen Carpenter Date: Thu, 5 Mar 2015 10:15:15 -0500 Subject: [PATCH 2/8] Fix for uinput write permissions --- 91-g13.rules | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/91-g13.rules b/91-g13.rules index e8d2d0d..a00bd54 100644 --- a/91-g13.rules +++ b/91-g13.rules @@ -1 +1,2 @@ -SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c21c", MODE="0660", GROUP="g13" +SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c21c", MODE="0660", GROUP="usb" +KERNEL=="uinput", SUBSYSTEM=="misc", MODE="0660", GROUP="usb" From ea5d4c11919ee301b11ac8884054eb1d2c7e6694 Mon Sep 17 00:00:00 2001 From: Stephen Carpenter Date: Thu, 5 Mar 2015 12:17:15 -0500 Subject: [PATCH 3/8] Updated Build for Install and udev rules for group Makefile now builds udev rules and clock. make install will now install files in /usr/local/g13-userspace use PREFIX to override location --- 91-g13.rules | 2 -- 91-g13.rules.tmpl | 2 ++ Makefile | 18 ++++++++++++++++-- clock.sh => clock.sh.tmpl | 6 +++++- 4 files changed, 23 insertions(+), 5 deletions(-) delete mode 100644 91-g13.rules create mode 100644 91-g13.rules.tmpl rename clock.sh => clock.sh.tmpl (93%) diff --git a/91-g13.rules b/91-g13.rules deleted file mode 100644 index a00bd54..0000000 --- a/91-g13.rules +++ /dev/null @@ -1,2 +0,0 @@ -SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c21c", MODE="0660", GROUP="usb" -KERNEL=="uinput", SUBSYSTEM=="misc", MODE="0660", GROUP="usb" diff --git a/91-g13.rules.tmpl b/91-g13.rules.tmpl new file mode 100644 index 0000000..ec56981 --- /dev/null +++ b/91-g13.rules.tmpl @@ -0,0 +1,2 @@ +SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c21c", MODE="0660", GROUP="!!GROUP!!" +KERNEL=="uinput", SUBSYSTEM=="misc", MODE="0660", GROUP="!!GROUP!!" diff --git a/Makefile b/Makefile index ee53160..0ad65a3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ -all: g13d pbm2lpbm +GROUP='usb' +PREFIX='/usr/local/g13-userspace' + +all: g13d pbm2lpbm 91-g13.rules clock.sh g13d: g13.h g13.cc g++ -o g13d -std=c++0x g13.cc -lusb-1.0 @@ -6,6 +9,17 @@ g13d: g13.h g13.cc pbm2lpbm: pbm2lpbm.c g++ -o pbm2lpbm pbm2lpbm.c +91-g13.rules: 91-g13.rules.tmpl + sed 's/!!GROUP!!/${GROUP}/' 91-g13.rules.tmpl > 91-g13.rules + +clock.sh: clock.sh.tmpl + sed 's|\!\!PREFIX\!\!|${PREFIX}|' clock.sh.tmpl > clock.sh + +install: all + install -m 755 -D g13d ${PREFIX}/g13d + install -m 755 -D clock.sh ${PREFIX}/g13-clock.sh + install -m 755 -D pbm2lpbm ${PREFIX}/pbm2lpbm + package: rm -Rf g13-userspace mkdir g13-userspace @@ -13,4 +27,4 @@ package: tar cjf g13-userspace.tbz2 g13-userspace rm -Rf g13-userspace clean: - rm -f g13 pbm2lpbm \ No newline at end of file + rm -f g13 pbm2lpbm diff --git a/clock.sh b/clock.sh.tmpl similarity index 93% rename from clock.sh rename to clock.sh.tmpl index 555ed58..cc0e2fe 100755 --- a/clock.sh +++ b/clock.sh.tmpl @@ -1,4 +1,8 @@ #!/bin/bash + +PATH=$PATH:!!PREFIX!! +export PATH + center_x=30 center_y=20 diameter=18 @@ -37,6 +41,6 @@ min_x=$(echo "scale=3;$center_x + $min_orig_y * s($min/60*(2*4*a(1)))" | bc -l) min_y=$(echo "scale=3;$center_y - $min_orig_y * c($min/60*(2*4*a(1)))" | bc -l) preparams="-size 160x43 xc:white -stroke black -fill white -draw \"circle 30,20 30,2\" -draw \"line 30,20 $sec_x,$sec_y\" -draw \"line 30,20 $min_x,$min_y\" -draw \"line 30,20 $hr_x,$hr_y\" " postparams="-pointsize 16 -fill black -font Courier -draw \"text 60,15 '$Date'\" -draw \"text 68,35 '$Time'\" pbm:- " -eval convert $preparams $ticks $postparams | ./pbm2lpbm > /tmp/g13-0 +eval convert $preparams $ticks $postparams | pbm2lpbm > /tmp/g13-0 sleep 1 done From 12fa138687c69853304f4b239b00f518e218c65c Mon Sep 17 00:00:00 2001 From: Stephen Carpenter Date: Thu, 5 Mar 2015 13:41:23 -0500 Subject: [PATCH 4/8] Updated doc for install/group options --- README.org | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index f4f5adb..cc8a27a 100644 --- a/README.org +++ b/README.org @@ -2,11 +2,40 @@ ** Installation Make sure you have boost and libusb-1.0 installed. +You should also create + Compile by running > make -If you want to run the daemon as user, put the file 91-g13.rules into /etc/udev/rules.d/ (or whatever directory your distribution uses). +Note that the default prefix is ".". If you would like make install and +the clock shell script to use a different directory (such as /usr/local/bin) +then use the following: + +> PREFIX=/usr/local/bin make + +** Install for non-root use + +In order to run the g13 deamon as a user, file permissions in /dev +need to be fixed. In order to do this you should do the following: + +1. Create the group: sudo groupadd --system usb +2. add yourself and any other users who will use g13 to the new group: + sudo usermod -a -G usb USERNAME +3. copy the file 91-g13.rules into /etc/udev/rules.d/: + sudo cp 91-g13.rules /etc/udev/rules.d +4. run udevadm trigger +5. run: sudo make install + +If you are logged in as the user, you will need to logout and back in. + +If you have problems check that /etc/udev/rules.d is the correct udev rules +location for your distribution. + +If you would like to change the name of the group used, then use the following +option with make to change it: + +> GROUP='newgroup' make ** Running Connect your device, then run ./g13, it should automatically find your device. @@ -50,4 +79,4 @@ Use pbm2lpbm to convert a pbm image to the correct format, then just cat that in The pbm file must be 160x43 pixels. * License -This code is placed in the public domain. Do with it whatever you want. \ No newline at end of file +This code is placed in the public domain. Do with it whatever you want. From cc15a1415900ae0486ca6a8a6e1d8ac715485c8b Mon Sep 17 00:00:00 2001 From: Stephen Carpenter Date: Thu, 5 Mar 2015 13:43:04 -0500 Subject: [PATCH 5/8] Updated makefile with install and templating --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0ad65a3..5511f12 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ GROUP='usb' -PREFIX='/usr/local/g13-userspace' +PREFIX='.' all: g13d pbm2lpbm 91-g13.rules clock.sh From 44dc136231bd504df5e1b0d0fe17037cbfa24723 Mon Sep 17 00:00:00 2001 From: Stephen Carpenter Date: Thu, 5 Mar 2015 14:56:54 -0500 Subject: [PATCH 6/8] Fixed readme added a make clean to prefix changing instructions --- README.org | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index cc8a27a..242af97 100644 --- a/README.org +++ b/README.org @@ -33,8 +33,9 @@ If you have problems check that /etc/udev/rules.d is the correct udev rules location for your distribution. If you would like to change the name of the group used, then use the following -option with make to change it: +option with make to change it: +> make clean > GROUP='newgroup' make ** Running From b5457f7100123aaebd99752ec6660318bd978439 Mon Sep 17 00:00:00 2001 From: Stephen Carpenter Date: Thu, 5 Mar 2015 15:05:10 -0500 Subject: [PATCH 7/8] Readme corrections New options were calling make incorrectly --- README.org | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index 242af97..e38d982 100644 --- a/README.org +++ b/README.org @@ -12,7 +12,7 @@ Note that the default prefix is ".". If you would like make install and the clock shell script to use a different directory (such as /usr/local/bin) then use the following: -> PREFIX=/usr/local/bin make +> make PREFIX=/usr/local/bin ** Install for non-root use @@ -25,7 +25,7 @@ need to be fixed. In order to do this you should do the following: 3. copy the file 91-g13.rules into /etc/udev/rules.d/: sudo cp 91-g13.rules /etc/udev/rules.d 4. run udevadm trigger -5. run: sudo make install +5. run: sudo make PREFIX='/usr/local/bin' install If you are logged in as the user, you will need to logout and back in. @@ -36,7 +36,7 @@ If you would like to change the name of the group used, then use the following option with make to change it: > make clean -> GROUP='newgroup' make +> make GROUP='newgroup' ** Running Connect your device, then run ./g13, it should automatically find your device. From 6a99719f82f7120c5b8eea5793f923a85a6380e8 Mon Sep 17 00:00:00 2001 From: Stephen Carpenter Date: Thu, 5 Mar 2015 15:07:09 -0500 Subject: [PATCH 8/8] Makefile clean target updated clean target was not cleaning updated templates, fixed --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 5511f12..03c2bca 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -GROUP='usb' -PREFIX='.' +GROUP = 'usb' +PREFIX = '.' all: g13d pbm2lpbm 91-g13.rules clock.sh @@ -27,4 +27,4 @@ package: tar cjf g13-userspace.tbz2 g13-userspace rm -Rf g13-userspace clean: - rm -f g13 pbm2lpbm + rm -f g13 pbm2lpbm clock.sh 91-g13.rules