Hotsolder

Electronics and other geeky pursuits!


  • Pithos (Pandora) Quicklist for Unity or Icon-Only Task Manager

    I use KDE but recently installed the excellent Icon-Only Task Manager (http://kde-look.org/content/show.php?content=144808) that lets you set up a Unity-like desktop. One cool thing is that some programs have QuickLists. So if you right click on a Chrome icon, for example, it gives you options to open a new window or tab, etc.

    Making a new Quicklist is pretty easy and I use Pithos (http://kevinmehall.net/p/pithos/) quite a bit to listen to Pandora. So here’s my Quicklist for Pithos. Save it as pithos.desktop and put it in /usr/share/applications/pithos.desktop.

    [Desktop Entry]
    Name=Pithos
    Comment=Play music from Pandora Radio
    Categories=GNOME;AudioVideo;Player;
    Exec=pithos
    Icon=pithos
    Terminal=false
    Type=Application
    Actions=Like;Ban;Skip;Pause-Play;

    [Desktop Action Like]
    Name=Like Song
    Exec=qdbus org.mpris.MediaPlayer2.pithos /net/kevinmehall/Pithos net.kevinmehall.Pithos.LoveCurrentSong

    [Desktop Action Ban]
    Name=Ban Song
    Exec=qdbus org.mpris.MediaPlayer2.pithos /net/kevinmehall/Pithos net.kevinmehall.Pithos.BanCurrentSong

    [Desktop Action Skip]
    Name=Skip Song
    Exec=qdbus org.mpris.MediaPlayer2.pithos /net/kevinmehall/Pithos net.kevinmehall.Pithos.SkipSong

    [Desktop Action Pause-Play]
    Name=Play/Pause
    Exec=qdbus org.mpris.MediaPlayer2.pithos /net/kevinmehall/Pithos net.kevinmehall.Pithos.PlayPause


  • $20 SDR Dongle Works as SDR

    Details on the set up here: http://sdr.osmocom.org/trac/wiki/rtl-sdr


  • Calibre Leaving Old News on My Sony Reader — Delete It!

    I haven’t had much use for book readers, but I saw a Sony PRS-300 in the Sony Outlet Store for only $40 so I bought it. No Linux software, but it does work well with Calibre, so I’ve been very happy with it. It is tiny and has amazing battery life and it is a great alternative to lugging my tablet around all the time.

    Calibre has a great feature where it can grab things off the Web, make them into eBooks and put them on your device. They have lots of precreated feeds like the BBC, CNN, etc. There is an option to tell Calibre to remove the news after it is a certain number of days old.

    I thought this wasn’t working because stuff was accumulating on my device. However, a little research showed that it is a quirk of Calibre. It removes the news from your library but not the Reader! Oops.

    I decided I can run a little script to trim old news from the reader. I may change the Calibre shortcut to do this automatically before it runs Calibre in the future. Here’s the script in case you find it useful:

    NOTE: DO NOT USE THIS CODE, use the code below!

    #!/bin/bash
    # Detele old news files from Sony Reader
    # Usage: trimsony [days]
    # Default is 5 days (delete things older than 5 days)
    echo NO DON'T USE THIS!!!
    exit 0

    # Check this file to see that reader is connected
    READERPRESENTFILE=/media/READER/metadata.calibre
    # Directory that holds news
    MEDIADIR=/media/READER/database/media/books/News

    if [ ! -f $READERPRESENTFILE ]
    then
    echo Error: Reader not connected! 2>&1
    exit 1
    fi
    DAYS=5
    if [ "$1" != "" ]
    then
    DAYS=$1
    fi
    # All subscriptions are in /media/READER/database/media/books/News
    find $MEDIADIR -type f -mtime +$DAYS -exec rm {} \;
    exit 0

    You can change the directories and the number of days used by default pretty easily if you like.

    Enjoy!

    UPDATE: I’m not so sure this is a good idea anymore. I have to run more tests. It does work, but I think deleting files off the Sony makes its media.xml database get out of sync and I can’t figure out what syncs it. Sometimes Calibre gets the dreaded media.xml is corrupt message and then getting it to stop doing that is a massive inconvenience. I’m still looking into it, but be warned!

    Update 2: Ok I’m back to try again. I found Calibre has a poorly-documented ebook-device command that lets you do command line operations. I also used kdialog to give a progress bar because it is slow. That means you need kdialog, qdbus, and other stuff that you already have if you are running KDE. However, you could remove that or replace it with other things if you aren’t.


    #!/bin/bash
    # Detele old news files from Sony Reader
    # Usage: trimsony [days]
    # Default is 5 days (delete things older than 5 days)

    # Mount directory (no trailing slash please)
    MOUNT=/media/READER
    # Check this file to see that reader is connected
    READERPRESENTFILE=$MOUNT/metadata.calibre
    # Directory that holds news
    MEDIADIR=$MOUNT/database/media/books/News

    if [ "$1" == '-' ]
    then
    dbusRef=$2
    CT=`qdbus $dbusRef Get "" value`
    CT=`expr $CT + 1`
    qdbus $dbusRef Set "" value $CT
    BASE=`basename "$3"`
    qdbus $dbusRef setLabelText "Removing $BASE"
    FILE="${3##$MOUNT}"
    echo -n $FILE
    ebook-device rm "$FILE"
    exit 0
    fi

    if [ ! -f $READERPRESENTFILE ]
    then
    echo Error: Reader not connected! 2>&1
    exit 1
    fi
    DAYS=5
    if [ "$1" != "" ]
    then
    DAYS=$1
    fi
    # All subscriptions are in /media/READER/database/media/books/News
    COUNT=`find $MEDIADIR -type f -mtime +$DAYS | wc -l`
    if [ "$COUNT" != 0 ]
    then
    # this desyncs the database!
    #find $MEDIADIR -type f -mtime +$DAYS -exec rm {} \;
    dbusRef=`kdialog --progressbar "Deleting old news" $COUNT`
    qdbus $dbusRef Set "" value 0
    find $MEDIADIR -type f -mtime +$DAYS -exec $0 - "$dbusRef" "{}" \;
    qdbus $dbusRef close
    fi
    exit 0


  • Byobu (Advanced GNU Screen) under Centos 5/Python 2.4

    I recently discovered Byobu, which is a set of scripts that lets you use GNU Screen more easily. If you spend a lot of time ssh’d into a server, you should definitely check it out. It worked fine on my desktop machine, but on my Centos 5 server, not so much. I did a little research and I found there were two problems.

    The easy problem was keeping F2-F4 from working. The trick is that /etc/screenrc has the following line in it:

    termcapinfo xterm 'k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~'

    Commenting out the line make the function keys work! That was easy.

    The 2nd problem was that F9 was not bringing up the menu. Well, most of the time. Sometimes you could get a peek of a Python traceback and sometimes — not often — it would work. The real puzzle was that if you started byobu-config from the command line it worked fine.

    It turns out Centos has Python 2.4 which is pretty old. I intercepted stderr from the script and found out that a command that was reading from a pipe was returning “System Call Interrupted.” This isn’t really an error, but this version of Python apparently thinks it is. So sometimes, that signal wouldn’t interrupt the pipe and it would work.

    I tried installing Python 2.6 but there are a lot of dependencies in Centos on Python and although I found someone with a “parallel” RPM it didn’t have the necessary libraries and I finally gave up. But then it hit me. If I could just pause a bit before the offending pipe, the signal would come in — not interrupt the pipe — and then all would be well. It seems to work!

    Here’s the fix:

    if os.path.exists("%s/.%s/disable-autolaunch" % (HOME, PKG)):
    return 0
    time.sleep(3)

    The script already imports time, so that wasn’t a problem. Problem solved. I like Byobu!


  • Speeding up Ubuntu Linux with SSDD

    A lot of people are switching their Windows machines to boot of solid state disk drives (SSDD) to get faster boot times. The price of these drives has been dropping, but since I use Linux (Kuuntu, actually, which is Ubuntu with KDE) it didn’t make much sense to me. I maybe reboot my machine once a month. What do I care if my reboot time is 30 seconds faster?

    Fry’s had a 64GB SSDD on sale this week. After rebate it was around $85 after rebate (you can get roughly the same deal at Newegg). They had a 32GB drive (which had slower specs, too) for even less. So I couldn’t resist. The drive was for a laptop, but the SATA connectors fit. I bought a $4 pair of brackets to make it fit, but in the end since the thing doesn’t spin, I just let it sit on top of a drive tray — I’ll probably secure it later, but for now it is just sitting on the inside. I formatted the whole device with btrfs (no partitions at all) and sure enough I had about 59GB of useful space in a new volume.

    I edited fstab to have the line:

    UUID=f9f6588e-dc7f-4675-b132-8b008486d243      /ssdd1    btrfs  defaults,ssd,noatime,discard

    Of course, your UUID will vary. I had to create /ssdd1 as root and then I did a mount -a to put the drive in place. Now… how to make things go faster?

    My basic idea was to copy stuff that KDE, X Windows, etc. uses a lot to the SSDD. I didn’t care so much about user files and I didn’t want the constant writing of /tmp or things from /var (in general) since SSDDs have some limit on write endurance (although modern drives do pretty well if you look into that). And I didn’t want to get messed up with things in /boot or things that I would need if the drive ever failed to mount (/bin, /sbin, and /lib, for example).

    What I did was make exact copies of /usr/share, /usr/lib, /usr/bin and put them on /ssdd1/usr/share, and so forth. You have to make exact copies since some things in /usr/bin are suid — that is, they run as their owner and a normal cp won’t do the job (not without a lot of options; look at -p, for example). I used cpio:

    find . -print | cpio -admp /ssdd1/usr/bin

    Obviously, you need to be root to do that and you need to be in the /usr/bin directory. Once I had the directories in place, I had to move the old directories (I was too chicken to delete them) and link to the new one. Before you do that, though, I’d check that /usr/bin/sudo was in place on the SSDD and that its sticky bit was set. If you lose that and you have no root account set…. well… let’s not do that, ok?

    Moving /usr/bin is a little tricky because you need to be root, but sudo is in /usr/bin! The easiest thing to do is just become root even though that angers the Ubuntu faithful:

    sudo -i

    Then you can do commands like the following:

    mv /usr/bin /usr/bin-old ; ln -s /ssdd1/usr/bin /usr/bin

    If things go wrong you can still get to things via /usr/bin-old.  So if you do mess up you could do something like:

    /usr/bin-old/sudo mv /usr/bin-old /usr/bin

    That actually sped things up quite a bit. Booting is notably faster and the response time of X in general is greatly improved.

    I then repeated the steps but this time I made shadow directories for ~/.config and ~/.kde. I redirected these to /ssdd1/home/alw/.config and /ssdd1/home/alw/.kde, respectively. This also made the system much snappier.

    There are other ways you could have done this. I considered loop mounting over the existing directories, for example. This would be very safe since if the drive didn’t mount you’d just lose performance. The issue is you’d need to occasionally sync the real directory and the shadow directory to be sure any updates were applied. I had bad luck with a scheme like that for putting Firefox’s files into a ram drive — if it does get out of sync, look out. Of course, my scheme has a similar issue — if you lose the SSDD your old files are out of date. But with my setup there is no way for updates to occur to the old files (for example, if the SSDD fails to mount and you don’t notice) making them  mismatched in both directions. You can rsync them from time to time, either way, but with my method if the SSDD fails to mount you will know it immediately. Also, the old files stay visible making syncing them easier if you care to do that.

    Meanwhile, I’m happy with how fast this has made my system. Granted, it was fast to start with (8G of RAM, 3.6GHz, and 4 cores), but the system does boot much faster, Gimp loads almost immediately, and switching between tabs in Chrome is notably faster. Since the system files are just moved and not removed, this “update” is fairly safe — you can still get to the original files if you have to. Just remember that updates will not change the old copies.

    UPDATE: Turns out Apparmor realizes that things aren’t in /usr/bin anymore and starts blocking things. The only thing I noticed was my printers (the CUPS daemon won’t start). You need to go to /etc/apparmor.d/tunables and edit the alias file. Then reload apparmor and reload affected services (or reboot, which is easier). Here’s mine:

    alias /usr/bin/ -> /ssdd1/usr/bin/,
    alias /usr/lib/ -> /ssdd1/usr/lib/,
    alias /usr/share/ -> /ssdd1/usr/share/,

    UPDATE #2: VirtualBox does not like /usr/lib as a symbolic link, I’m not sure why but the code specifically checks for this case and throws an error. I had thought about using bind mounts instead of symlinks before and this pushed me over the edge. So I still use the symlinks for stuff in my home directory but for /usr instead of creating bin, share, and lib links I created empty directories to use as mount points. Then in /etc/fstab I put:

    /ssdd1/usr/bin   /usr/bin   bind   defaults,bind   0 0

    And similar lines for /usr/share and /usr/lib. Now Apparmor is happy and so is VirtualBox. I assume fstab mounts in order, so be sure those lines come AFTER the mount of /ssdd1, of course.

    And one more update: Nepomuk and Strigi — which always give me grief anyway — write huge files to ~/.kde/share/apps/nepomuk/blah blah blah. This will quickly fill up a small SSDD. So one more link. I made ~/.nepomuk and then linked it in the ~/.kde tree. UNFORTUNATELY, filling up a btrfs volume causes it (at least in my case) to become totally unusable and unrepairable. So I would up switching everything to ext4. No compression, but better than having a total crash of the drive when it gets full.

    After I had the crash I decided it would be nice if the regular hard drive had a pretty recent copy of what it was supposed to have. Since I had the space full crash about a week after I installed, it wasn’t so bad, but what if it had been a year or more later? Luckily, I had followed a simple pattern to replace the directories. Given some directory I wanted to replace called /x/y/z, I copy it to /ssdd1/x/y/z and then rename the original to /x/y/z-nossdd. Finally a bind mount or symlink points the original location at the SSDD.

    Given that pattern, it was easy to create a daily cron job (/etc/cron.daily) named ssdd-backup:

    #!/bin/bash
    for dir in /home/alw/.kde /opt/google /usr/bin /usr/share /usr/lib /usr/include /usr/lib32 /home/alw/.config /home/alw/.local
    do
    rsync --archive --update --quiet /ssdd1$dir/ $dir-nossdd
    done
    This runs every day early in the morning and ensure that the old directories get any updates. The update is NOT two way. If you change something in xxx-nossdd, that does not propagate to the SSDD (but why would you?). Of course, you’ll want to modify the first line to name the directories you actually shadowed.

  • Viewing EFX Fax Files (EFAX) with Linux (or anything else probably)

    I get about 2 faxes a year, so I hate to stand up a dedicated fax machine and phone line. There is, of course, a free fax service available. But the problem is the free version only delivers proprietary efx files. To open these you need to run the eFax software. Sure its free, but its Windows only! Might run under Wine with some coaxing and, of course, you can run Windows in VirtualBox, but what a pain just to open a fax or two a year.

    EFax will let you get the fax as PDF if you upgrade. I just don’t get enough faxes to justify that. But there is a way.

    If you log into your account online you will see several options including “View Faxes.” Click that. You get a web page that looks like an e-mail inbox. You’ll see the faxes you have received. Click the fax you want to view or print. This will load a preview pane at the bottom. But you can only look at the first page. Double clicking the fax brings up a  new tab that shows the same preview image. But there is a link in the header that says “View Fax: xxxxxxxx.efx” (where the x’s are the file name). You’d think that would just download the efx file, right? Nope.

    Click the link. Go on. Now you have a viewer that lets you pick a page of the FAX, zoom it, and rotate it. If you just need to look at the fax you are done. But I wanted to print mine. Am I out of luck? Here’s the trick: Right click on the displayed fax (it doesn’t matter if you can see it all or not). Depending on your browser you’ll get an option like “Copy Image URL” (I guess you could also “Save Image” and then go open the image in your favorite picture editor and go from there.  With the Image URL, go to a Web browser and paste it into the URL bar. Woo hoo! You now have a full page image that you can print from the browser. Different browsers handle images differently, so you are on your own at this point. On Chrome I’d zoom the image up to 100% and print and I got nice full page faxes. If you were not at 100% the print would be smaller than the page.

    Of course, if you have a 100 page fax its a pain to have to do this for every page. But seriously, if you are getting 100s of pages of fax, subscribe or install the free app under VirtualBox or Wine! But for those of us who left most of our faxes back in the 1990′s this is an easy way to get faxes printed without Windows.


  • How to Disassemble (Take Apart) a Rigol DS1052E, DS1102E, DS1052D, DS1102D

    I had a bad encoder on my Rigol scope. Taking it apart was an adventure.

    Have a look at this slide show to see how it comes apart. I replaced the encoder with a mostly compatible unit from Digikey..


  • PICP (Linux PICSTART Plus) for 16F883 and 16F886

    Just in case you want to use PICP with either the 16F883 or 16F886, add this to your picdevrc file:

    [16F883]
    0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0
    PICSTART

    [16F883:def]
    10 00 3f ff 3f ff 00 7f
    00 7f 3f ff 3f ff 00 ff
    00 ff 00 00 00 00 00 00
    0D 10 20 00 04 20 07 02
    00 00 01 00 00 00 00 00
    00 01 22 0f

    [16F883:defx]
    3f ff 07 00 00 00 00 00
    00 00 00 00 00 00 00 00
    3f ff 07 00 00 00 00 00
    00 00 00 00 00 00 00 00

    [16F886]
    0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0
    PICSTART

    [16F886:def]
    20 00 3f ff 3f ff 00 7f
    00 7f 3f ff 3f ff 00 ff
    00 ff 00 00 00 00 00 00
    0D 10 20 00 04 20 07 02
    00 00 01 00 00 00 00 00
    00 01 22 0f

    [16F886:defx]
    3f ff 07 00 00 00 00 00
    00 00 00 00 00 00 00 00
    3f ff 07 00 00 00 00 00
    00 00 00 00 00 00 00 00


  • Cost Effective Digital I/O for LabView

    Example GP3 VI

    LabView is great software, but it isn’t easy to find inexpensive hardware that works with it. Since the GP-3 is a serial device (RS232 or USB) LabView can use it, but it does take a bit of hoop jumping to match the GP-3′s efficient binary protocol with LabView’s string-oriented I/O.

    Because so many people have asked me about how to use LabView with the GP-3, I’ve started posting blocks that do the GP-3 functions. I don’t have them all yet, but I’m steadily adding to them, and the example they provide would make it pretty easy to do any of them you want (in fact, I just copy, paste, and modify to get most of them myself).

    Read the whole article at and look for the download files at the bottom.


  • New GP-3X Boards Available

    Here’s a chance to pick one up at a promotional auction price.

    The firmware on these boards is the normal GP-3. You can use it as a PC A/D interface for data acquisition or control You can also create a program with GP3EZ and then “download” it to the board so the board will function without a PC.

    The differences in this board from the regular board:

    1) All I/O is out to the edge and marked. Screw terminals are optional (included in the auction).

    2) Dedicated jumper for GP3EZ run/program mode

    3) USB daughterboard available

    4) Room for a “regular” LED or a 2nd 5V LED.

    5) Large ground lands for the analog converters to decrease noise pickup

    6) Spare area for op-amps or other devices (if not using USB daughterboard); flexible I/O lets you “interrupt” the analog and digital I/O to reroute.

    7) Slot for resonator OR crystal.

    8 ) Switchable DTE or DCE serial port (and connections for TTL serial)

    There is also a new manual for ALL GP-3s. Unlike the old “two part” manual, this is one manual for all GP-3 boards and should not require any other manual regardless of which kit you have. http://www.awce.com/gp3.pdf




©2014 Hotsolder Entries (RSS) and Comments (RSS)  Raindrops Theme