Script to handle a printer and feed it w/social media content from any linux computer.
This program is under development, not ready for producive use. See TODO for a (incomplete) list of open tasks and features
See INTPRN for more informations about the project, this software is part of.
Tested with Ubuntu 16.04 and Raspian 4.1 + Raspian 4.9 (for Raspberry Pi)
Ruby 2.x, Rubygems, CUPS 2.1.3, Wiringpi (Binding for gpio), Rubgems, Rake, Rspec 3.5.0, ActiveRecord, SQLite3, GIT
Raspian 4.9 has Ruby 2.3 and gpio 2.44
Install CUPS
$ sudo apt-get install libcups2 libcups2-dev
You'll need a printer installed, at least install CUPS-PDF to have a print-to-file option:
$ sudo apt-get install cups-pdf
(The files will saved at /home/your-username/PDF )
Install Wiringpi (only needed if you want install an external button, see below). See Wiringpi.com for detailed instruction
Install Bundler
$ sudo gem install bundler
Get PRNTSTN code via Github (read-only)
$ git clone https://github.com/ut/PRNSTN.git
Install the needed gems with Bundler:
$ cd PRNSTN
$ bundle install
If you have trouble for the native extension FFI and get a message like...
An error occurred while installing ffi (1.9.14), and Bundler cannot continue.
...install ruby-dev and then try to install ffi again
$ sudo apt-get install ruby-dev
$ sudo gem install ffi -v '1.9.14'
If you have trouble installing the native extension Rainbow and get a message like
An error occurred while installing rainbow (2.2.2), and Bundler cannot continue.
...install rake and then try to install rainbow again
$ sudo gem install rake
$ sudo gem install ffi -v '1.9.14'
If you have trouble installing the native extension SQLite3 and get a message like
An error occurred while installing sqlite3 (1.3.12), and Bundler cannot continue.
...install libsqlite3-dev and then try to install SQLite3 again
$ sudo apt-get install libsqlite3-dev
$ sudo gem install sqlite3 -v '1.3.12'
To communicate with the Internet printer, it needs its own social media channel. You can either setup a GNU Social or Twitter account. Other platforms may be included in the future (you are welcome to contribute to this project by adding your favorite platform).
Create a profile at your favorite GNU Social installation. Check the sourcecode of the profile page or ask the admins for your ID and the API URL.
Edit lib/prnstn/config.rb:
GNUSOCIAL_ID = '...'
GNUSOCIAL_MENTIONS_ENDPOINT = 'https://your.gnusocial.installation/api/statuses/mentions/'+GNUSOCIAL_ID+'.json'
Create a Twitter application via apps.twitter.com and export the following credentials into your local environment:
$ export CONSUMER_KEY="..."
$ export CONSUMER_SECRET="..."
$ export ACCESS_TOKEN="..."
$ export ACCESS_TOKEN_SECRET="..."
$ ./bin/prnstn
Per default, the PRNTSTN runs in dry mode (without printing anything).
Show all parameters:
$ ./bin/prnstn -h
At /etc/rd.local add the following line
sudo -u USER -i /home/USER/start_prnstn.sh
At home directory, create start_prnstn.sh
$ nano /home/USER/start_prnstn.sh
and add the following lines
#!/bin/bash
#
# Start PRNSTN
cd /home/USER/PRNSTN/
export CONSUMER_KEY="...."
export CONSUMER_SECRET="...."
export ACCESS_TOKEN="...."
export ACCESS_TOKEN_SECRET="...."
./bin/prnstn -s twitter -p 1 -D
Another approach would be defining a startup script at systemd
On Raspberry Pi, an external button can be used to print latest messages. See INTPRN for the hardware needed.
Since we use Raspberry Pi GPIO for that, we need to run this script as root!
If the following error ocurrs:
`require': cannot load such file -- twitter (LoadError)
then install the cli version of the Twitter gem
$ sudo gem install t
If you are using the ONPUSH mode and get the following message
Unable to determine hardware version. I see: Hardware : BCM2835
- expecting BCM2708 or BCM2709.
... then you are probably using an outdated version of wiringpi (e.g. as standard package). Visit Wiringpi.com and re-install wiringpi
Bug reports and pull requests are welcome on GitHub at https://github.com/ut/prnstn. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
A project by Ulf Treger [email protected] as part of
Running via CLI and as a daemonized script based on a concept by Jake Gordon at Daemonizing Ruby Processes
This project is licensed under a GNU General Public Licence v3.