ircterm
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
ircterm [2015-01-11 19:54] – rob | ircterm [2016-10-07 17:04] – [Playing the sound] tim | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== Project Background ==== | + | ===== Project Background |
Rob wanted a way to promote IRC use and make it feel more part of the lab rather than a separate 'IRC club', and also open it up to non-IRC users and provide a way to quickly reply. Similar IRC terminals exist at other hackerspaces, | Rob wanted a way to promote IRC use and make it feel more part of the lab rather than a separate 'IRC club', and also open it up to non-IRC users and provide a way to quickly reply. Similar IRC terminals exist at other hackerspaces, | ||
Line 5: | Line 5: | ||
{{: | {{: | ||
- | ==== Hardware ==== | + | ===== Main Hardware |
- | === Main components === | + | |
- | + | ||
- | | + | |
* Some crappy ' | * Some crappy ' | ||
- | * Optiquest Q22wb (Viewsonic/ | + | * Optiquest Q22wb (Viewsonic/ |
+ | * Wall mount VESA arm | ||
* Also a passive USB 2.0 hub and a small USB keyboard | * Also a passive USB 2.0 hub and a small USB keyboard | ||
{{: | {{: | ||
- | === Piecing it together === | + | ===== Piecing it together |
The Pi is back-powered via the hub, which is in turn back-powered via a small in-line 5v 1A PSU originally for a Zip drive. There are a few of these useful PSUs in use in the lab. The back-powering is a result of only wanting to use bits in the ' | The Pi is back-powered via the hub, which is in turn back-powered via a small in-line 5v 1A PSU originally for a Zip drive. There are a few of these useful PSUs in use in the lab. The back-powering is a result of only wanting to use bits in the ' | ||
Line 28: | Line 27: | ||
{{: | {{: | ||
- | === Wifi === | + | ===== Wifi ===== |
Terminal is connected to the main ' | Terminal is connected to the main ' | ||
Line 48: | Line 47: | ||
</ | </ | ||
+ | === Automatically reconnecting wifi === | ||
- | ==== Software ==== | + | / |
+ | < | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | / | ||
+ | < | ||
+ | # | ||
+ | |||
+ | while true ; do | ||
+ | if ifconfig wlan0 | grep -q "inet addr:" ; then | ||
+ | sleep 60 | ||
+ | | ||
+ | ifdown wlan0 | ||
+ | sleep 10 | ||
+ | ifup --force wlan0 | ||
+ | sleep 10 | ||
+ | fi | ||
+ | done | ||
+ | </ | ||
- | === OS Config === | + | ===== OS Config |
Stock Raspbian with all x11-* and various other things removed. | Stock Raspbian with all x11-* and various other things removed. | ||
Line 81: | Line 100: | ||
Terminus font in UTF8, at size 16x32. | Terminus font in UTF8, at size 16x32. | ||
- | === Powering on/off the screen automatically === | + | ===== Powering on/off the screen automatically |
The screen turns off when the lab is empty and turns back on again as soon as someone enters the lab and triggers the PIR. This happens via the message bus and is handled by idle.py which is currently run from rc.local. idle.py was written by Tim initially. | The screen turns off when the lab is empty and turns back on again as soon as someone enters the lab and triggers the PIR. This happens via the message bus and is handled by idle.py which is currently run from rc.local. idle.py was written by Tim initially. | ||
Line 92: | Line 111: | ||
/ | / | ||
< | < | ||
- | # | + | #!/usr/bin/env python |
- | import | + | import |
- | import | + | import |
- | import pika | + | |
- | import time | + | |
- | logging.getLogger('' | + | last_state = None |
- | logging.getLogger(' | + | |
- | amqp_host = "amqp.hacklab" | + | def on_connect(client, |
- | amqp_exchange = " | + | client.subscribe("sensor/ |
- | topic = " | + | |
- | tvstate = False | + | def on_message(client, |
+ | global last_state | ||
- | connection = pika.BlockingConnection(pika.ConnectionParameters(host=amqp_host)) | + | # ignore retained |
- | channel = connection.channel() | + | #if msg.retain: |
- | channel.exchange_declare(exchange=amqp_exchange, | + | # |
- | result | + | if last_state != msg.payload: |
- | queue_name = result.method.queue | + | # state has changed |
- | channel.queue_bind(exchange=amqp_exchange, queue=queue_name, routing_key=topic) | + | if msg.payload == " |
+ | # screen on | ||
+ | subprocess.call(" | ||
+ | elif msg.payload == " | ||
+ | # screen off | ||
+ | subprocess.call(" | ||
+ | last_state = msg.payload | ||
- | def callback(ch, method, properties, body): | + | m = mqtt.Client() |
- | | + | m.on_connect = on_connect |
+ | m.on_message = on_message | ||
+ | m.connect(" | ||
+ | m.loop_forever() | ||
+ | </ | ||
- | changed = properties.headers[' | + | Required to run: |
- | state = properties.headers[' | + | |
- | old_state = properties.headers.get(' | + | |
- | + | ||
- | if state == ' | + | |
- | if tvstate == False: | + | |
- | os.system(" | + | |
- | tvstate = True | + | |
- | elif state == ' | + | |
- | os.system(" | + | |
- | tvstate = False | + | |
- | channel.basic_consume(callback, | + | < |
- | | + | apt-get install python-pip |
- | | + | pip install paho-mqtt |
- | channel.start_consuming() | + | |
</ | </ | ||
- | Required | + | Log file of TV status (due to people wondering if it doesn' |
< | < | ||
- | apt-get install python-pika | + | ~/idle.log |
</ | </ | ||
- | === Irssi config === | + | ===== Irssi config |
Summary: | Summary: | ||
Line 387: | Line 402: | ||
- | === Playing the sound === | + | ===== Playing the sound ===== |
Part of the ' | Part of the ' | ||
* / | * / | ||
- | * / | ||
- | |||
- | The following was required for hacksense.py but has been suggested by Tim that any Redis stuff should be removed from hacksense.py instead. | ||
- | |||
- | < | ||
- | apt-get install python-redis | ||
- | </ | ||
* uhoh.mp3 is on doorbot which has the speaker attached to it. | * uhoh.mp3 is on doorbot which has the speaker attached to it. | ||
In irssi config: beep_cmd = "/ | In irssi config: beep_cmd = "/ |
ircterm.txt · Last modified: 2021-05-21 14:00 by simon