20100212

My XFCE Setup

I use XFCE for my desktop environment in Linux, and I think it strikes a nice balance between minimalism and functionality.  You can add lots of crazy panels and menus if you want, but you don't have to.  Personally, I find that the crazier, more "user friendly" setups of KDE or Gnome provide way more interface than I need, and are just annoying.  I can launch anything I want by typing it into the terminal, so I don't need to navigate pages and pages of GUI to find something when I already know what it's called.

My setup has a floating taskbar which gives me quick access to the stuff I want to use quickly (like Firefox, Thunderbird, gedit...), but I can still pull up a menu to dig around if I need to find a particularly weird program (which is rare, I pretty much do everything in a terminal).

The coolest thing about my setup (at least I think), is that I've got a huge list of wallpapers loaded up, that change on a cron job every half hour. Here's the relevant shell code:

Dump the current wallpaper image:
xprop -root | grep 'XFDESKTOP_IMAGE_FILE_0(STRING)' | cut -f 2 -d\"

Reload a new image off the list:
xfdesktop -reload
(Note that to do this in a cron job, you may need to set the DISPLAY and XAUTHORITY right.)

I've got another set of scripts that removes the current wallpaper from the list (just using text manipulations on the file), so I can remove the one's I don't like. I'm thinking about auto generating the lists using everything in my "wallpapers" folder, but so far it's been easier to use find and then merge them by hand.

So that was the easy part. The hard part was getting xfdesktop to do something intelligent with it's "auto" setting for stretching/tiling them. In the defense of XFCE, I wanted some weird rules for my distorted aspect-ratio LCD screen. The xfdesktop defaults are to zoom anything that's not tile-able, which makes more sense if the aspect ratios match standard wallpaper sizes. The only really wonky thing they do is zoom in on the upper square of particularly bad aspect-ratio images, but I suppose normal people don't have manga pages and raw hubble footage in their rotation.

So to set that up I had to hack XFCE (see my previous post for getting this to work nice with Gentoo). I'm happy to report that it wasn't too hard. The xfdesktop code I looked through was pretty easy to read.

Basically I made it tile slightly more things, and then not distort things too much. (The specific numbers were chosen by looking at how the standard wallpaper resolutions looked on my monitor.) Here's my final patch:
diff --git a/src/xfce-backdrop.c b/src/xfce-backdrop.c
index 486a796..a028f3f 100644
--- a/src/xfce-backdrop.c
+++ b/src/xfce-backdrop.c
@@ -805,17 +805,34 @@ xfce_backdrop_get_pixbuf(XfceBackdrop *backdrop)
     }
     
     if(backdrop->priv->image_style == XFCE_BACKDROP_IMAGE_AUTO) {
-        if(ih <= h / 2 && iw <= w / 2)
+        xscale = (gdouble)w / iw;
+     yscale = (gdouble)h / ih;
+     gdouble sDiff = xscale - yscale;
+     if(sDiff < 0) {
+      sDiff = -sDiff;
+     }
+     
+     int xTile = (ih <= h/2);
+     int yTile = (iw <= w/2);
+        
+        if(xTile && yTile) {
             istyle = XFCE_BACKDROP_IMAGE_TILED;
-        else
-            istyle = XFCE_BACKDROP_IMAGE_ZOOMED;
-    } else
+        } else if ((xTile || yTile) && sDiff < 0.36) {
+         istyle = XFCE_BACKDROP_IMAGE_TILED;
+        } else if ( sDiff < 0.30) {
+            istyle = XFCE_BACKDROP_IMAGE_STRETCHED;
+        } else {
+         istyle = XFCE_BACKDROP_IMAGE_SCALED;
+        }
+    } else {
         istyle = backdrop->priv->image_style;
+    }
     
     /* if the image is the same as the screen size, there's no reason to do
      * any scaling at all */
-    if(w == iw && h == ih)
+    if(w == iw && h == ih) {
         istyle = XFCE_BACKDROP_IMAGE_CENTERED;
+    }
     
     /* if we don't need to do any scaling, don't do any interpolation.  this
      * fixes a problem where hyper/bilinear filtering causes blurriness in

Now all I have to do is go through my wallpapers and figure out which ones I really want in my rotation...

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.