Friday, October 22, 2010

Switching Displays/Monitors in Fedora with Gnome and xrandr

This is one is mostly for my own reference. In my case, I'm hooking up my work Latitude to an HP external monitor, and I want the HP to have the main panels and be the main desktop. This must be executed as root, hence "#" and not "$" in example below:

# xrandr --output HDMI1 --primary

Running xrandr without any options will list the all available devices and indicate which ones are connected and in use. In my case, LVDS1 is laptop's monitor:

# xrandr
Screen 0: minimum 320 x 200, current 3040 x 1200, maximum 8192 x 8192
LVDS1 connected 1440x900+1600+300 (normal left inverted right x axis y axis) 331mm x 207mm
   1440x900       60.0*+   40.0  
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
VGA1 disconnected (normal left inverted right x axis y axis)
HDMI1 connected 1600x1200+0+0 (normal left inverted right x axis y axis) 408mm x 306mm
   1600x1200      60.0*+
   1280x1024      85.0     75.0     60.0  
   1280x960       60.0  
   1152x864       75.0  
   1024x768       85.0     75.1     60.0  
   832x624        74.6  
   800x600        85.1     60.3  
   640x480        85.0     75.0     60.0  
   720x400        70.1  
DP1 disconnected (normal left inverted right x axis y axis)
...

Friday, May 21, 2010

Win32 GUID in Elisp

I work with WiX source files in Emacs (using James Clark's excellent nxml-mode) a lot and sometimes need to create a GUID. I was going to the trouble of calling guidgen.exe, copying, pasting, and formatting (upcasing, and adding the "{}"). Then I did some digging in org-mode to see how it was generating GUIDs: they use uuidgen from E2fsprogs which is available in cygwin and in Linux. OS X also has this utility but is a different version that does not support the same options.

Here's my implementation:

(defun insert-guid ()
  "Inserts a Win32 GUID."
  (interactive)
  (let ((guid (shell-command-to-string "uuidgen|tr -d '\\n'")))
    (insert (concat "{" (upcase guid) "}"))))

I pipe the ouput to tr to remove any newlines.

Saturday, October 17, 2009

WiX and MSXML 6 SP2

I set out to add MSXML 6 to the package we are creating with WiX 3.0. At first I looked for a merge module (MSM), but no luck. I later found this reasoning:
http://channel9.msdn.com/forums/Coffeehouse/256077-MFC-dependencies-madness/?CommentID=323942

I might have thought about extracting the DLLs, but not seriously. Just as well:
http://channel9.msdn.com/forums/Coffeehouse/256077-MFC-dependencies-madness/?CommentID=324015

So that left me needing to author a custom bootstrapper package for MSBuild. I started with this tutorial, which has a few typos/bugs, but got me what I needed:
http://msdn.microsoft.com/en-us/library/aa730839%28VS.80%29.aspx

The particular EXE used is for MSXML6 SP2, and can be found here:
http://www.microsoft.com/downloads/details.aspx?familyid=59914795-60C7-4EBE-828D-F28CB457E6E3&displaylang=en

<?xml version="1.0" encoding="utf-8"?>
<Product
    xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
    ProductCode="Microsoft.MSXML.6.SP2">

  <PackageFiles>
    <PackageFile Name="msxml6-KB954459-enu-x86.exe"/>
  </PackageFiles>

  <InstallChecks>
    <MsiProductCheck 
        Property="IsMsiInstalled" 
        Product="{1A528690-6A2D-4BC5-B143-8C4AE8D19D96}"/>
  </InstallChecks>

  <Commands>
    <Command PackageFile="msxml6-KB954459-enu-x86.exe" Arguments="">
      <InstallConditions>
        <BypassIf 
            Property="IsMsiInstalled" 
            Compare="ValueGreaterThan" Value="0"/>
        <FailIf Property="AdminUser" 
                Compare="ValueNotEqualTo" Value="True"
                String="NotAnAdmin"/>
      </InstallConditions> 

      <ExitCodes>
        <ExitCode Value="0" Result="Success"/>
        <ExitCode Value="1641" Result="SuccessReboot"/>
        <ExitCode Value="3010" Result="SuccessReboot"/>
        <DefaultExitCode Result="Fail" String="GeneralFailure"/>
      </ExitCodes>
    </Command>
  </Commands>
</Product>