Wed, 12 Dec 2018

Running latest firefox on debian installed as user

Debian packages the firefox-esr release which works quite well most of the time, but I find often the newest browser is often required for some functionality. I've put together a little script that basically sets this up with a local firefox install in ~/.opt

You can copy/paste this into a terminal and it will download the latest firefox, extract it to ~/.opt/firefox and setup a desktop file so that it will appear in the desktop menu

mkdir -p ~/.opt
cd ~/.opt

VER=${VER:-$(wget --spider -S --max-redirect 0 "${FFCHANNEL}&os=linux${LIBDIRSUFFIX}&lang=${FFLANG}" 2>&1 | sed -n '/Location: /{s|.*/firefox-\(.*\)\.tar.*|\1|p;q;}')}
echo $VER

wget${VER}/linux-x86_64/en-US/firefox-${VER}.tar.bz2 -P /tmp
tar jxvf /tmp/firefox-${VER}.tar.bz2

mkdir -p ~/.local/share/applications
cat <<EOF >> ~/.local/share/applications/firefox-stable.desktop
[Desktop Entry]
Comment=Web Browser
Exec=${BASEDIR}/firefox/firefox %u

sudo ln -sf ${BASEDIR}/firefox/firefox /usr/local/bin/firefox

More information in the debian wiki:

posted at: 19:34 | path: /debian | permanent link to this entry

Tue, 11 Dec 2018

Adding a menu location for locally installed xdg .desktop application links

I ran into an issue recently trying to install a application menu link on a debian system (desktop was mate in this case, but I think it applies to any gnome based desktop). The issue was that I would install a new .directory file for a new menu entry along with the .desktop file, and when I did, the application would show up under "Other" and not under the menu category I was trying to add.

The processes being:

Running this as the local user, correctly installs the files in ~/.local/share/, but it does not write a menu file. And so the application will show up under Applications->Other

If you run the command as root, it will install system wide, and creates the menu for you under /etc/xdg/menus/applications-merged/

But if you don't want this installed system wide, it seems like the only way to fix this is to setup the .menu file manually? I feel like I'm doing this wrong, and there is a way to specify the menu in a user folder, but at the time I can't seem to figure this out.

To fix the issue I created the /etc/xdg/menus/applications-merged/ file manually like this:

<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"

This added the menu entry, and the locally installed applications now show up in the correct location.

posted at: 23:43 | path: /linux | permanent link to this entry

Wed, 17 Jan 2018

Setting ip address of squeezeboxserver

I couldn't seem to find this information anywhere, and I just spend longer than I'd like to admit sorting this issue out. I use the Logitech Media Server (v7.9.1 as of now) and I just reinstalled it on my server. After doing that the "Server IP Address" was getting picked up as my public ip address on my gateway server, and not the local network address of This was causing the settings interface to be inaccessible on the local network with an error in the server.log file of Access to settings pages is restricted to the local network or localhost.

Fixing this was as simple as editing the /etc/default/logitechmediaserver file and setting the following line:


Not the httpaddr or cliaddr options which is what I was setting, because I didn't read the help page closely enough.

posted at: 23:49 | path: /debian | permanent link to this entry

Tue, 22 Aug 2017

solar eclipse as experienced by solar panels


We had about 70% coverage of the sun where we were which actually seems to be about 70% less production on the graph (which is what you'd expect, but neat either way).

posted at: 10:25 | path: /energy | permanent link to this entry

Fri, 23 Jun 2017

getting canadian exchange rates in python

Simple script to get the current exchange rates from the bank of canada:

import requests

r = requests.get('')
rates = r.json()
date = rates['observations'][-1]['d']
rate = rates['observations'][-1]['FXUSDCAD']['v']

posted at: 12:23 | path: /python | permanent link to this entry

Thu, 18 May 2017

wordpress plugin update error: PCLZIP_ERR_BAD_FORMAT

I was having some issues on a server where a particular plugin (bb-plugin) wouldn't update, and I'd just get this error:

PCLZIP_ERR_BAD_FORMAT (-10) : Invalid archive structure

After much poking around, I ended up installing the php5-curl package (on debian), and this ended up solving the problem. I think php was downloading the archive from the update server, but for whatever reason it was getting corrupted or not saving correctly. With curl the download seems to have saved the zip file correctly, and thus the error went away. It seems to have only been effecting this one plugin, as other plugins and wordpress auto updates were working just fine.

Anways, I didn't have much luck in googling a solution to this problem, so I thought I'd publish what I found.

posted at: 17:04 | path: /linux | permanent link to this entry

Sun, 06 Nov 2016

magicjack go device troubleshooting

We've been using a magicjack go device for the past couple of years, and it's worked quite well. It's a small device that is powered via usb, plugs into your LAN, and then you plug your regular old landline phone into it and it provides your phone service. Recently the device seems to have stopped working, and after wasting a bunch of time with the online chat tech support to indeed confirm that the device is dead, I decided to tear it apart just to see. Getting the device open was not easy, it seems to be glued together (no screws), and I ended up just cutting along the blue line with an exacto knife until it broke open. After getting it open I noticed it has two pads for tx/rx on the PCB and hooking them up to an oscilloscope it looked like it was transmitting some data. So I hooked up my buspirate to it and was able to read the following data (at 38400 baud I think):

MZ decompression
                MZ decompression error trap
                                           spi[2]:000000EF ,00000016
err header: FFFFFFFF

I'm not entirely sure what that is telling me, but it looks like it's probably having some trouble loading the firmware on the microcontroller and that explains why the device is dead (the blue power light comes on, but it won't connect via the lan port, and plugged into a computer it doesn't show up as a usb device at all).

Anyways, the warranty only covers one year on these little devices, so I can either buy a new one ($30 USD), or for the time being I might just use the android app as that seems to work well enough.


posted at: 01:26 | path: /electronics | permanent link to this entry

Thu, 03 Nov 2016

mpd in debian jessie using pulse audio

I've used mpd on various desktops for a long time, and I've always just set the output directly in the mpd.conf file, but that leads to the sound device being tied up if you ever want to do anything else with it. I finally got around to setting this up properly with pulse audio. This setup uses mpd running as the mpd user, and sets up pulse audio (which is running as the desktop user) to allow network access on localhost. MPD then connects to pulse audio to send the audio stream.

# give mpd access to use pulse
sudo usermod -aG pulse,pulse-access mpd

# configure pulse to allow access from localhost
echo "load-module module-native-protocol-tcp auth-ip-acl=" >> /etc/pulse/

# restart pulse audio as the user
pulseaudio --kill
pulseaudio --start

Then configure /etc/mpd.conf with the following audio_output:

audio_output {
      type            "pulse"
      name            "MPD PulseAudio Output"
      server          ""
      # set sink to name from "pacmd list-sinks"
      sink            "alsa_output.usb-Burr-Brown_from_TI_USB_Audio_DAC-00-DAC.analog-stereo"

Restart mpd, and then it should start playing through pulse audio. (should be able to see it playing in pavucontrol). Lots more detailed information here for different configurations:

posted at: 22:55 | path: /debian | permanent link to this entry

Mon, 07 Dec 2015

Bios freeze up trying to boot from USB stick

I ran into this problem and problem recently where I was trying to install linux from a USB stick on an slightly older machine (Intel Core2Duo era), and I had created a bootable Debian Jessie install image by simplying copying the netinstall image to the USB stick using cp file.iso /dev/sdb . This usually works just fine, but every time I put that usb stick in the system to boot from, it would just freeze the bios. If I started the system with the stick in place it would just start up then basically freeze up detecting drives. As soon as I unpluged the stick it would continue to boot. If I was in the bios, and inserted the stick it would freeze up, remove the stick and it would become responsive again. After pulling out some hair, and changing all the bios settings I could find relating to usb, I realized the stick I had was new, and was usb 3 (denoted by the blue colour plug). So I found an old cheap usb stick and wrote the image to that and tried it, and sure enough it just booted up without any problem and I was able to select it as a boot device and install.

So if your on and older system and can't boot from your usb install medium, try using an older usb stick (pre usb3) and that might solve the problem.

posted at: 23:03 | path: /computers | permanent link to this entry

Sun, 15 Nov 2015

hacking a logic controls cr3003 usb cash drawer

I had this usb cash drawer for a point of sale system, and needed to trigger it to open. I assumed it would be a serial protocol as I saw the drivers mention something about COM port selection in windows, so I figured it would be easy enough to figure out and get working. Turns out that was not the case.

The device itself shows up in lsusb and gets detected with the following information:

$ lsusb
Bus 006 Device 013: ID 0fa8:b033 Logic Controls, Inc.

[299584.252035] usb 6-1: new low-speed USB device number 5 using uhci_hcd
[299584.427042] usb 6-1: New USB device found, idVendor=0fa8, idProduct=b033
[299584.427049] usb 6-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[299584.427053] usb 6-1: Product: LCI_CR
[299584.427056] usb 6-1: Manufacturer: Logic Controls Inc
[299584.449247] hid-generic 0003:0FA8:B033.000A: hiddev0,hidraw3: USB HID v1.00 Device [Logic Controls Inc LCI_CR] on usb-0000:00:1d.0-1/input0

I probed around the hidraw interface a bit but finally gave up after not being able to transmit anything to it via pyusb without getting usb.core.USBError: [Errno 16] Resource busy errors.

So I broke down and loaded up a windows VirtualBox instance and installed the driver. It seems to emulate a COM port in some fashion, and then there is a utility to set what codes you want to use to open the cash drawer. So I snooped the usb data and found the control code for opening the drawer. Disconnected the usb device from virtualbox, and sent the data with pyusb, and sure enough it was working! I was all happy for a moment then decided to unplug the drawer plug it back in and make sure it still worked, but of course, no. After plugging it back in I got Resource busy errors again, and could transmit the open code. So I enabled usb in virtualbox again, and disabled it a few seconds later, and then I could open it again with libusb. So the driver seems to initialize the device in some way when it first talks to it.

So I then found some info on the web about how to capture data with the usbmon kernel driver and ended up doing the following:

tcpdump -i usbmon6 -w - -U > dump.out

Then connected the device in virtualbox, let the driver do it's initialization and then disconnect from virtualbox.

With that I had the raw usb data the driver used to initalize the device in dump.out. With some google searching I found this USB Reverse Engineering toolset which had a script to replay data from a capture. So I downloaded that library and ran the following:

cat dump.out | python ./ --vid 0x0fa8 --pid 0xb033

This produced some errors, but ultimately turned out to work. After doing that I could open the cash drawer with the following python code:

import usb.core
import usb.util

dev = usb.core.find(idVendor=0x0fa8, idProduct=0xb033)
if dev.is_kernel_driver_active(0) is True:

cfg = dev.get_active_configuration()
intf = cfg[(0,0)]
epout = usb.util.find_descriptor(intf, custom_match=lambda e: usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.ENDPOINT_OUT)
assert epout is not None
epout.write([0x31, 0x07])

I ended up wrapping all that uglyness up into a hack that does the job, but ugh. In my google searching I did find a device called "USB Trigger For Cash Drawer (Model: DT-100U)", which would have been a better solution (along with any old cash drawer with receipt printer interface). This is just a serial usb device, and when you send it data, it triggers the cash drawer via the commonly used receipt printer interface (24V).

posted at: 04:08 | path: /linux | permanent link to this entry


Powered by PyBlosxom | RSS 2.0