Low-tech door monitoring with ICQ

Do you want to monitor some door? Get notified when it opens/closes? This is low-tech solution for the trusty old parallel port.

Just solder a Reed-switch and protective resistor to a DB-25 connector. Then run this simple program as daemon to monitor the switch. (This project is about 10 years old. You might consider fancy things like DBUS today…)

I my case the program runs scripts which controls the status of a running ICQ client. The door in question is the front door of our club room. Yeah!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include <unistd.h> /* needed for ioperm() */
#include <asm/io.h> /* for outb() and inb() */
#include <fcntl.h>
#define DATA 0x378
#define STATUS DATA+1
#define CONTROL DATA+2
#define LP_PE 0x04 /* shifted */
int runscript(char *cmd)
{
int ret;
if((ret=fork())==-1) { perror("Fork Failed"); return 1; }
if(ret==0) // child
{
char *args[] = { NULL };
execve(cmd, args, NULL);
perror("Exec Failed"); return 1;
}
wait(&ret); // wait for child
return 0;
}
int main(void)
{
int v, v0;
if (ioperm(DATA,3,1))
{
printf("Sorry, you were not able to gain access to the ports\n");
printf("You must be root to run this program\n");
exit(1);
}
for (;;) {
v = ((inb(STATUS)^0x80) >> 3);
if (v != v0)
if ((v & LP_PE) != 0)
{
//printf("Status: opening\n");
runscript("/root/bin/opendoor");
}
else
{
//printf("Status: closing\n");
runscript("/root/bin/closedoor");
}
v0 = v;
sleep(1);
//usleep(100000);
}
return 0;
}

The script should run some commands (also consider dropping the privileges) but must not stay in the foreground (i.e. needs to terminate). Simple example:

1
2
#!/bin/sh
exec su someuser -l -c /usr/local/bin/opendoor-user

Where opendoor-user would set the status in licq, micq, pidgin, …

MP3 Scan + Repair

The audio repair tool to check and fix all your MP3 files.

Check and repair your MP3 audio files.

Some of your audio players might be picky or play choppy sound. Scan and fix all your MP3 files for best performance! And it's free, too!

MP3 Scan + Repair

Mouse Acceleration for OS X

Set up extended speed parameters for your mouse.

Extended mouse settings

The Mouse Acceleration PrefPane is a GUI and startup item to Richard Bentley's MouseFix.

You can set up extended speed parameters and acceleration curves for your mouse.

  • Increase mouse pointer precision
  • Speed up your mouse movement
  • Set mouse acceleration parameters
  • Full control with just two simple knobs

Mouse Acceleration for OS X

About the Author

Hi there! I'm Christian Zuckschwerdt a freelance software designer from Germany. On this blog I'd like to share some free and open source software for GNU/Linux and Apple Mac OS X.
There are also some themes and tricks for the Drupal CMS. And then the occasional hardware or gadget hack. It's all free and mostly licensed under the GPL or CC.
Write a comment or send me a mail. I love to hear from you!

About FOSS

Do you know how much free and open source software is involved in creating and delivering some basic web pages?

This triq.net blog is rendered by hexo themed with nunjucks compiled by nodejs served by apache httpd secured with openssl stored on MariaDB running on gentoo linux, edited with vim deployed by openssh, graphics done with inkscape and gimp.

triq

zany@triq.net
triq.net blog
© 1999 – 2017 Christian Zuckschwerdt.

Links