Thursday, January 2, 2014

Keybindings in Openbox

When I log into XFCE on my work desktop remotely using NoMachine's NX client, the "p" button stopped working.  Instead of messing with my XFCE settings, I tried logging into LXDE.  The "p" button worked.

Then I needed to remap the keyboard shortcuts for switching/cycling through windows.  I'm using a Mac Pro at home, and left Command-Tab alone.  Instead, I wanted my keyboard's control + tab keys to cycle through windows.  In XFCE, I would have gone to the window manager settings in the main settings dialog.  However, it looks like I had to manually edit Openbox's keyboard mappings in an XML file.

I ran xev in the X session to find out which key was being pressed.  It said Control_L and Tab were being pressed.  When I edited the /.config/openbox/lxde-rc.xml file from:

   1:  <!-- Keybindings for window switching -->
   2:  <keybind key="A-Tab">
   3:    <action name="NextWindow"/>
   4:  </keybind>
...to:
   1:  <!-- Keybindings for window switching -->
   2:  <keybind key="Control_L-Tab">
   3:    <action name="NextWindow"/>
   4:  </keybind>
...it didn't work.  I didn't care if it was the left or right Control key, so I just changed it to:
   1:  <!-- Keybindings for window switching -->
   2:  <keybind key="C-Tab">
   3:    <action name="NextWindow"/>
   4:  </keybind>
Then I typed openbox --reconfigure to reload the settings without restarting Openbox, and it worked as expected.

References:


http://openbox.org/wiki/Help:Bindings
http://superuser.com/questions/248517/show-keys-pressed-in-linux
http://linux.die.net/man/1/xev

Thursday, December 26, 2013

Android: Accessing shared preferences in Activity

I was getting this error when trying to access shared preferences in my main activity:

http://stackoverflow.com/questions/12201371/android-unable-to-start-activity-componentinfo

Moving getPreferences() to the onCreate() method solved the problem.  I'm guessing it's because I was trying to get the shared preferences before the activity was created.  (Hey, I'm new at this!)

Monday, October 28, 2013

Android ROMs

I'm flashing SuperJELLY on my HTC EVO 4G LTE right now.

I was running Paranoid Android for a few weeks, probably my fourth or fifth custom ROM on this device, and am switching back to a Sense-based ROM (or maybe stock-based ROM is more accurate) because there are some crucial features that just aren't supported at all or well on custom ROMs like Paranoid Android and Cyanogenmod.

GPS:
I've had significant GPS problems running anything other than a stock-based ROM.

4G/LTE and roaming:
I've never been able to get 4G data using a custom, non-stock ROM on this device using Sprint in Washington, DC.  Roaming seems to be much worse also.  Combine that with the fact that it doesn't automatically (as far as I can tell) update its preferred roaming list (PRL) makes it much worse than a Sense-based, stock-based ROM for data connectivity.

Camera:
The first couple non-stock ROMs I installed could barely use the camera at all.  The time between photos was seconds.

Contacts:
Two of the custom ROMs I installed could not load the contacts app without crashing.  The best explanation I found for this was that any significant number of contacts can be a problem for some ROMs.  Never had a problem with stock though.

These problems might entirely be HTC's fault for making it difficult for others to write code for their hardware.  However, that's just another reason to choose hardware whose philosophy fits yours.  Personally, I'd rather have a phone that is generic enough that it will run whatever I want to put on it, rather than having a camera chip that's so spiffy that anything but the stock ROM can barely use it effectively, much less take advantage of its spiffiness.

The take-away from this is that I'm going to hold my breath until my Sprint contract is up in February and then sign up for a no-contract plan with whomever is currently offering something like the MotoX or the next Nexus phone.

Anyone else have similarly frustrating experiences with custom ROMs on their new-ish HTC phone?

Friday, May 11, 2012

Proprietary NVIDIA drivers for Linux

One of my perennial occasions to POUND MY HEAD AGAINST A WALL is trying to wrestle with video issues on Linux.  This time around, I was trying to once and for all figure out why Kubuntu was doing such a poor job with giving me the available 3D & window compositing effects.  My mantra which was written on paper and hanging on my cube wall in front of my eyeballs for years at my old job was, "Never install proprietary video drivers!  Evar!!!1"  I wrote that after wasting probably a dozen hours trying to get my Ubuntu box to run as I thought it should.  This time, after trying XRender (which I don't understand), then switching back to OpenGL (which I don't understand), trying different NVIDIA drivers from the Ubuntu/Kubuntu repositories (I'm using 12.04), trying to tweak my xorg.conf, etc., I finally just went to NVIDIA's site and downloaded the latest driver, dated something like last week.  Of course, I installed it, rebooted it, now everything is great.


Sunday, April 8, 2012

Scripting Selenium / WebDriver with JavaScript

This is the example code I wanted to write using JavaScript:

http://code.google.com/p/selenium/wiki/GettingStarted

Here is where I looked for help when it wouldn't work[1]:

http://stackoverflow.com/questions/10057163/cant-run-java-example-for-selenium-webdriver

To save you the trouble: my Java is poor.  :-)  That's okay, because I'm not a Java programmer.  I do want to script Java[2], however, using JavaScript and Mozilla Rhino.  A prime candidate for learning how to do so (for me) is writing Selenium / WebDriver tests against their Java API.

I finally got the example code to work.  Here is the command line:

alis-mac-pro:selenium ali$ java -cp ".:/Users/ali/Downloads/selenium-2.20.0/*:/Users/ali/Downloads/selenium-2.20.0/libs/*:/Users/ali/Downloads/rhino1_7R3/*" org.mozilla.javascript.tools.shell.Main -f example.js 
Page title is: Cheese! - Google Search

That's my input, and the program's output.  And here is the example.js file that Rhino executed:


importClass(org.openqa.selenium.By);
importClass(org.openqa.selenium.WebDriver);
importClass(org.openqa.selenium.WebElement);
importClass(org.openqa.selenium.htmlunit.HtmlUnitDriver);

// Create a new instance of the html unit driver
// Notice that the remainder of the code relies on the interface, 
// not the implementation.
var driver = new HtmlUnitDriver();

// And now use this to visit Google
driver.get("http://www.google.com");

// Find the text input element by its name
var element = driver.findElement(By.name("q"));

// Enter something to search for
element.sendKeys("Cheese!");

// Now submit the form. WebDriver will find the form for us from the element
element.submit();

// Check the title of the page
print("Page title is: " + driver.getTitle());




[1] - (BTW, before this, I asked for help on irc.freenode.net on #selenium and on #java and got nearly zero response.  The response was useful, though, but without any follow-up, I was left high and dry.  Theoretically, IRC and other live communication channels are wonderful resources for support, but I find that the reality falls way short of that theory.  Maybe it's just my theory?)

[2] - http://www.mozilla.org/rhino/ScriptingJava.html

Thursday, March 22, 2012

Tweaking display set-up on Ubuntu

(Thank you very much, Shinobu!)

I was trying to switch to the Nvidia drivers for Ubuntu 10.04, but was running into the same problem that made me ditch the drivers in the first place: I couldn't get Nvidia's config tool to rotate one of my monitors and leave the other alone.

Thanks to http://zuttobenkyou.wordpress.com/2009/10/04/linux-nvidia-xinerama-guide-rotating-just-one-monitor-in-a-dual-head-setup/ , I was able to switch to Xinerama (an Xorg extension), and rotate one of my monitors.  It involved some manual editing of my /etc/X11/xorg.conf , but nothing too painful.

Here's my /etc/X11/xorg.conf :


# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings:  version 1.0  (buildd@yellow)  Fri Apr  9 11:51:21 UTC 2010

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 1024 100 
    Screen      1  "Screen1" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "1"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor1"
    VendorName     "Unknown"
    ModelName      "DELL ST2420L"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 76.0
    Option         "DPMS"
    Option         "Rotate" "Left" # for portrait mode
EndSection

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "DELL 1907FP"
    HorizSync       30.0 - 81.0
    VertRefresh     56.0 - 76.0
    Option         "DPMS"
    #Option         "Rotate" "Left" # for portrait mode
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro FX 4600"
    BusID          "PCI:8:0:0"
    Screen          1
    Option         "RandRRotation" "on"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro FX 4600"
    BusID          "PCI:8:0:0"
    Screen          0
    Option         "RandRRotation" "on"
EndSection

Section "Screen"
    Identifier     "Screen1"
    Device         "Device1"
    Monitor        "Monitor1"
    DefaultDepth    24
    Option         "TwinView" "0"
    Option         "TwinViewXineramaInfoOrder" "DFP-1"
    Option         "metamodes" "DFP-0: nvidia-auto-select +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "TwinView" "0"
    Option         "metamodes" "DFP-1: nvidia-auto-select +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Extensions"
    Option         "Composite" "Enable"
EndSection


I'm sure there's still some cruft in there, but oh well.

Thursday, March 1, 2012

Debugging Google Chrome / Chromium CPU Horror

I hated to admit that using Google Chrome was destroying my productivity on my Ubuntu workstation at work.  The CPU usage was absolutely horrible, and the average load on my machine was usually anywhere from 1.5 to 7.  I know!

My workstation was fairly beefy memory-wise and CPU-wise, and had plenty of disk space.  I disabled everything I could think of, enabled GPU rendering of things, disabled debugging, extensions, ETC. . . .

I exited Chrome and waited for the processes to die.  Usually, I just verify this happened by looking at top; since Chrome usually owns the top spots (no pun intended), I wait until top shows no chrome processes, then I restart it.  This time, I did ps for chrome and chromium processes.  TURNS OUT that after using the Profile Manager[1] extension, several chrome and chromium processes were starting up every time I logged in.  I verified this by looking at "~/.config/autostart", which showed several *.desktop files pointing to Google Chrome and Chromium profiles.

So far, the change is extremely significant.  I recorded no benchmarks along the way, so I am unsure of how much each of my changes improved performance.  However, it appears that all of the extra Chrome processes were what made the biggest difference.

Chalk up another win for blogging about anecdotal information that may or may not lead to misunderstandings about technology.  :-)  You're welcome!


-Ali


[1]  I started using Profile Manager because I wanted to run multiple Chrome sessions in isolation, depending on what I was working on.  For my day-to-day work, I use one profile.  For my volunteer work, which I associate with its own Google Apps account, I use another profile.  For my browser testing, I use another.  THE LIST GOES ON.