Rearrange windows on iconbar in Fluxbox

I don’t know C++, so I don’t know how to add a patch to Fluxbox to make it easy to drag and rearrange the windows on the iconbar (aka taskbar). But I’ve dabbled with some higher-level X tools, and here’s my dirty solution to rearrange the windows.

# designed to be used with a keyboard shortcut
# in ~/.fluxbox/keys that could be:
# Control Shift Mod4 X :Exec /home/username/bin/
xdotool getactivewindow windowunmap windowmap

This is original research.
Any arbitrary window that is active, can be hidden and then redrawn, to make it show up last in the list, so it is on the end. Do it enough, and the remaining windows will be bumped to the first in the list.


This functionality has been requested in fluxbox itself, but has not been implemented: Fluxbox / Feature Requests / #94 Rearrange toolbar buttons order

Fix Palemoon browser mouse scroll wheel goes through history when using Fluxbox

The solution

In my ~/.fluxbox/startup:

xinput set-button-map "$( xinput | awk -F'[=]' '/ouse/{print $2}' | awk '{print $1}' | head -n1 )" 1 2 3 4 5 6 7 0 0 &

The story

I installed Devuan ceres on a desktop workstation as part of my research into lightweight window managers. I installed my self-rolled dpkg of Palemoon (source on gitlab) because I have been actively reducing my use of upstream Firefox. When I scrolled up with the mouse wheel, the browser jumped back and forth in history. If the current tab in the browser has no previous pages, then the scrolling operates just fine.

Apparently I’m a unicorn. Nobody has had this exact problem in this environment before (Windows users of Firefox changing the about:config don’t count). Relevant xkcds include a tiny bit of xkcd#979 and a healthy dose of xkcd#1495.

I investigated many different methods to try to solve my problem. I tried changing the about:config settings in the browser (specifically mousewheel.default.action and similar) which did not solve my problem.

My next attempt involved file ~/.fluxbox/keys to assign commands to mouse button actions to reduce the effect they have in the window, which failed to suppress the undesirable actions.

I investigated using xbindkeys to control what is sent to the X server when it receives certain inputs. I even tried complicated guile logic, which actually seems quite nifty, but it just didn’t accomplish what I wanted in this case. I found an interesting example (secondary reference 3) where some toggling logic was shared, and I spent a lot of time trying to tinker with that.

I finally found what I was looking for on the Arch Wiki (primary reference 1), go figure. Those Arch folks know how to help a guy no matter the distro! You can use xinput to change what signals are sent to X from the device by remapping the buttons. You can suppress a button with 0.
The wiki helpfully explains how to find which device to modify. And then the series of numbers after that are the button mappings. So the first button, is mapped to the first number, and so on. If a button is mapped to 0, it is effectively ignored.

xinput set-button-map "$( xinput | awk -F'[=]' '/ouse/{print $2}' | awk '{print $1}' | head -n1 )" 1 2 3 4 5 6 7 0 0 &

In my example, I mask buttons 8 and 9. Using xev and xbindkeys -mk I learned that my mouse (a generic HP mouse since I’ve never cared about fancy peripherals) sends button 4 on scrolling up, and then button 8 and button 9 when stopping the scrolling up action. It was the button 8 (and 9) that were causing weird issues with the browser. When I mask the input with xinput as seen here, the scrolling operates completely normally and as expected.

The probable causes

I have been using this mouse with Xfce on Fedora for years, and the scrolling has never been a problem. I suspect my choice of installing all the packages myself on a Devuan netinst contributed to the problem. I had an issue with fonts on xscreensaver which was probably due to my minimal install. Perhaps Fluxbox does not perform some perfunctory task that desktop environments (DEs) do with sanitizing input. I don’t care, because Fluxbox has been quite satisfactory.

And as a side node, I haven’t found a debian-family “minimal” disc that can be used independently of a network, like the CentOS minimal disc image, only a netinst.



  1. Mouse buttons – ArchWiki []


  1. XBindKeys []
  2. xbindkeysrc.scm []
  3. [SOLVED] [xbindkeys] Advanced mouse binds? []
  4. fluxbox-keys(5) Manual Page []


xev – uesful to display info about keys are being pressed

xbindkeys -mk – same

xinput – manipulate mouse button mapping





xorg show current config

If you already have X running, and you try to generathe the xorg.conf file, you might get an error.

$ sudo Xorg -configure 
Fatal server error:
(EE) Server is already active for display 0
        If this server is no longer running, remove /tmp/.X0-lock
        and start again.
Please consult the The X.Org Foundation support 
 for help. 

What you need to do is use another virtual display/terminal/whatever (I’m still learning these terms).

sudo X :2 -configure

Thanks to Joe-ubunt at the Ubuntu Forums: [SOLVED] generate xorg.conf from current configuration

Run game in dosbox and make nice menu icon for it

When I want to play an old-school DOS game, I use the emulator DOSBox. I discovered that DOSBox has its own icon and uses its title in the window, and not the name of the game running inside. I now have a solution to change the icon and title that I want.

First of all, I make my .desktop file call my shell script.

$ cat ~/.local/share/applications/st25.desktop
[Desktop Entry]
Name=Star Trek 25th Anniversary
Comment=1993 DOS computer game
Keywords=Game;Star Trek;

The shell script calls dosbox with the custom batch file (from the olden days of non-free operating systems)

$ cat /usr/share/st25/
# Star Trek: 25th Anniversary game
cd "${GAMEDIR}"
dosbox ST25.BAT &
sleep 1
tid="$( xwininfo -root -children -all | grep -iE "dosbox.*STARTREK" | awk '{print $1}' )"
echo "modifying id ${tid}"
xseticon -id "${tid}" "${ICONFILE}"
xdotool set_window --name "STARTREK" "${tid}"
xdotool search --name "STARTREK" set_window --classname "STARTREK" --class "STARTREK" windowunmap windowmap

The above shell script is where the magic happens. The main emulator is executed and placed in the background. After a short delay, some X tools are used to find the specific application’s window ID.
A custom application named xseticon (available in my Fedora copr) written by Paul Evans is used to change the icon used by the window.
The more easily available xdotool (probably already bundled by your distro) can change the window name.
Additionally, xdotool can hide and re-show the window, to make the window manager and panel recognize the new icon and name!

And just for completeness’s sake, here is the batch file.

$ cat /usr/share/st25/ST25.BAT
REM Star Trek: 25th Anniversary game

MOUNT C /usr/share/st25


This is my preferred way to run a DOS-based application: desktop file, shell script, batch file. Yes, it spawns the extra process with the shell script, but I want to be able to call an application from the command line easily.

How do you make your DOS programs accessible to users on cli or the desktop?


For a complete list of Internet resources used to build this process, see my other post, X11 change application titlebar and icon in window manager panel.

X11 change application titlebar and icon in window manager panel

If you are trying to change the listing of a running application in the window list, regardless if you’re running XFCE or Cinnamon or another display manager, you might want to go down the same line of research I did.

In an upcoming article, I will talk exactly about how I run a game in DOSBox with a wrapping shell script and batch file. But today, this article is about how I rename the window and change its icon.

First, I run the application and I know what the titlebar looks like. I have to learn the window ID to set the icon.

I set the window title to the preferred name, and then use that window name to search and then execute a series of commands, which change the class and redraws the window so the panel learns the correct name.

tid="$( xwininfo -root -children -all | grep -iE "dosbox.*STARTREK" | awk '{print $1}' )"
echo "modifying id ${tid}"
xseticon -id "${tid}" "${ICONFILE}"
xdotool set_window --name "STARTREK" "${tid}"
xdotool search --name "STARTREK" set_window --classname "STARTREK" --class "STARTREK" windowunmap windowmap

I researched on the Internet to discover how to change the application icon. I had to compile a nifty little tool written in C (xseticon), so I bundled it into an rpm. But it does exactly as the description says.
Changing what appears on my Cinnamon panel was a different story, however.
I eventually remembered using xdotool for something in the past, and decided to read its man page. After a lot of experimentation, I got the classname and class adjusted. But it still didn’t do any good.
So I finally tried the windowunmap command, which was recommended after doing some other change. And then I had to hurriedly windowmap it again, so I could see the window. It doesn’t minimize the application; it removed it from the panel and display entirely, even though the process was still running. After the windowmap, it showed the custom icon, and the exact title I wanted!
I learned how to chain the commands together into fewer invocations.


Web links

link to xseticon
compiling xseticon
xseticon source
rpm spec
xseticon rpm in copr

Further reading

Internet searches

xprop change icon of running application

Man pages


Changing screen resolution on Linux terminal server

If you’re using xvnc on Linux (for example, if you’re running Xfce on xrdp on Fedora) and you want to resize the display, here’s a way to do it.

DISPLAY=:10 xrandr --output VNC-0 --mode 1024x768

You could also use an –auto instead of a –mode XxY setting.

Apparently I like to redo my own work.
Check out from my bgscripts package.

for word in $( xrandr --listactivemonitors | awk 'NR != 1 { print $NF; }'; ); do xrandr --output ${word} --auto 1>/dev/null 2>&1; done

Linux find running display manager

In GNU/Linux, if you ever need to know what your currently running display manager is, here is how you can find it:

x="$( sudo lsof -F '' /tmp/.X11-unix/X0 | head -n1 )" ; x="${x#p}"
display_manager="$( ps -p $( ps -o ppid -p ${x} | tail -n +2 ) -ho command )"
thisdm="$( basename "${display_manager}" )"




Find running X sessions


{ ps -eo pid,command | awk '/-session/ {print $1}' | while read thispid; do cat /proc/${thispid}/environ | tr '\0' '\n' | grep "DISPLAY" | sed -e "s/^/${thispid} $( stat -c '%U' /proc/${thispid}/comm ) $( basename $( readlink -f /proc/${thispid}/exe ) ) /;"; done; } 2>/dev/null | grep -iE "xfce|cinnamon"


I was working on a shell script that affects the running desktop environments. In order to find the running processes, owners, executable, and display session, I whipped up this one-liner.

Obviously here, I limit my searches to specific types of desktop environments. I was getting a dbus-daemon and at-spi2-registryd which I neither understand nor care about, so I added the regular expression search at the end. Feel free to modify for your own use.

Example output:

$ { ps -eo pid,command | awk '/-session/ {print $1}' | while read thispid; do cat /proc/${thispid}/environ | tr '\0' '\n' | grep "DISPLAY" | sed -e "s/^/${thispid} $( stat -c '%U' /proc/${thispid}/comm ) $( basename $( readlink -f /proc/${thispid}/exe ) ) /;"; done; } 2>/dev/null | grep -iE "xfce|cinnamon"
1791 bgstack15-local xfce4-session DISPLAY=:0

X forwarding for virt-manager to Windows

Story time! When I was working on my virtual environment, I rebooted my main desktop. So I was stuck using my Windows desktop for a minute, and I wanted to work on my virtual machines.

I decided to do some X forwarding, which for virt-manager on CentOS 7 needs some special steps.

On the server

The first thing is to install virt-manager. You also will need a piece of software named xauth, and some special fonts.

yum install -y virt-manager xauth dejavu-\*fonts


On the client

On the Windows client, you should install an X server. I picked Xming. It also needs it fonts installed.

Run Xming.

Connect to server with PuTTY. You will need to configure PuTTY to allow X forwarding, and to use the right X server.

Screenshot of Putty configuration screen showing X11 forwarding options
Telling PuTTY to allow X11 forwarding to localhost:0


Unfortunately, my keyboard input to the virtual machine does not work when I have it configured with a spice display. But it works when I use a vnc display. See for a closed bug report that has similar symptoms to this problem.

virt-manager settings of a virtual machine, showing where to change display to VNC server type.
Setting on virtual machine of VNC server or spice server.



  7. PuTTY