Results tagged “x11”

For quote some time I have been using x2x to have single keyboard and mouse for multiple machines (EeePC or third monitor at work), but I had problem with selection buffers. x2x was written for scenario where all X servers are listening to network connections, so if you had two machines klin and t42 and you wanted to use keyboard and mouse on klin you would have to do something like this:

dpavlin@t42:~$ xhost klin

dpavlin@klin:~$ x2x -to klin:0 -west
However, recent Debian systems are not listening to TCP connections, so you will have to modify xserverrc for this to work:
dpavlin@t42:~$ cat /etc/X11/xinit/xserverrc 

exec /usr/bin/X11/X #-nolisten tcp
However, it's much nicer to depend on ssh X11 forwarding to provide encryption using:
dpavlin@klin:~$ ssh -X t42 x2x -to :0 -west
To finish this post, I have to include small patch which allows to switch copy/paste direction (which I don't need any more, but it proved useful in at least one case):
diff -r 2ce6789a43da x2x.c
--- a/x2x.c     Tue Mar 18 22:47:34 2008 +0600
+++ b/x2x.c     Tue Nov 24 14:08:16 2009 +0100
@@ -1125,7 +1125,7 @@
       if (doSel) {
         // pDpyInfo->initialClipboardSeen = False;
         pDpyInfo->winSelText = NULL;
-        pDpyInfo->hwndNextViewer = SetClipboardViewer(pDpyInfo->edgewindow);
+        pDpyInfo->hwndNextViewer = SetClipboardViewer(pDpyInfo->bigwindow);
       pDpyInfo->onedge = 0;

If you have any objection your X11 setup (especially if you are not running Gnome or KDE) it's probably: Firefox menu font size is too big! However, that's really not right complaint. If you create your own userChrome.css and install it in correct location, you will notice that rest of applications still won't look good. But, Firefox was biggest problem, so you move on...

But, solution is really simple:

dpavlin@t61p:~$ cat .gtkrc-2.0 
gtk-font-name = "Verdana 7"
This will change all GTK application's (including FIrefox, and others) to sane font size for huge monitors with high DPI settings. It's a single line fix to all your problems!, take a look: gtk-font-change.png

One of first differences when you start using X11 is that you can just select any text on screen and press middle mouse button to paste it back. But, after a while you end up in situation where you did ctrl+c in application, and somehow you expect that middle mouse button will paste it back.

X11 implementation of copy/paste is much more complicated, as you might read from excellent X Selections, Cut Buffers, and Kill Rings.

Most of the time, having two different clipboards is very useful. Think about copy/pasting url and title at the same time from one web page to another (like I do often when writing blog posts like this one).

So, how to we manage buffers more efficiently? First, install xclip and try it out:

dpavlin@t61p:~$ xclip -h
Usage: xclip [OPTION] [FILE]...
Access an X server selection for reading or writing.

  -i, -in          read text into X selection from standard input or files
  -o, -out         prints the selection to standard out (generally for
                   piping to a file or program)
  -l, -loops       number of selection requests to wait for before exiting
  -d, -display     X display to connect to (eg localhost:0")
  -h, -help        usage information
      -selection   selection to access ("primary", "secondary", "clipboard" or "buffer-cut")
      -noutf8      don't treat text as utf-8, use old unicode
      -version     version information
      -silent      errors only, run in background (default)
      -quiet       run in foreground, show what's happening
      -verbose     running commentary
Help output is probably a little verbose, but just remember following things:
  • -in is default
  • -out displays content
  • default selection is primary (which is content you marked on screen)
  • -selection clipboard is only other thing you need to rember
So, armed with that knowledge, here are couple of examples:
# display selected text
xclip -out

# display clipboard (copy/paste in applications)
xclip -out -selection clipbaord

# transfer selection into copy/paste buffer
xclip -out | xclip -selection clipboard

# transfer selection into copy/paste buffer
xclip -out -selection clipboard | xclip
Last example is useful if you want to paste something back in terminal and it somehow ended up in copy/paste buffer, following is Zotero example: zotero-copy-to-clipboard.png

Just let your imagination go wild: what if you have only textarea and you want to do some massive editing for which vi whould be better? You can install excellent It's All Text! Firefox extension but, you could also write something like this:

xclip -out > /tmp/$$.txt && vi /tmp/$$.txt && xclip -in -selection clipboard < /tmp/$$.txt
You could bind that to a key in your window manager or start different editor if you wanted to... or I guess live can be simple again if you just install autocutsel

Few days after I wrote this blog post, I had interesting problem. I was trying to decrease font size in firefox and I found instructions which included filename and content itself. I copied content with Ctrl+C and selected filename and used this little gem:

xclip -sel clipboard -out > `xclip -out`

Generally we just like to bitch about state of X. However, I would like to point you towards two presentations from 2009:

Introducing the Re-Built Linux Desktop by Keith Packard

You will find out what is GEM and why do we have it and now it influenced Linux kernel development. Also explained are DRI2 and KMS. So now you can run non-root X servers, multiple X servers with acceleration and other fun stuff. Look, glxgears on compiz sphere!

From click to pixel: A tour of the Linux graphics pipeline by Carl Worth

Video file contains only first half hour of presentation, but here are interesting highlights from slides:

  • Visually inspecting GTK+ updates
    ./configure --enable-debug=yes # for GTK+
    GTK_DEBUG=updates ./my-program
  • Tracing cairo calls

    Install cairo 1.9 or later

    cairo-trace ./my-program
    See results in my-program.$PID.trace

  • Inspecting Render protocol
    xtrace -D :5 > my-program.xtrace
    DISPLAY=:5 my-program
  • Finding software fallbacks in EXA

    Edit xserver/exa/exa_priv.h:

    #define DEBUG_TRACE_FALL 1
    Recompile xserver and examine Xorg.0.log file

  • Finding software fallbacks in xf86-video-intel

    In "device" section of xorg.conf:

       Option   "FallbackDebug"     "true"
    Examine Xorg.0.log file

  • Inspecting 3D state (for Intel)

    fall: Show software fallbacks
    batch: Show decoded batchbuffers
    sync: Wait for idle after each batchbuffer
    (see intel_context.c debug_control[] for more)

  • Inspecting GEM state
    cat /proc/dri/0/gem_objects
    cat /proc/dri/0/i915_gem_interrupt

Good stuff, well worth two hours of your time to get to know your X, stop bitching and start reporting bugs...

I rarely use X11 for system administration. There is one tool, however, which was always invaluable to me: xlax. Sure, there are other solutions but somehow, I got addicted to xlax ever since I was introduced to it by fellow sysadmin.

Until today, that is. I always have source on the disk since it was such a hard thing to find. I run quick xmkmf on it, and... it didn't work! However, since xlax now has a home page which explains everything about XTerm*allowSendEvents I was on right track.

But, now so fast, grasshopper!
dpavlin@llin:/rest/unix/x11/xlax2.4$ make
gcc -m32 -o xlax -g -O2 -fno-strict-aliasing       xlax.o -lXaw -lXmu -lXt -lSM -lICE -lXpm  -lXext -lX11      
xlax.o: In function `SetupInterface':
/rest/unix/x11/xlax2.4/xlax.c:173: undefined reference to `strlcpy'
collect2: ld returned 1 exit status
make: *** [xlax] Error 1
Argh. I started with Digital UNIX (called OSF/1 back then) and part of my brain which deals with minor adjustments hasn't died yet, so I decided to do quick google search for strlcpy which which has handy link to strlcpy implementation in OpenBSD. Licensing terms aside, I decided to give it a try.

After applying following patch:

diff -urw xlax2.4/Imakefile xlax2.4.strlcpy/Imakefile
--- xlax2.4/Imakefile   2008-07-31 22:18:25.000000000 +0200
+++ xlax2.4.strlcpy/Imakefile   2009-04-30 21:32:15.000000000 +0200
@@ -5,8 +5,8 @@
 #            DEFINES = -DDEBUG
             DEPLIBS = XawClientDepLibs
     LOCAL_LIBRARIES = XawClientLibs
-               SRCS = xlax.c
-               OBJS = xlax.o
+               SRCS = xlax.c strlcpy.c
+               OBJS = xlax.o strlcpy.c

and quick xmkmf && make and I got it compiled.

Another trivial change was to implement automatic ssh to each host in mkxlax by adding -e 'ssh $ARGV[$i]' to system xterm line so I will have remote reminals opened by default.

And now, back to real work :-)

I wanted to automatically configure second monitor plugged into my laptop as above internal LCD, and I was prepared to allocate few days for this task. But, in recent servers this has gotten much better, so it's enough just to add following to .xinitrc:

xrandr --output DVI-0 --auto --above LVDS
xrandr --output VGA-0 --above LVDS

There is also grandr (with package in Debian) if you want point-and-click functionality.

Don't work on single monitor, having dual monitor again is such productivity boost :-)

Update: this works only on cards which report more than one output connected with xrandr -q:

Screen 0: minimum 320 x 200, current 1920 x 2250, maximum 1920 x 2250
VGA-0 disconnected (normal left inverted right x axis y axis)
LVDS connected 1400x1050+0+1200 (normal left inverted right x axis y axis) 305mm x 228mm
DVI-0 connected 1920x1200+0+0 (normal left inverted right x axis y axis) 474mm x 296mm
Im my case, it's ATI Technologies Inc M52 [Mobility Radeon X1300] with radeon driver. To make this work, I also needed to create virtual desktop which is large enough to accomodate both screens by adding Virtual to /etc/X11/xorg.conf:
Section "Screen"
        Identifier "MyScreen"
        Device     "MyCard"
        DefaultDepth     24
        SubSection "Display"
                Virtual 1920 2250

Video editing under Linux

I wanted to edit some video for my local LUG. However, this doesn't seem to be simple task under Linux.

I have some background since I worked on local TV station from 1991-1995 among other things in video editing. So I do know semi-professional and professional video equipment from those days (hack, I was earning good buck with it!) and my judgment is somewhat biased towards ease of use and practical problems which I encountered during editing of professionally shot video material (I don't nearly have so steady hand, it seems).

I have video materials recorded with JVC Everio GZ-MG575E (There doesn't seem to be any good official JVC page about it. Go figure that!) Reposted by lsusb as:

Bus 005 Device 004: ID 04f1:0008 Victor Company of Japan, Ltd GZ-MG30AA/MC500E Digital Video Camera

Files from internal read-only vfat 40Gb disk are available when camera is mounted as USB device on Linux as sd_video/prg001/mov*.mod. File on one of files report MPEG sequence, v2, program multiplex.

Let's look at available options:

  1. Kino - Safe choice, right? Debian package, version 1.1.1.
    It can't import avi in original format. When I tried to convert it some other .avi format using ffmpeg it segfaulted on loading of that avi.
    It has somewhat home video look which I don't like.
  2. cinelera - GUI hurtes my eyes and distracts too much from video footage. I tried. I really tried. It didn't work for me.
  3. The Open Movie Editor can't be compiled from upstream repository. Looked somewhat promising up to that point...
  4. Avidemux - to be honest, I found this one while Googling for video editing on FreeBSD software section video. Good catch, I had Debian package version 2.3.0 available from
    Very nice tool, it fits my brain rather well. Well, I would have to remap keys because it's just half-usable on notebook keyboard (no numeric keymap, allthough I might buy USB one just for this application :-)
  5. pitivi able to import avi, but blocked after a few clicks and stopped refreshing screen. It's interesting to note that clips which where loaded into avidemux had little picture from movie, while the ones which weren't loaded didn't.
  6. LiVES - last time I tried to find video editing software, LiVES turned out as only software which worked at all. Still, strange intraface, in part Gtk based, and in part just ugly doesn't sit well with me.
  7. Kdenlive is another project which is well worth a look. Clean QT interface, all the options I would like, want or need.
    Just two problems: I don't hear any audio. I do get blink sound from KDE, but not from video sound. Another problem is related to by attempts to solve previous one: upstream Subversion repository source code doesn't pass configure on my machine. Yikes.
    Update: My problems with audio are solved after I insalled sdl-alsa variant (instead of old alsa-oss, my fault). It's quite capable software, my only remaining gripe is that every action has a click or two indirection until you can have it done. Other than that I have problems with audio-video sync when producing any format other than mpeg (which is same as my source format), but I don't care much about that, because I intend to do recoding as final step into multiple formats anyway...

As I have complained several times before, I have problems with my ATI Technologies Inc M52 [ATI Mobility Radeon X1300] card on IBM/Lenovo T60 (don't you just love those company name changes?!)

I have been tracking two git repositories for drivers:

  • git://
    Older reverse engineering effort to which I contributed PCI ID of my card
  • git://
    Newer effort based on AMD specification which developers from Novell received ahead of rest of Open Source community

Last time I reviewed the problem, both of those drivers where broken for my box.

This time, I must report that avivo driver is now finding my card, and in fact, I'm typing this blog post using it :-)

Even xrandr is reporting something which seems sane:

Screen 0: minimum 320 x 200, current 1400 x 1050, maximum 1400 x 1400
VGA unknown connection 1280x800+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1280x800       60.0* 
   1280x768       60.0  
   1024x768       60.0  
   800x600        60.3  
   640x480        59.9  
LFP connected 1400x1050+0+0 (normal left inverted right x axis y axis) 305mm x 228mm
   1400x1050      60.0*+   50.0  
   1280x1024      59.9  
   1280x800       60.0  
   1280x768       60.0  
   1024x768       60.0  
   800x600        60.3  
   640x480        60.0     59.9  

I will have to plug in external monitor to test this out! /me happy

OOH, radeon-hd is showing just blank screen. So, don't give up upon avido driver yet!

The most useful hint for testing drivers from git is to simply do:

ln -sf /usr/lib/xorg/ /usr/local/lib/xorg

because both of those drivers have tendency to install into /usr/local by default (which is good), but then Debian installed Xorg won't find it. I could have done ./configure --prefix=/usr, but in git repository doesn't have that, and who wants to thing about small things all the time?!

X11 anti-aliasing slow?

My quest in finding faster X11 environment lead from WindowMaker to ion3, dwm and finally awesome. I would be very pleased with speed improvement if latest version of awesome didn't have xft support. Now I have to find and disable something I never needed in the first place, ehhh...

Have in mind that I do have laptops with more and more CPU power, so it's not that I use newer versions of software on some old crufty hardware (which I actually do from time to time, but that's not the point). Also, have in mind that I actually do like anti-aliased fonts but not in terminals and window managers.

What's wrong with anti-aliases fonts in terminals?

Glad you asked. Instead of trying to explain that (and failing), do a little test:

  • Pick any anti-aliased font in your terminal of choice
  • Execute find . in some directory with reasonable amount of files (home dir comes to mind)
  • Notice flickering on scroll? After a while it gets better (I guess that xfs cache some anti-alias information)
  • Now pick some fixed bitmap font and re-run find .
  • If you didn't notice difference in speed and flicker of scrolling you might be using terminal without xft support or bitmap font already.

But, anti-alias can't be that slow!

Nice try... Let's try another experiment. Open your ~/.fonts.conf and add something like:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
 <!-- bitmap fonts -->
 <match target="font" >
  <edit mode="assign" name="hinting" >
 <match target="font" >
  <edit mode="assign" name="hintstyle" >
 <!-- antialias tweaks -->
 <match target="font">
  <test compare="more" name="pixelsize" qual="any">
  <test compare="less" name="pixelsize" qual="any">
  <edit mode="assign" name="antialias">
 <match target="font">
  <test name="weight">
  <edit name="antialias" mode="assign">
 <match target="font">
   <edit name="rgba" mode="assign"><const>rgb</const></edit>

This is my current configuration, you might want to skip rgba part if your LCD or CRT is different than mine...

Now re-try browsing in firefox (iceweasel, whatever). Do you notice something? Yes, it's faster. Even on dual core T2500. Isn't that somewhat strange?

To be quite honest, I'm running vesa graphic drivers. But, that's because my T60 has ATI Technologies Inc M52 [ATI Mobility Radeon X1300] card which isn't supported under current unstable Debian with any other driver (fglrx from Debian and xf86-video-avivo and/or xf86-video-radeonhd from upstream git). So, I have something to say about drivers also...

Is there any way to make anti-alias faster? Does compiling my own fontconfig might make a difference? I'll have to find out one day if there isn't any response to this post...