Showing posts with label zaphod multihead. Show all posts
Showing posts with label zaphod multihead. Show all posts

Friday, September 12, 2014

Open documents in an application on a different X display

When running multihead with separate servers for each screen (Zaphod mode, not Xinerama), there comes occasional need to launch applications on a display other than the one currently in use.  This comes up in various tasks:
  • Launch an app on screen A from a panel launcher on screen B
  • Place application windows on various screens with a session recovery script
  • Open a URL in a web browser from an application on a different screen
It's the third task which is the solution to a problem I encountered when setting up Thunderbird.  Unless Thunderbird is on the same X display as the browser, It will fail with the error

Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.
YOU BROKE IT, MILLIE!

I mention Thunderbird, but this could be Evolution or some other app. The target application doesn't have to be a web browser either.  In fact, if your browser and mail client are on different screens, the browser won't be able to open mailto links in the mail client either.  In these cases, the core of the solution is to temporarily change the $DISPLAY environment variable.
#!/bin/bash
# allows thunderbird to pass URLs to a browser on a different $DISPLAY

cdisp=$DISPLAY
DISPLAY=:0
palemoon $1
DISPLAY=$cdisp
Change the executable name and display numbers to suit. 

For Thunderbird specifically, enabling the use of this script requires changing the attachment handler settings.  Since there is no way to add new entries in the Attachments section of the Preferences dialog (on TB 24), open about:config and set network.protocol-handler.warn-external.http and network.protocol-handler.warn-external.https to TRUE. This forces a user dialog when a link of either type is clicked. Select the new script in both cases. Once successful, the dialog shouldn't pop up again. The resultant settings generated by these actions are visible/editable in the Attachments section of the Preferences dialog. 

It's worth noting that applying these methods to Firefox will open the URL in the existing Firefox session. If you expect to open a new Firefox window on another screen, you're pretty much shit out of luck as far as i know. There are certainly some dodgy workarounds, though.

Wednesday, September 10, 2014

Fix black missing window decorations in xfwm4

This is one of many problems i seem to have a problem discussing with anyone due to the growing rarity of Zaphod X configurations. In my configuration, i have three screens on different xorg servers (no xnest).  Using Mint14 and XFCE, when i log into my desktop environment, there are no window decorations (title bars, buttons, frames) drawn for the windows on displays :0.1 or :0.2. Only the first display (:0) has any window decorations; everything else is black.

Left: Everything is fine.  Right: Windeco's are missing


In my case, going to the Window Manager settings dialog and cycling between themes was sufficient to fix the issue.  If GTK settings are altered, the fix will need to be re-applied.  In order to simplify and automate this workaround, I  slapped a script together that uses xfconf-query to cycle to a different xfwm4 theme and back:

#!/bin/bash
# resets the xfwm4 window decoration theme
# this is a workaround to help enforce drawing on secondary $DISPLAYs

xfconf-query -c xfwm4 -p /general/theme -s Tgc
sleep 0.5
xfconf-query -c xfwm4 -p /general/theme -s Next

Stick this script wherever is convenient for your session startup needs.  I use it in a session template script, but there are more conventional places to put it.