Showing posts with label xfce. Show all posts
Showing posts with label xfce. Show all posts

Monday, September 15, 2014

The mysterious shrinking terminal window

Terminator is a nice little tool for managing multiple gterm sessions within a single window.  I find the use of split screens very comfortable.  Terminator allows the creation of layout profiles to automate the setup of a particular tab/split configuration.  These can be selected with the --layout option when launching Terminator.  The problem with this is that at least under my current environment (Mint 14/XFCE), the resultant window spawns and then shrinks down as small as possible.  It's hard to describe, so maybe i should include a graphic. 

Whaaaaaat
I recall having read about this phenomenon elsewhere, though i don't recall if a solution or workaround had been revealed at the time.  Since i was issuing these commands primarily via a long, ugly session recovery script, my first hack-around solution was to use wmctrl to subsequently restore the window geometry.  This was fun to watch, but the better workaround is to just use the gnome geometry options from the start.
terminator --layout="yourlayoutname" --geometry=1280x977 
That was a pretty simple solution to a rather comical problem.

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.

Automatic GIMP dock window exporting


To my knowledge, GIMP is unlike other applications under X in one particular sense; it has the inbuilt functionality to export its windows to other X displays. Besides the bizarre, a more common application is to move GIMP windows onto different monitors (screens) in a multihead configuration (Zaphod mode, not Xinerama). This functionality is available on the window menus and in theory, these window locations should even be saved in the sessionrc data. ... But that's where everything breaks.
The export menu items

In my experience with GIMP 2.8.2 and a few earlier versions under xfwm4/Mint14, the sessionrc file normally contains all the correct geometries for a dock window which has been exported to another X display; however, when GIMP exports the window during launch, the window is initialized at a minimal size instead of the specified overall geometry. Resizing the window like this destroys any specific internal geometries (i.e. the relative widths of individual dock tabs). I'm not terribly sure, but i suspect that it's a window manager problem and that a simple delay during the export process would fix the problem.

The collapsed dock window.  Internal geometry is lost.

My workaround was to simply automate a manual window export routine. Since the two displays normally used for both the GIMP image window and the exported dock have the same dimensions, I simply configure both to be created on the same display. I then set GIMP preferences to save the window positions. Subsequently, i turn off session save features and even set sessionrc to read-only (just for good measure).

A short script using xdotool does all the work:

#!/bin/bash
# this script launches gimp and exports the tools/layers dock window
# this avoids the fact that gimp's session manager cannot accurately place the
# window if exported during launch
# may be due to laggy wm data during concurrent placement of other gimp windows
# click placement is dependent on screen dims, themes

gimp &

while [ "$(wmctrl -l | grep "Layers")" == "" ]; do
  sleep 0.1
done

DISPLAY=:0.2
wmctrl -s 1
sleep 0.5
DISPLAY=:0

keytime=0.005

xdotool search --screen 0 --name "Layers" windowfocus;
sleep 0.1; xdotool mousemove 1266 60
sleep 0.3; xdotool click 1

for i in `seq 1 12`; do
  sleep $keytime; xdotool key Down
done

sleep $keytime; xdotool key Right

for i in `seq 1 3`; do
  sleep $keytime; xdotool key Down
done

sleep $keytime; xdotool key Return

echo "window move attempted"

It's a cringe-worthy open-loop sort of approach, but it does work. This script launches GIMP with the unexported dock window on the same screen. It raises the dock window, clicks on the menu button, and uses key events to navigate to the desired menu entry.

Simply tailor the script to fit your application:
  • menu button location (1266 60)
  • $DISPLAY values for particular screens
  • dock window title string
  • number of key events to reach your menu item
  • adjust key delay if necessary