Category Archives: technical

Fauxdacious Version 3.83-Final Released

Fauxdacious Version 3.83-final Released for Linux and Windows: 

* FIXED filewriter plugin to “fail over” to “unknown” for the filename if the playing filename is too long or invalid (needed for youtube streams, etc.).  Also fixed a potential null-pointer reference.

* FIXED (rebuilt) FauxdaciousURLHelper.exe (Windows version binary) to add missing utf8_heavy module needed to fetch some IHeartRadio streams (Linux version not effected, which uses the Perl script).

* Added “close after song change.” checkbox for STDOUT output to “close” STDOUT when either song stops playing or record is toggled off in order to avoid errors in the created output stream.  Otherwise, output to STDOUT accumulates as a single long stream until recording stops.  This allows for combining multiple songs into a single output file, but can produces (somewhat harmless) errors at end of playback in such files.  The default is TRUE (checked) (properly close and prevent errors and only record the last song (overwrite).

* Added fixups for ugly but common stream title formats.

* Mandate SDL2 in Fauxdacious main, remove choice to use SDL1 in plugins.

* Merged all Fauxdacious commits through ace32cd; and plugin commits through: a666f70.

* Merged Audacious commits: 7886b7b; and plugin commits:  #9816dc6, 4f327c6, 10abf7d, 94d95fc, b13a35d.

Advertisements

Fauxdacious Version 3.83-beta3 Released

Fauxdacious Version 3.83-beta3 Released for Linux and Windows: 

* ADDED DVD-player plugin now included in the Windows version!  NOTE: For some reason, the livdvdnav library does not return the DVD Title string on Windows, so DVD cover art won’t work and all DVD titles are shown as “Unknown Title”.  TODO:  Try to figure out why.

* Addressed “smudgy” menu issue on some menus (Still not perfect on all menus, but much better).

WARNING:  Playing DVDs that contain CSS encryption DRM requires a special decrypting software library that is ILLEGAL in many jurisdictions.  This plugin software does NOT contain such decrypting software, but can make use of it in jurisdictions where such use is not prohibited.  It is the sole responsibility and liability of the user to ensure that such decrypting software is legal to use in their jurisdiction before installing and using such software with this plugin or any other software and / or hardware capable of playing DVD discs.  NOTE:  To play (legally purchased) encrypted DVDs in you region, (if it is legal to use libdvdcss in your jurisdiction), you will need to obtain a copy of libdvdcss-2.dll and manually place it in the bin/ directory where you installed Fauxdacious (where fauxdacious.exe and libdvdread-4.dll exist).

To play any DVDs, you will also need to edit your audacious config file (usually C:\Users\<username>\AppData\Local\audacious\config and add the following lines (or adjust as you see fit):

[dvd]
device=D: #(Or the drive letter of your DVD drive) libdvdread quirk: Add "\" if NOT using libdvdcss!
highlightbuttons=TRUE
play_video=TRUE
title_track_only=TRUE
video_qsize=5
video_windowtitle=Fauxdacious DVD #(Or whatever you want displayed in the titlebar)
video_xmove=1
video_ysize=-1

* FIXED bug that occasionally hangs Fauxdacious on startup when loading up with a wild-card list of files (usually .wav files), ie:  fauxdacious ~/Music/*.wav (Fauxdacious commit #8e3ba79).  This was due to a mutex deadlock in our song-specific equalizer-preset feature code.

* I gave up and made SDL v2 a REQUIREMENT now for Fauxdacious itself (The new DVD plugin already requires SDL2).  This is due to the fact that the nasty old issue of gtk-window vs SDL segfault kerfuffle resurfaced again (see plugin commit #5c09006 for a brief history of this issue), so now we will properly initialize SDL in main() since SDL seems to want to pretend like it has the “main()” function and must be initialized very early (now in main()) in order to play nicely with gtk windows created later (Fauxdacious commit #cec5946).  TODO:  Add this to the configure script!

* ADDED cover-art via the user_tag_file option for both DVDs and Audio CDs.  User must manually obtain cover art images and store the image files, rename them to the same name matching the respective CD or DVD title (shown in the playlist) and place them either in the [dvd|CDDA].cover_art_path (config file option) or the default: ~/.config/audacious[_instancename]/ directory (if not specified) – (plugin commits #5b0f6d7 and #cce218a).  The manual requirement is currently due to my inability to find free urls for reliably locating cover art programatically by searching with the information at Fauxdacious’s disposal (the CD/DVD “Title” string and disk IDs).  If I or someone else can find and provide URLS for such libraries and scrape logic (ok if separate ones for Audio-CDs and/or DVDs), I’ll be happy to test and include in a future release!

* MERGED (mostly) our stdin streaming feature with that of Audacious.  Our implementation of this feature predates Audacious’s and required specifying the file extension (as “stdin://-.mp3” for mp3) but theirs does not (“-“).  Since they now support stdin piping, including seekability via buffering during probing, I’ve now REMOVED my (now ancient) “hacks” to the sndfile, vorbis, and gio plugins previously needed to support stdin streaming without seeking, and remerged their latest versions of these plugins (less maintenance for me – yay)!  I’m leaving it in ffaudio for now though as it handles so many different formats (commit #8524685, and plugin commits # 7b0be4f, 9d4cfa3, 240e090 and 2ba6b75).

With Fauxdacious, one can still include the extension (the old Fauxdacious way) and save the overhead of probing all the plugins, however, the extension is still REQUIRED for non-“Input” plugins such as cue-sheets (“-.cue”) and playlist files (“-.pls”, etc.), as these do not “probe” to determine what’s being piped in!  Believe me, I spent a day trying to get the Fauxdacious core to “probe” playlists and cue-sheets piped in via stdin, but the underlying Audacious architecture simply doesn’t permit it as written.

Also removed the added Fauxdacious requirement of specifying “stdin://-” (instead of just “-“), though the old way is still acceptable.  NOTE:  This did result in one minor regression:  when piping a simple line-separated list of items to play (ie. “ls *.mp3 | fauxdacious -“), one must now specify either “-.txt”, “-.ls” or “-.m3u” (doesn’t matter which) instead of just “-” as I’ve removed the old code in main() that specifically handled this and now use the standard m3u playlist plugin for this.

* Instance numbers (single digits) can now be combined with single-letter command-line options, ie. “fauxdacious -Dc2”, and instance# 0 is now a synanymn for the default instance (name: audacious) (commit #712b923).

* Merge in all Fauxdacious commits through 712b923 and plugin commits through b4882eb.

* Merge in Audacious commits:  20ecbff, 9303781, baabb80, 79dcc0f, e859ae3, 11b4856 (plugin commit a7ba191 has long been part of Fauxdacious).

TBT – My Favorite ’80s Software (WinDOS and PC-Write)


MS-DOS Executive Main Screen
MicroSoft Windows “MS-DOS Executive” main window (courtesy Wikipedia)
Today, I decided to take a walk down memory lane and dust off one of my oldest and favorite programs that I wrote back in the late ’80s:  “WinDOS(tm)”.  This was my first semi-graphical application and my first “file-manager”.  This was during the heady days of MS-DOS.  Children, if you don’t know what MS-DOS was, ask your folks!  At that time, Windows was new and at version 3.  There was no internet, very little graphical software for personal computers (Windows was coming onto the scene to change all of that forever though)!  My computers at the time (at home and at work) were still running “MS-DOS 5” and few had Windows, which (as Windows always does) required purchacing new, beefier (and pricier) hardware.  There were one or two computers at work that had Windows and so I got to play around a bit with it, but the interface was clunky and different and I was still USED to working in DOS which involved working a lot from the command line (what was known then as the “C> Prompt”)!  Meanwhile, Windows had this interesting little “app” called “MS-DOS Executive“, which was their early attempt at what we would now call a “file manager”.  I liked the new “mouse-based” interface that Windows offered.  In my daily workflow I found myself as a software developer often repeating a handful of commands with different files, ie. “Copy, Edit, Compile, Link, and Execute”, etc.  I looked at MS-DOS Executive to make this simpler, but alas, it didn’t really seem to work at all the way I was used to in DOS and besides, it was only for Windows, and I couldn’t afford Windows anyway, nor had it at work.
WinDOS Main Screen
WinDOS “WinDOS Executive” main screen
I wanted something similar for MS-DOS, something that would allow me to select a command (or “.BAT” script), select a file (or more than one file for commands like COPY) with a mouse, and click and run.  I also wanted to be able to do the same with the keyboard when my hand wasn’t on the mouse, and be able to click once on a list of the last dozen or so commands I had just executed to repeat them (or make a slight edit to one and run it again).  There was a cool program called “Norton Commander” (now the free “Midnight Commander” for Windows and Linux) which provided this capability, but it (like nearly all software applications and utilities at the time) cost money!  I was already writing some programs at home using the “Modula II” language and the $89 Logitech Modula II compiler (Yes, boys and girls, Logitech USED to make software back in the day, not just mice and keyboards!) for personal computers and MS-DOS!  So (being me) I decided to write my own program for MS-DOS and call it “WinDOS” (a combination of Windows and DOS, sort of a “poor man’s version of MS-Windows”).  I even patterned the main screen to look something like Windows’ “MS-DOS Executive” window but instead captioned “WinDOS Executive” and including the date and time and a “C> Prompt” for quick-typing and editing DOS commands (when my hand was on the keyboard).  WinDOS permitted me to greatly automate my workflow using a mouse to launch commands and programs while still providing enhanced keyboard-editing and entry of DOS commands!  MS-DOS Executive provided customized “.PIF” files as an early version of file/mime type associations and I quickly found myself needing something similar so I created text-based “.CIF” files (Command Information Files) to handle that in WinDOS, for example COPY.CIF configured WinDOS to prompt for TWO arguments for the COPY command.  I also created a “GUI” for creating and editing “CIF” files and an “installer” program and made it available as share-ware (open-source) and installable from a single floppy-drive!  One interesting programming feature was that I wrote WinDOS with an executable and a looping batch script to invoke it so that when the user executed a command, the WinDOS executable would exit freeing up nearly all of the 640K of system memory to run the program, then restart the WinDOS executable after the command finished.  This freed a lot of memory without noticably sacrificing speed.  My effort was not in vain as WinDOS quickly became one of my most-used programs for several years (along with the shareware / open-source editor “PC-Write(tm)”, which I also ended up purchasing the paid version because I loved and used it so much) until I finally moved my world to Linux in the mid ’90s (I pretty much skipped Windows all together)!  Heck, I even had several coworkers using WinDOS on their machines too!
Now that I’ve been on Linux for nearly twenty years now, I’ve long since developed my own file-manager (since I couldn’t find one that I liked) that incorporates the same basic principles as WinDOS, but also all the modern features one would want in a file-manager.  This is “JFM4“.  You can get it and see a screenshot on my download site.

Spiral-bound PC-Write(tm) Users’ Manual
PC-Write(tm)“, by Quicksoft (Bob Wallace and his wife Megan Dana) was my other fav. app. in my MS-DOS years as it provided a very nice and customizable full-screen (and full-color) text editor that was great for editing program source-files and writing letters, etc.  It was both a good code-editor and (for the time) a full-featured auto and manual-formatting word-processor, and it was free and shareware, and fit on a single floppy disk, so I could carry it anywhere with me!  I liked and used it so much, I ponied up the $69 (I believe) for the “fully-registered” (paid) version for which Quicksoft sent me a fully spiral-bound 426 page plus index manual (fully written and illustrated in PC-Write itself by Bob’s wife Megan Dana, seen on the cover), a free one-year subscription to their (paper) newsletter “Quicknotes”) and two free update coupons!

I got more than my money’s worth out of this program too using it for all my code development and word-processing needs for nearly ten years until I switched from DOS to Linux.  I wrote a full customization file (text file) with the colors and keyboard sequences all set the way I wanted to facilitate my work in the ways most natural to me.  After moving to Linux, I ended up writing my own full-color text editor named “E Editor” taking many ideas from this one and adding language-specific syntax-colorizaton, code-evaluation, and quick-compile that I still use today and you can get it (and JFM4) here from my download site for Windows and Linux.  “E” is not a full-blown word-processor though (I use LibreOffice for that).

PC-Write(tm) Intro screen
PC-Write(tm) Intro screen
PC-Write(tm) Editer screen
PC-Write(tm) Editer screen (editing an ancient FORTRAN program)

Fauxdacious For Windows (with executable installer) Released!

Introducing
I’m happy to announce my latest release of the Fauxdacious Media Player (version 3.83-final) with a full-functioning Windows version complete and bundled with a simple to use executable installer program created using the free and open Inno Setup Wizard!    (Get it Here:  http://phoenixcomm.net/~jturner/Fauxdacious_install.zip)  If you’re not familar with Audacious / Fauxdacious, it’s an audio and (with Fauxdacious) video player for both Linux/Unix and Windows.  Why use Fauxdacious instead of another video player?  With Fauxdacious, you also get one of the best audio player engines with many audiophile-ish sound-enhancing plug-ins!  Another reason is that unlike most Windows-based media players, Fauxdacious and Audacious are fully free and open-source programs with no binary blobs for malware to hide in!  One feature of interest to many Windows users is the option to use the classic “WinAmp Skins” interface, which uses the same “skins” as the old Windows “WinAmp” media player (see the bottom screenshot).  The default interface is the more modern-looking “GTK” interface, but it’s easily switchable to the WinAmp interface in [File].[Settings].(Appearance): Interface plug-in: and change the dropdown menu, then select your “skin”.  To turn on the video-playing option, simply select [Settings].[Plugins].[Input tab].[x] FFmpeg Plugin, then [Settings button] and check the box: “[x] Play video streams in popup window…”.
I understand the Audacious Team has now also created an installable version of their Windows version for v3.8.  This closes Audacious-rejected feature request #613.  This culminates nearly three weeks of hard work to build this thing for Windows.  I had held off doing this until I had a new machine with a huge hard disk that I could dedicate plenty of space for the Windows 7 partition in order to accomodate downloading the MingGW C++ compiler and compiling and installing all the three dozen or so libraries needed to compile this thing from scratch on Windows.  Thanks to the Audacious Team’s detailed and concise instructions for building on Windows, I was able to do this with only a few minor glitches (all now resolved).  For the brave techies, the gory build instruction details (including the issues I encountered and corrected) are included in the “Fauxdacious/share/” directory (fauxdacious_buildnotes.htm) created by the installer when you install (or the audacious/contrib/win32/notes.html file in the source tarballs, downloadable separately from the same site).
UPDATE (7/1/17):  Version 3.83-beta3 Released (Final 3.83 version – minor bugfixes)
UPDATE (6/5/17):  Version 3.83-beta3 Released (Adds DVD-Player Plugin!)
UPDATE (3/18/17):  Version 3.83-beta1 Released
UPDATE (3/8/17):  Version 3.82-final Released
UPDATE (2/16/17):  Version 3.82-beta2 Released
UPDATE (1/31/17):  Version 3.81-final Released!
Fauxdacious Installer
Fauxdacious Initial Setup Screen – Inno Setup Wizard
Fauxdacious Screenshot
Screenshot of Faudacious playing a video and using the default WinAmp skin with the main, playlist, and equalizer windows all displayed.
UPDATE (11/16):  Version 3.8-final Released.
UPDATE (10/25):  Version 3.8-beta1 Released.
UPDATE (5/31):  Version 3.74-beta2 Released.  Added the Inno Setup build file (Fauxdacious.iss) to the share directory.  If you don’t trust me fearing that I might’ve put any malware (I didn’t!) in Faudacious, you can download the full source and build instructions to examine and or re-build it yourself!

Make Special HP Laptop Touchpad Toggle Key Work In Linux

I recently purchased a new (refurbished) HP “Elitebook” 8440p laptop (see previous blog post) and docking station, and installed my custom “remastered” copy of Antix Linux!  Before buying, I had tried out my remastered Antix live-DVD on my wife’s laptop (same model with lower resolution screen) and everything basic seemed to check out.  As I expected, this laptop has proved to be a great laptop for Linux but I’ve been somewhat surprised at the number of additional (and difficult) issues/hacks I’ve had to resolve/make to my (already very customized) remastered linux installation.  In my previous post I described the nightmare I went through getting Linux to boot with Windows 7, though this is not at all a fault of the computer or it’s hardware, but rather owing to the way Windows 7 was partitioned and installed.  Another hack / workaround I ended up having to make (after another extended, but fruitless search) was downgrading my “AccelMethod” from “SNA” back to “UXA” in my /etc/11/xorg.conf file to stop screen corruption and lockup when exiting X without having to add a “chvt 1; sleep 2” sequence to each logout/exit/reboot command script in the window-manager, and disabling the “Ctrl-Alt-Backspace” command.  Switching to “UXA” eliminated the need for these workarounds (after I tried everything else I could come up with).  This machine has a LATER version of Intel graphics (Mesa DRI Intel Ironlake Mobile x86/MMX/SSE2).  The tradeoff is a slight reduction in video performance from up to 2000 fps to around 1700 or so, only really noticeable by running glxgears (My Dell never broke above 900 fps, but WORKED flawlessly with SNA!).
The hardware was very similar (driver-wise) to that of my old Dell D620, but more modern (Intel CPU, Intel integrated graphics, sound, and network interfaces).  The first issue that needed tweaking was to activate all the custom special-function keys.  Nearly all laptops have them and they all seem to be different not only between brands, but also between models.  I had long ago gotten the Dell’s all working using a now rather old program called “hotkeys”, however, I had not used them in ages since my Dell has not had a working battery since forever, and I’ve been using it almost exclusively docked (and the lid closed).  I’ve found that hotkeys seems to not work well anymore due to trouble staying up between suspends, etc.  I began looking for a better solution and found “xbindkeys”. This program also includes a GUI which permits you to actually press each key and then add your desired action command and builds the config. file for you!  This strategy proved successful for all the special keys, including the little “led” light-up ones above the keyboard that look more like status indicators than press-able keys.  The only ones not configurable via xbindkeys were the “wifi switch” led/key and the “touchpad toggle” led/key.

~/.xbindkeysrc:

     #Quieter
     "/usr/bin/amixer -q set Master 4- unmute"
         m:0x0 + c:122
         XF86AudioLowerVolume

     #Louder
     "/usr/bin/amixer -q set Master 4+ unmute"
         m:0x0 + c:123
         XF86AudioRaiseVolume

     #MuteToggle
     "/usr/bin/amixer -q set Master toggle"
         m:0x0 + c:121
         XF86AudioMute

     #Display
     "sudo /usr/local/bin/switchdisplay.sh"
         m:0x0 + c:235
         XF86Display

     #Internet
     "/usr/local/bin/browse.pl"
         m:0x0 + c:180
         XF86HomePage

     #LockScreen
     "/usr/local/bin/screenoff"
         m:0x0 + c:160
         XF86ScreenSaver

     #Dimmer
     "/usr/local/bin/setbacklight.sh -60"
         m:0x0 + c:232
         XF86MonBrightnessDown

     #Brighter
     "/usr/local/bin/setbacklight.sh 60"
         m:0x0 + c:233
         XF86MonBrightnessUp

     #ScreenToggle
     "/usr/local/bin/togglebacklight.sh"
         m:0x0 + c:248
         NoSymbol

     #Suspend
     "sudo /usr/local/bin/s2ram"
         m:0x0 + c:150
         XF86Sleep

The wifi key “works” in that it uses rfkill to toggle the wifi.  For most people, this will probably work fine out of the box, but I configure my networks manually, and need for the wifi to go off (and ethernet to come on) when docking so that my home network comes up on the ethernet connection (I needed to be able to execute a custom script whenever this key was pressed).  I ended up getting this key working by adding an ACPI event and script (see below).
/etc/acpi/events/hp8440p-wireless:

     event=PNP0C14:01 00000080 00000000
     action=/etc/acpi/hp-wifi-jwt.sh

In Linux Live-CD:

/etc/acpi/hp-wifi-jwt.sh

     event=PNP0C14:01 00000080 00000000
     #!/bin/sh

     test -f /usr/share/acpi-support/key-constants || exit 0

     . /usr/share/acpi-support/key-constants

     wifiblocked=`rfkill list wifi|grep "yes"`
     if [ "X$wifiblocked" = "X" ]; then
         echo "..WIFI BUTTON PRESSED: wifi not blocked!" >>/tmp/acpi.dbg
         #DO WHATEVER TO RESTORE PREV. CONNECTION:
     else
         echo "..WIFI BUTTON PRESSED: wifi BLOCKED!" >>/tmp/acpi.dbg
         #DO WHATEVER WE WANT WHEN WIFI TURNED OFF:
     fi

HP Touchpad Toggle Led/KeyI got all the special HP light-up buttons above the keyboard working with xbindkeys EXCEPT the one that looks like a tiny touchpad, that’s supposed to toggle the touchpad.  That little bugger just did not want to work, not even in Windows-7?!  The “touchpad toggle” led/key lights up cyan on startup and the touchpad is enabled.  Pressing it turns it orange and (should) disable the touchpad. Touching again turns it back to cyan (should re-enable touchpad).  In reality, it does nothing but change color when pressed.  X does not see it except the very first time it’s pressed, in which case xev sees a continuous spewing of keypresses and releases of keycode 138 killable by pressing Ctrl-C.  dmesg reveals that the kernel sees the alternate press as unassigned scancode “e058”.  Subsequent presses produce nothing visible to X until you reboot.  I tried adding the setkeycodes command the kernel suggested, googled and googled and could not find anything that would make this key visible to X. The console program showkey would show it alternately returning keycode 138 and keycode 140 (the one I assigned with setkeycodes) as I wanted, but for some reason nothing in X could see anything when the key was pressed.  Obviously, the key was seen by the kernel.  Several google pages described how to “translate” these kernel keycodes to X, including xmodmap, but nothing worked.
It was not like this particular key was very important to me, but at this point it had just become a determined challenge to force it to work!  I finally stumbled upon a tiny C program that could monitor the keyboard input device and report each key pressed.  I ended up modifying this program to look for these two keycodes and calling a command whenever one was seen.  I then set this program up as a tiny daemon so that I can now press the key and toggle the state of the touchpad!  Why?  Because I could and because I had already wasted too much time trying to figure this out!  😀
I finally found, stole and hacked up a tiny daemon C program that DOES make it work!  You need to do the following:
1)  in rc.local or somewhere in startup scripts add: /usr/bin/setkeycodes e058 140
2)  compile this little C program “keycheckd” (gcc -o keycheckd keycheckd.c) and place the compiled binary in /usr/local/bin/, and chown 4755 keycheckd
3)  In your X desktop session’s startup script do (must be started from w/n X desktop, NOT startup or console!):

     xset -r 138 -r 140 -r 146 -r 148
     keycheckPid=`pidof keycheckd`
     [[ "X$keycheckPid" == "X" ]] && /usr/bin/nice -n 10 /usr/local/bin/keycheckd &

The source (keycheckd.c) (note: you could add other keysyms / actions, if needed):

#include <stdlib.h>>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/input.h>
#include <string.h>
#include <stdio.h>

/*
JWT:THIS DAEMON PGM WATCHES THE KEYBOARD FOR PRESSES OF THE SPECIAL HP ELITEBOOK 8440P "TOGGLE-KEYPAD" KEY WHICH X (xev, xbindkey & FRIENDS REFUSE TO SEE AFTER THE 1ST PRESS PER REBOOT) AND INVOKES THE COMMAND TO TOGGLE THE TOUCHPAD (AS IT WAS DESIGNED TO DO). X DOESNPT LIKE THIS SPECIAL KEY B/C IT ONLY SENDS A "KeyPressed" EVENT W/NO CORRESPONDING "KeyReleased" EVENT. IT WORKS LIKE OTHER "LED"DED KEYS SUCH AS CAPSLOCK AND NUMLOCK! THE INITIAL STATE IS "BLUE" (TOUCHPAD ON), FIRST PRESS SENDS KEYCODE 140 (148 TO xbindkeys) AND SWITCHES THE LED TO "ORANGE". NEXT PRESS SENDS KEYCODE 138 (146) AND SWITCHES THE LED BACK TO "BLUE". SUBSEQUENT KEYPRESSES ALTERNATE BETWEEN THESE TWO STATES. I STOLE THIS PGM. FROM HERE: http://stackoverflow.com/questions/20943322/accessing-keys-from-linux-input-device.  I MODIFIED IT TO ONLY CARE A/B THESE TWO KEYCODES. NOTE: I HAD TO ADD "setkeycodes e058 140" TO rc_local.pl WHEREAS THE OTHER ONE (138) WAS ALREADY RECOGNIZED BY THE KERNEL. THIS PROGRAM SHOULD BE STARTED THE FIRST TIME YOUR WINDOWMANAGER STARTS UP (.afterstep/autoexec in my case)
*/

int main(void) {
    const char *dev = "/dev/input/event0"; /* or whatever your keyboard input is */
    struct input_event ev;
    ssize_t n;
    int fd;

    fd = open(dev, O_RDONLY);
    if (fd == -1) {
        fprintf(stderr, "Cannot open %s: %s.\n", dev, strerror(errno));
        return EXIT_FAILURE;
    }
    while (1) {
        n = read(fd, &ev, sizeof ev);
        if (n == (ssize_t)-1) {
            if (errno == EINTR)
             continue;
            else
             break;
        } else
        if (n != sizeof ev) {
            errno = EIO;
            break;
        }
        if (ev.type == EV_KEY && ev.value >= 0 && ev.value <= 2) {
            /* printf("0x%04x (%d)\n", (int)ev.code, (int)ev.code); */
            if ((int)ev.code == 138) {
                /* TURN ON TOUCHPAD: */
                /* printf("--138: turn touchpad ON!\n"); */
                system ("/usr/bin/synclient TouchpadOff=0");
            } else if ((int)ev.code == 140) {
                /* TURN OFF TOUCHPAD: */
                /* printf("--140: turn touchpad off!\n"); */
                system ("/usr/bin/synclient TouchpadOff=1");
            }
        }
    }
    fflush(stdout);
    fprintf(stderr, "%s.\n", strerror(errno));
    return 0;
}

Now, when you press this “key”, it should turn orange and actually disable your touchpad, a second press should turn it back blue and re-enable your touchpad.  I believe you could add the “/usr/bin/synclient TouchpadOff=1” in your X session startup script above where you start this daemon, and reverse the two “TouchpadOff=#” commands in it to have it start out disabled, then toggle to enabled, then disabled, etc.
%d bloggers like this: