Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Running Ubuntu 12.10 with Xubuntu-Desktop. Would like window to minimize if I middle-click on its title bar. Can't find any setting for this. Is it possible?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Yes, this is possible- I have been experimenting with xdotool and xbindkeys, and they are mostly all you need to pull it off, so please enter

sudo apt-get install xdotool xbindkeys x11-utils xinput

Now, your middle mouse button is usually button 2, but you can check by using xev and clicking in the event tester box, or looking at the output of xinput. Enter xinput and that will list your devices, so note the id for your mouse and then enter

xinput list-props < device id >

to find details on your mouse buttons. You can always choose a different mouse button if your middle button doesn't register properly or is unavailable.


The xdotool command you need for what you want to do is:

xdotool getactivewindow windowminimize

This command minimises the active window; however this action must also be associated with mouse button 2 and the way to do that is to use xbindkeys. We place the above command in ~/.xbindkeysrc (see below) and associate it with the middle mouse button (b:2), so that the depressing of mouse button 2 triggers the xdotool command.

(This xdotool command will work in the terminal if executed and will minimize it, so showing that it is the necessary command for what you want.)

This entry must be placed in your ~/.xbindkeysrc:

"xdotool getactivewindow windowminimize"
b:2

The xdotool command must also be enclosed in quotes (as above) when placed in that file.

So that xbindkeys re-reads the file, you can clear current bindings with killall xbindkeys and then just execute xbindkeys to restart it.

Now your command will be available; xbindkeys doesn't seem to need to be put in startup for me, and you can run your command without rebooting; you can cancel it any time again by entering killall xbindkeys and then editing your ~/.xbindkeysrc.

share|improve this answer
    
Thanks so much for this. I will give it a go :) –  nLinked Dec 10 '12 at 22:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.