Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Udev rules #3

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion 91-g13.rules

This file was deleted.

2 changes: 2 additions & 0 deletions 91-g13.rules.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c21c", MODE="0660", GROUP="!!GROUP!!"
KERNEL=="uinput", SUBSYSTEM=="misc", MODE="0660", GROUP="!!GROUP!!"
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
all: g13d pbm2lpbm
GROUP = 'usb'
PREFIX = '.'

all: g13d pbm2lpbm 91-g13.rules clock.sh

g13d: g13.h g13.cc
g++ -o g13d -std=c++0x g13.cc -lusb-1.0

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
cp g13.cc g13.h logo.h Makefile pbm2lpbm.c g13-userspace
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
34 changes: 32 additions & 2 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,41 @@
** 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:

> make PREFIX=/usr/local/bin

** 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 PREFIX='/usr/local/bin' 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:

> make clean
> make GROUP='newgroup'

** Running
Connect your device, then run ./g13, it should automatically find your device.
Expand Down Expand Up @@ -50,4 +80,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.
This code is placed in the public domain. Do with it whatever you want.
6 changes: 5 additions & 1 deletion clock.sh → clock.sh.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/bash

PATH=$PATH:!!PREFIX!!
export PATH

center_x=30
center_y=20
diameter=18
Expand Down Expand Up @@ -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