dowie

Optimising fluxbox for multiple monitors and power events (ACPI)

dowie at

Optimising fluxbox for multiple monitors and power events (ACPI) https://dowe.io/optimising-fluxbox-multiple-monitors-power-events-acpi/ Screenshot of GNU/Linux Fluxbox desktop

[ this article is an incomplete draft, published for posterity ]

If you want to learn more about the GNU / UNIX operating system, and how Linux interacts with it, using a minimal installation of GNU/Linux will help.  It is harder work than installing and using GNOME 3 or KDE, but the benefits soon outweigh the costs.

Preface: Migrating to a leaner window manager

This article was created on fluxbox, but can probably be applied to any minimalist window manager for GNU/Linux.  My current operating system is Devuan, a fork of Debian.

If you are coming from Linux and have used XFCE, GNOME or KDE, or if you use macOS or Windows, prepare to invest some time in learning a new, yet more basic way of doing things.  Many people will claim that manually doing things in a terminal window is “old fashioned” or slow.  Actually, the more cloud-based and cloud-focused the world becomes, the more all of our programmatic and systematic workflows will rely on Linux.  Having a reasonable understanding of the GNU operating system software can only be an advantage for people these days.

But I digress.  I have written to some length about my love/hate relationship with GNOME 3.  Many of the design decisions of GNOME 3 are admirable but, in implementation, some of its features can become burdensome.  Using fluxbox, there is enough of a window manager for general productivity, but no more.  fluxbox is fast, yet it is so minimal that there is/are:

  • No native GUI tools to adjust its settings
  • No way of handling multiple monitors
  • No built in sound management
  • No native network management
  • No concept of power management
  • No icons on the “desktop”, and in fact, it’s not really a “desktop” at all – just a screen
  • A menu!  Yes, right-click on the desktop to access a menu and launch your programs! 😉
  • Workspaces.  Yep, that bastion of GNU/Linux productivity that us “open sorcerers” all enjoyed for years, before Windows 10 and Mac OS X (Lion) copied on…
  • Settings.  If you’re happy editing a text file, that is.  But if there’s one thing most people know how to do, that’s edit text files.

So, if none of the above phases you, then either you already use fluxbox, or you’re planning to and have now realised that this article is not about installing it for you!  Ah no… if you want some good guides to fluxbox, check out fluxbox.org, Arch’s fluxbox page or Debian’s fluxbox page.

Configuring easier multi-monitor support

Laptop with additional monitor connected.

My ThinkPad with an external display attached.  Yep, snapped while creating this post.

Being such a minimalistic “desktop”, fluxbox is not built to handle multiple monitors.  In GNU/Linux, a popular tool to handle this task is xrandr.

xrandr is handy.  It provides descriptive text output that can be used fairly easily as logical input in a script.

Here’s an example of xrandr on my dual display set-up:

# xrandr

Screen 0: minimum 320 x 200, current 1920 x 1980, maximum 8192 x 8192
LVDS1 connected 1600x900+0+1080 (normal left inverted right x axis y axis) 309mm x 174mm
 1600x900 60.01*+ 40.00 
 1440x900 59.89 
 1360x768 59.80 59.96 
 1152x864 60.00 
 1024x768 60.00 
 800x600 60.32 56.25 
 640x480 59.94 
VGA1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
HDMI3 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 478mm x 269mm
 1920x1080 60.00*+
 1680x1050 59.88 
 1280x1024 75.02 
 1440x900 74.98 59.90 
 1280x960 60.00 
 1280x800 59.91 
 1152x864 75.00 
 1280x720 59.97 
 1152x720 59.97 
 1024x768 75.08 70.07 60.00 
 832x624 74.55 
 800x600 72.19 75.00 60.32 56.25 
 640x480 75.00 72.81 66.67 60.00 
 720x400 70.08 
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)

My laptop’s display is identified as LVDS1, and my external monitor is HDMI3, despite that I connect via DVI.  This output was generated with my laptop in a docking station, so without this it may report a DVI connection as HDMI1 or HDMI2.  The T420 also has a DisplayPort++ interface, which would appear to be one of DP{1-3}, and a VGA output too.

The sections we’re interested in here are:

LVDS1 connected 1600x900+0+1080 (normal left inverted right x axis y axis) 309mm x 174mm
 1600x900 60.01*+ 40.00 
[...]
HDMI3 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 478mm x 269mm
 1920x1080 60.00*+

Two things of note:  Firstly, when a monitor is connected to a display interface, xrandr reports this as “connected”.  Otherwise, it’s “disconnected”.  Secondly, a monitor may be connected but may not be active.  How do we tell this?  Well, the resolution line displays an asterisk if the display is active, and omits an asterisk if not.  Working on the basis that the xrandr output will always list resolutions from maximum to minimum, and that we would want any monitor to run at best (native/highest) resolution, we can assume that it’s ok to test for the presence of this asterisk in the line that follows the main display line.

(UPDATE: 8 Dec 2016)

Next steps

Since drafting this article in August, my computer and computing needs have changed drastically over the past few months.  Despite a happy 16+ year relationship with Linux on the desktop (YMMV, BTW, but for me every year for me was the “Year of LOTD“), my working and personal computing needs came to an impasse which could only be resolved by moving over to a Mac.  My feelings and initial impressions of Mac usage are still true; for a better desktop, get GNOME – even if there have been several annoying problems.

Coming back to configuring xrandr, I’m afraid I never completed this exercise and instead opted for a quick and dirty logic script that determined which monitors were connected.  Because monitor positions would rarely change, I hard-coded the positional relationship into the script.  The scriptis will be below (when I’ve found it).

As I continue on with the Mac, I will dump more of the old Linux-y stuff into my blog, to use mainly as a reference for myself should I every have the pleasure of going back there one day.

(UPDATE: 14 Feb 2017)

After 10 months of trial and error, I am finally giving on up the Mac as a means to do work.  I’m faster and happier on GNU+Linux, so that’s where’s I’m headed.  Again.  Happy times! 😀

I’ll still post the script when I find it.

The post Optimising fluxbox for multiple monitors and power events (ACPI) appeared first on dowe.io.

Twitter