Archive for the ‘Software’ Category

OS X Launcher Applet For X11 Apps

Monday, September 12th, 2011

Trying to get my favorite text editor SciTE fully integrated into OS X required me to figure out some AppleScripting. I found a non-functioning SciTE launcher somewhere on the interwebs, but it only contained binaries, no script to tweak (how rude). Basically, I pulled apart the broken SciTE.app and found I could stick an AppleScript in there (called “main” in the directory structure below). This is what SciTE.app currently looks like when you “Show Package Contents”.

SciTE.app

Here’s the script I ended up with, it evolved as I overcame various hurdles. It writes to a file on the desktop to log errors, or if you set debugmode to true:

global debugmode

# Arguments passed on command line...
on run argv
 set debugmode to false
 runFilelist(argv)
end run

# Arguments passed with Finder...
on open filelist
 set debugmode to false
 if filelist is {} then runScite("")
 runFilelist(filelist)
end open

on quoted(f)
 return quoted form of POSIX path of f
end quoted

on runScite(argstring)
 try
 # All the guff at the end is required to prevent the script waiting for execution to terminate
 # otherwise this apple script will only work once
 do shell script "/opt/local/bin/scite " & argstring & " > /dev/null 2>&1 & "
 on error the error_message number the error_number
 set the error_text to "Fatal Error: " & the error_number & ". " & the error_message
 my write_error_log(the error_text)
 end try
end runScite

on runFilelist(filelist)
 set filename to missing value
 set filenames to ""
 try
 if (count of filelist) is greater than 0 then
 repeat with filename in filelist
 set filenames to filenames & " " & quoted(filename)
 end repeat
 end if
 if debugmode is true then
 set the error_text to "Debug: filenames = " & filenames
 my write_error_log(the error_text)
 end if
 runScite(filenames)
 on error the error_message number the error_number
 if debugmode is true then
 set the error_text to "Error: " & the error_number & ". " & the error_message
 my write_error_log(the error_text)
 else
 runScite("")
 end if
 end try
end runFilelist

on write_error_log(this_error)
 set the error_log to ((path to desktop) as text) & "SciTE.app_Error.txt"
 try
 open for access file the error_log with write permission
 write (this_error & return) to file the error_log starting at eof
 close access file the error_log
 on error
 try
 close access file the error_log
 end try
 end try
end write_error_log

You can drag this into your apps folder, stick it on your dock and just generally let the good times roll. Getting file associations working required some more awesome copy/paste action however. Basically I just found a text editor that supported lots of code languages and edited the Info.plist such that some of the labels and values looked more appropriate for my SciTE launcher and put it in the SciTE.app package. This allowed me to “Open With” files using SciTE, however I couldn’t set default file associations for file types until I added CFBundleIdentifier to Info.plist. Possibly something was corrupted because even after that it didn’t work, though maybe I just needed to reboot it or something. I tried installing RCDefaultApp, but that was fail, even after I got it working RCDefaultApp refused to set file associations to my launcher. The symptom I was experiencing was selecting Open With SciTE from both the “Get Info” and “Open With…” would work for a single file, but if I tried to make it default, it would flick straight back to xcode or whatever the default file handler was. Here’s what I tried before I noticed it finally working:

  1. Created a CFBundleIdentifier element in Info.plist
  2. Ran “/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -f /Applications/SciTE.app” both with and without sudo. This gave me some weird message about Throttline IO that I didn’t understand.
  3. Ran “/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user” both with and without sudo (I think).
  4. Rebooted

This is when I noticed RCDefaultApp wasn’t helping me at all, it still wouldn’t work, so I removed it. Using “Get Info” to set my launcher as the default did finally work by this stage.

Here’s the launcher, enjoy! SciTE.app

(I’m still on Snow Leopard by the way I have no idea if this works on Lion yet)

VirtualBox vs. “VMware Server”

Thursday, December 23rd, 2010

, or,

Starting VirtualBox On Boot

This post is applicable to Linux users with a VMware Server background considering moving to VirtualBox or VirtualBox users who want to start a VM on boot. If you skip my obligatory rantings and follow the steps below you can easily replace the functionality of VMware Server with VirtualBox in a way which is currently better supported on the Ubuntu platform (if not all Linux based platforms in general).

Normally I’m a VMware man, but after half a day wrestling with installation of VMware Server on Ubuntu then trying to load a VMware Fusion image and ultimately failing, I decided to try out VirtualBox. I used to use the free VMware Server on Ubuntu for months until I eventually had to move on to VMware Workstation to gain access to some of the more advanced VM building features. I never had any problem with Server, but one thing that bugged me about Workstation though was the need to login before the VMs would start running, and the fact that logging out would cause a hard shutdown of the VMs (and of course the inability to install Server alongside Workstation to get the best of both worlds). I was in a situation where I needed something on a machine that was not licensed for VMware Workstation, and VMware Server just wasn’t working for me.

  1. Visit VirtualBox website and get the repository added to your Linux distro for the latest and greatest version of VirtualBox and to ensure prompt updates.
  2. Create a VirtualBox specific user (i.e. vbox). This is a good idea for a number of reasons, but if your regular user account uses the encrypted file system then it’s critical. This user will own all the VMs you want to start on boot (make sure it doesn’t use an encrypted file system as root can’t access that and hence can’t start any VMs located there).
  3. Build, move, export/import, convert or what ever you need to do to get your VMs to run under VirtualBox as the vbox user.
  4. Install the VBoxTool script from Sourceforge. All the installation steps are in the packages readme file, so I wont repeat them here. Basically you set the scripts to run as a service and set up some configuration files. You could do all this yourself manually, but VBoxTool worked for me. Even if you don’t end up using it or it doesn’t work on your distro, the scripts are a good starting point to building your own init.d scripts to start the VMs on boot.
  5. VBoxTool will save the state of the VM if it’s running on system shutdown and resume (or start it) on boot. Test that it’s working by rebooting the host while doing something in the VM. You connect to the VM using an RDP client (or VNC if you insist on using OSE). The RDP client that comes preinstalled with Ubuntu is called “Terminal Server Client” and you connect to localhost.
  6. One last highly recommend point. If you don’t want anyone else on the network to connect to the VM directly then I suggest you firewall the port that RDP is using (3389 by default). You can do this easily from Ubuntu by installing the package “gufw” and enabling firewall with appropriate settings.

MPD on the Popcorn Hour A110

Wednesday, November 10th, 2010

So I got myself a Popcorn Hour 110. The PCH is a Network Media Player, and the name says it all it play all sort of digital media. It is equipped with a 500Gb HD and it can also stream content across the network, and it does a hell of a good job too.

The only if is the User Interface, it is shockingly unusable…If you just want the PCH to browse and watch your video collection is not so bad, but when you want to use it to listen to your music collection you enter a world of pain. So far I couldn’t see an easy way to use playlists or even simple features like shuffle, there are some Jukebox mods that you can install, but browsing through the solutions they are not that user friendly either.

Another feature that I need from my PCH is the ability to be remote controlled due to the setup of my house. No easy way to do this too…So I dropped the PCH for music altogether and even started preparing a box that I had lying around (matter for another post) with something called Music Player Deamon , MPD is a remote controlled media player, basically is a daemon service that accepts requests to control media files on the host computer. It is opensource and has a large community of developers that  have developed a number of clients for it for platforms including Windows, Linux, MacOsx, Android, Iphone, you name it. Perfect for my requirements.

So I had my box all setup and running with MPD when I came across this post about installing MPD on the PCH…I couldn’t believe it, yes the Popcorn hour runs Linux and these two guys managed a way to fit MPD into it…awesome.

Since the documentation on the mentioned post is a bit convoluted due to updates along the time I will document here step by step the process that I followed to install the MDP on my PCH:

You need to setup your PCH to talk with your network, easiest way is to allow automatic IP address and let your DHCP server do the rest. The PCH will automatically acquire an IP address that you will need later to connect to it.

On another PC in your network you need to install the NMT Community Installer, this utility is nothing less than a bundle of applications that you can install in your PCH provided by the community, it features Themes, mods to the original graphics, and also several tools and applications like bit torrent clients, a replacement for the default http server, etc. The one we are interested for the MPD install is telnet, this will provide a way to access a command line for our PCH. So go ahead and install it.

Once telnet is installed you can connect to it by using a telnet client. I used putty, any other telnet client will do.

After you connect to your PCH you will be sitting in the share folder, this is the root folder for all your content. In the command line issue the following commands:


cd /mnt/syb8634/etc
wget http://nmt.explore.nl/mpd-nmt-20090504.tar.gz -qO - | tar xvz
cd mpd
pwd
./installmpd.sh
./startmpd.sh

And that’s it, now every time the PCH reboots it will scan your music folder and rebuild its internal database. Pick an MPD client from the Client List and off you go.

My favourite client is Music Player Mininon which is a Firefox plugin.

NetworkManager Can Ignore VPN DHCP

Friday, August 6th, 2010

Connecting to a VPN that has DHCP settings configured can be rather frustrating if it breaks your regular network settings. The biggest problem I’ve had with this in Ubuntu is with resolv.conf losing my DNS settings in favour of the VPN DNS settings.

For a long time I’ve tolerated the workaround of setting the immutable attribute on resolv.conf (ie. chattr +i /etc/resolv.conf). This will prevent anything from updating the file and thus you will not lose your DNS settings when the VPN connection takes place. This is fine for a desktop machine on a local network where resolv.conf is likely to stay static, but no good for a laptop or other mobile device.

This week I searched around for a better solution. Something new I found was vpnc connect and post-connect scripts. This looked like a possible solution, something similar to what I did when using the vpnc client for KDE. The KDE client had a post-connect script option, and from that I would restore my old resolv.conf. I tried creating the vpnc scripts to back up resov.conf and restore it afterwards, but it seems that those scripts don’t even get run by NetworkManager because nothing happened for me.

Then by luck I noticed something in my search results about a setting called ignore-auto-dns. Seems that the interface doesn’t support the setting, but you can specify it for the connection using gconf-editor. The specs for the setting are here… http://projects.gnome.org/NetworkManager/developers/settings-spec-08.html

So to apply this setting, open gconf-editor and find your VPN connection under system/networking/connections (all connections are just numbered under there). There should be an ipv4 key in there. Now just create the boolean value ignore-auto-dns and set it to true. Shortly after discovering this solution, I found another technique which lists this same setting but in a network configuration file… https://help.ubuntu.com/community/NetworkManager0.7. I’ve not tried the method listed there because I’m not actually convinced that it’s a better option than modifying this gconf setting.

Eee PC Clicking Sound

Wednesday, June 16th, 2010

I’ve noticed that on battery power the hard disk makes a clicking sound every 20 seconds or so. This symptom has been reported particularly by laptop and netbook users, including those that use Windows (though I gather it’s much less of a problem with Windows users).

A quick summary of the situation. If your Eee PC has a SATA hard disk, chances are you’ve noticed this problem. The simple solution is just to disable Advanced Power Management on the hard disk all together and then get on with your life. There are plenty of other power saving features that work, but it seems that the APM is not well suited to Lucid Lynx (or vice versa).

Ubuntu is telling the hard disk to take it easy and not to chew too much power. But this is really just to lull it into a false sense of security as it doesn’t actually cut the drive any slack. In fact, Lucid has some services which appear to be very demanding on the hard disk. The hard disk keeps trying to take a break but Lucid keeps accessing it. The result is a drive that constantly sleeps and wakes up again (causing the click to be heard, as the disk heads park and then move back into working position again). Luckily this action was actually audible, otherwise I’d have been none the wiser, oblivious to the performance hits until my hard disk finally died from excess wear.

A quick search revealed the following command to instantly stop the clicking:

$ sudo hdparm -B 254 /dev/sda

Where “sda” is your SATA hard disk device of course. That command will buy you some time to figure out what’s really happening. Unless you are feeling adventurous, you’ll probably reach the same conclusion that I have. But lets work through this anyway for the sake of actually understanding a little more about what’s actually going on here.

The following command will tell you lots of stuff about your hard drive that you probably don’t want to have to care about:

$ sudo hdparm -I /dev/sda

You can find just the line we are interested in with this one:

$ sudo hdparm -I /dev/sda | grep "Advanced power management"

Which should yield this, since we ran hdparm with the -B 254 option…

Advanced power management level: 254

This is what we want. But if you reboot and run that command you will see it reverts back to level 128. In fact, if you plug the power back in and then remove it, theoretically it should revert to APM level 128.

To find out what the hard drive has been up to, install the smartmontools package using synaptic or sudo apt-get install smartmontools. Then you can run this command (make sure your terminal window is nice and wide or maximised):

$ sudo smartctl -a /dev/sda

Cool huh? More stuff you don’t want to have to care about. But just have a look at the section titled “Vendor Specific SMART Attributes with Thresholds”. On my Eee PC I had very high “RAW_VALUE” for “Load_Cycle_Count” row.

“Load_Cycle_Count” was 3150 and “Power_On_Hours” was only 56. So I’m assuming this means the drive has averaged one “load cycle” per minute of it’s life. Which is about right, since the clicking only happens on battery power and then it happens about every 20 seconds during this time. So if the clicks coincide with these “load cycle” thingamajigs, this would suggest it’s lived on batteries less than 1/3rd of it’s life, which is about right.

If you don’t like my science, or you have a different interpretation of your own threshold table then you might want to have a look at the SATA known issues wiki page. Meanwhile, on with the show…

With a default Lucid Lynx installation, the APM level 128 setting is triggered by a htparm power management script that lives here… /usr/lib/pm-utils/power.d/95hdparm-apm. If you have another power management package installed such as laptop-mode-tools then your on your own.

The configuration for this and possibly other power management tools lives in /etc/hdparm.conf. To basically disable APM when running on battery power, add the following to the end of the config file…

/dev/sda {
	apm = 254
	apm_battery = 254
}

This tells hdparm to keep the drive at APM level 254 even when it’s running on battery power. Unfortunately, this seems to be the simplest option when running Lucid Lynx on an Eee PC. Apparently Lucid Lynx just doesn’t want to stop molesting the hard disk. Just disable APM for now. Hopefully future UNE releases will address this rather major issue.

I’m planning to test the battery life of the OEM Windows 7 and then compare it with Lucid Lynx without APM. I expect it to be a bit of a hit, but I get the impression it’s not worth the effort to make Lucid Lynx APM friendly. If you are feeling masochistic though, perhaps you can pick up from where this guy left off.. http://forum.eeeuser.com/viewtopic.php?id=85230

I see this as an unfortunate trade off between power consumption and performance. The performance improvement of Ubuntu still far out weighs this issue. To be fair, I first found out how to fix this problem from Windows users. Someone has ported a lot of the functionality of hdparm to a tool called quietHDD to solve this for the Windows platform. At least our solution is supported and bundled with the operating system. I found it interesting anyway to know a bit more about how power management works in Ubuntu.

References:
man hdparm.conf

KDE or not KDE? That is the question…

Tuesday, September 1st, 2009

I’ve been gradually catching up with a lot of the rants on the net with respect to KDE3.5 vs. KDE4. Some less sane than others. I came to the debate quite late it seems, and it’s something I’m not pleased with even having to care about to tell the truth. Suddenly now I find my self having to understand the developers philosophies and getting to know some of the more vocal egos on both sides of the fence. After grasping a better idea of what’s happened, I don’t think I’ll ever be completely sold on KDE4. But after reading some more compassionate words on the topic today, I think I’ve finally come to terms with the situation.

In the KDE developers defence, I don’t think it’s possible for complete overhauls of software to ever be embraced whole heartedly by the userbase. Particularly not right away. I will continue to resent the fact that Kubuntu took up KDE4 so soon. I liked KDE3.5 because it was a work of art, but also because it was fully functional and intuitive for anyone who is used to MS Windows. At that time I couldn’t understand why Ubuntu picked Gnome for the flagship considering KDE3.5 was so much more suited winning over the users afflicted by Bug #1. My first impression when KDE4.1 was thrust upon me was of some retarded mutant desktop environment from a future that I don’t care to participate in. KDE4 turned my entire desktop experience inside out!

I’m not going to pretend that I’m not a stubborn person. I like to work in a particular way which I’ve refined over years, dating back to MS DOS and Windows 3.1. I switched to Linux because some of the more restrictive and intrusive features in Windows Vista had well and truly crossed the line as far as I was concerned. I wanted to get back to a basic desktop without all the useless eye-candy. KDE3.5 was the best fit for me at the time.

I’m quite busy as well. I soon learnt with Linux distro’s, every time there is a distribution upgrade to postpone it for at least a month and ensure I dedicate a couple days after it to get myself settled back in. With KDE4 it was more like a couple of weeks of pointless frustration. Wrestling with KDE4 just proved to be too much hassle for me at work and I’ve now fully switched over to Gnome. I found it easier to customise to my liking than KDE4. At home I’m still on KDE4.2 because it doesn’t matter so much if I’m spending 6 hours trying to figure out how to customise the desktop theme in vein, and I still hold out for a glimmer of hope that the developers may resolve some of my issues with it.

KDE4 is not easy or intuitive to use. I don’t like this widget based desktop paradigm and I don’t understand how it’s useful in anyway. Most of the time my desktop is hidden by windows anyway. I have to wonder if KDE4 was ever designed for using or if it’s just for looking at. KDE4 is a contradiction in my eyes. To be a desktop environment which gets in the way of letting users do what they want, yet to do so in the name of flexibility is bizarre. It makes me anxious and I don’t like it.

I still see KDE4 as the lavalamp of the desktop environment world. It chews a lot of power and looks pretty, but it’s not all that useful. You also have to be careful about touching it because you might get burnt. I have a feeling it’s the new development philosophy that’s flawed, but I can’t quite put my finger on what that flaw is as yet. I think I’ve reached a turning point in my thinking about KDE4 now though, and I find my self walking peacefully in the opposite direction.

VPNC Android GUI Package

Wednesday, July 22nd, 2009

Forget my post about running VPNC from the G1 terminal. Wmealing has just released the Android package that does it all in GUI form. Grab the get-a-robot-vpnc package now.

Not much to add, except “oh the awesome!”. Here’s a little screen shot of the add connection GUI…

If you have trouble figuring out what to enter into those fields, check out my old get-a-robot-vpnc post for some hints.

Cupcake update pushed to JFv1.51 US/UK

Wednesday, July 22nd, 2009

This morning I checked my phone only to find a message about updates downloaded and ready to install. That’s an odd thing, since I’ve got modded firmware that should have disabled such behaviour to prevent conflicts. I was a bit worried, but an ADP G1 wielding colleague pointed me to this notice… http://andblogs.net/2009/07/otas-in-jfv1-51/

I followed JF’s 2nd and 3rd suggestion and so far so good. Here’s the exact steps I took to disable the update.

  1. Download and extract JFv1.51 ADP firmware and copy build.prop to the sdcard. Or use this build.prop (freshly extracted for your convenience).
  2. Mount /system on the G1 as read/write. Two simplest ways to do this is either install “DroidSans Tweak Tools” or run “mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system” in a terminal.
  3. Replace build.prop and make the permissions the same as the old one with something like:
    $ su
    # mv /system/build.prop build.prop.bak
    # cp /sdcard/build.prop /system
    # chmod 644 /system/build.prop
  4. Find the update in the /cache directory and “chmod 000″ it…

    Disable Cupcake OTA update screenshot

  5. Now I actually clicked on the “restart and install” option on the update dialog. The phone rebooted, and the update failed. I rebooted with Home+Back and haven’t had the update prompt as yet.

So far so good. One odd thing I noticed is the update is gone from the /cache directory.

Browse for Android apps without the eye strain

Wednesday, July 1st, 2009

The Cyrket website is an “Android Application Browser” for the desktop. Makes it much easier to search for applications and works especially well in conjunction with “Barcode Scanner” app installed on the handset.

Now why didn’t Google just do that in the first place?

Android MarketEnabler

Wednesday, June 17th, 2009

Looks like some Italians figured out a way to access paid applications on the Android Market. Check out this English translation which contains a link to the MarketEnabler app they wrote. I’ve tested it out and it stills work quite well.