Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Monday, April 8, 2013

Emacs keyboard delay when switching frame focus

I recently ran into an annoying issue with Emacs; I'm not sure what initiated this problem, but it might be that the default value of focus-follows-mouse changed. Or Ubuntu changed.

Here's the issue that I was seeing:

  • I have multiple Emacs frames, and I like to switch between them often.
  • Switching between them by using Alt-Tab, or clicking, would result in no problems.
  • However, using the interactive function other-frame (via a keybinding) results in a problem that there's an approximately 2 second delay from switching focus to when the keyboard would accept input again. Even worse, Emacs seems to have forgotten what modifier keys I had down, so when it did accept keyboard input, it wouldn't know that I still had the control key held down.
I tried various ways of debugging this to see if anything was going on (xev, strace) but ultimately I figured it out by reading M-x describe-function other-frame. That reveals the following text:


To make this command work properly, you must tell Emacs
how the system (or the window manager) generally handles
focus-switching between windows.  If moving the mouse onto a window
selects it (gives it focus), set `focus-follows-mouse' to t.
Otherwise, that variable should be nil.

When I M-x describe focus-follows-mouse, it shows t, which is wrong. So I instead added the following to my .emacs:

(setq focus-follows-mouse nil)

and now everything is back to normal. Why did that setting break things? Not sure. Maybe Emacs didn't call something it should have called assuming X would take care of it. Or the other way around. Anyhow, it's much better now.

Some details on my setup:
  • Ubuntu 12.04 Precise Pangolin
  • Emacs 23.3.

Wednesday, November 9, 2011

EasyCap DC60 and Ubuntu 11.10

I got an EasyCap DC60 from Amazon to see if it would work with my Ubuntu box to capture video. It looked promising at first... The output from dmesg looks like this:

[ 3391.497363] easycap::0adjust_standard: selected standard: PAL_BGHIN
[ 3391.808248] easycap::0adjust_format: sought:    640x480,UYVY(0x59565955),1=field,0x00=std mask
[ 3391.808256] easycap::0adjust_format: sought:    V4L2_FIELD_NONE
[ 3391.808264] easycap::0adjust_format: actioning: 640x480 PAL_BGHIN_AT_640x480_FMT_UYVY-n
[ 3391.832121] easycap::0adjust_brightness: adjusting brightness to  0x7F
[ 3391.856121] easycap::0adjust_contrast: adjusting contrast to  0x3F
[ 3391.880121] easycap::0adjust_saturation: adjusting saturation to  0x2F
[ 3391.904122] easycap::0adjust_hue: adjusting hue to  0x00

and it shows up as a video device just fine:

$ ls -altr /dev/video0 
crw-rw----+ 1 root video 81, 0 2011-11-05 22:58 /dev/video0

But when actually using it, it shows an image at first, and then shows grey bars. Note that the above message shows PAL, but I've tried NTSC, and other encodings with the same result. I found a thread about this on SourceForge.net, but the SourceForge project appears to be empty now. Google Cache currently contains the thread. The interesting pieces of text are:


The vertical grey bars usually mean that the front-end video chip cannot lock onto the analogue input signal.  This can happen if, for example, the video signal is really NTSC while the mplayer command line specifies PAL.  But in these circumstances, I would not expect to see any video output at all (apart from the grey bars).  The puzzling thing is that you do get some valid video, which then disappears.

One possibility is that the SAA7113H chip is raising a hardware "lost signal" flag when in reality the signal remains entirely viable (some aspects of this chip are known to be flaky).  To investigate this, it would be useful if you could reinstall the driver after changing line 31 of the script ./install.sh to
BARS=0
and run ./test4PAL.sh again.  This is a straight go/no-go test:  either it solves the problem or it is doesn't.  We don't need a verbose kern.log this time, so you can set DEBUG=0 in the installation script.
Since the SourceForge project seems to have disappeared, I'm not sure where install.sh is, or how to find it. Maybe the whole thing's moved to kernel.org. I suppose I could start digging around in the kernel source and see if I can figure out what that does...

Update: OK, this was a lot easier than I thought:

  • Google for "easycap site:kernel.org"
  • Find the README.
  • Remove all users of easycap kernel mod (shut down apps/services)
  • sudo rmmod easycap
  • sudo modprobe easycap 'bars=0'
  • Restart and try again...
Update 2: The next thing you should probably do is:
  • sudo vi /etc/modprobe.d/easycap.conf
  • options easycap bars=0
  • :wq
  • sudo reboot

Sunday, November 6, 2011

Zoneminder Memory.pm bug in 1.24.4


If you have Zoneminder installed and you're seeing this in /var/log/syslog:
Nov  6 14:36:11 machine zmwatch[2741]: ERR [Shared data size conflict in shared_data for monitor monitor, expected 328, got 316]
It's probably because of a bug that's been patched. On my distribution (Ubuntu 11.10) the file Memory.pm is at
/usr/share/perl5/ZoneMinder/Memory.pm
and the patch in question was applied at line 130.

Wednesday, March 25, 2009

Ubuntu 8.10 and Static IP


I just installed Ubuntu 8.10 Desktop and had a very interesting time trying to configure a static IP address. There are plenty of discussions on the forums about how this doesn't just work with the standard Network Manager. And you can't just edit/etc/network/interfaces because that is ignored when you have Network Manager installed.
To make it work, I followed this procedure:
First, remove the Network Manager packages:
sudo apt-get remove network-manager
sudo apt-get remove gnome-netstatus-applet
Now you'll have to manually set an IP so that you can connect to the Internet (modify this to be appropriate to your setup):
sudo ifconfig eth0 10.x.x.y netmask 255.255.255.0
sudo ip route add default via 10.x.x.1
sudo vi /etc/resolv.conf
Set nameserver 10.x.x.z appropriately. Next install the old gnome network admin tool:
sudo apt-get install gnome-network-admin
Finally use the old GUI to set networking configuration:
network-admin
This will store the network configuration in /etc/network/interfaces where it belongs. And it seems to work when you reboot. I'll keep it this way until Network Manager is fixed.

Friday, February 8, 2008

Compiling xemacs 21.5.28 on Ubuntu 7.10

I'm actually now a GNU Emacs user, not an XEmacs user, but in case this is helpful to anyone I've recorded how I figured out how to the get the XEmacs source to compile on Ubuntu 7.10.

The reason I'm no longer an XEmacs user is because it's just not keeping up with GNU Emacs, but more importantly, there is an extremely annoying bug...

Update: It appears that the "Xlib: unexpected async reply" that I refer to above is fixed in Ubuntu 8.04. Too bad I'm now using GNU Emacs...