Middle click the desktop to create a new note

December 1, 2014

I still use Openbox daily, but recently decided to finally give some of the big desktop environments a serious try. The last time I really tried Gnome or KDE was before their big shifts (to 3. and 4. respectively). A friend had been speaking highly of the latest Gnome versions and claimed several features of it enhanced his workflow and productivity. Was I missing out on all these great developments by sticking with Openbox? I gave Gnome and KDE another try, using them for my usual work for a few days each. There are indeed some nice features in these newer versions, and I particularly liked some of the new aspects of KDE.

But I am now back with Openbox, because I feel so much more at home in it (having spent a few years fine tuning a desktop that suits my needs), and because I still don’t understand why I need to spend so much of my laptop’s resources on window and desktop management (resources that are not a plenty with older laptops!).

One feature of KDE I particularly liked: middle click on the desktop and the text in your primary X clipboard (the clipboard that contains the text that is merely highlighted, and that is normally pasted with a middle mouse click) is pasted into a new note on the desktop. Very handy for information you quickly want to store somewhere (for however long you want to)!

When I moved back to Openbox, I immediately decided to implement that in my Openbox desktop, using xpad. Here is how I did it.

Open your favourite text editor and create the following script:

#!/bin/sh
FILE="/tmp/xpadclick.txt"
xclip -selection p -o > $FILE ; xpad --new-from-file=$FILE

(If, for some reason, you want this to work with the text you copied with Ctrl+C use “xclip -selection c -o” instead of “xclip -selection p -o” in the above script.)

Note that this requires xclip to be installed (besides xpad, obviously). If you don’t have it installed, you can do so on Debian systems with the following command:

sudo apt-get install xclip

Save the script (I saved it as ~/.scripts/xpad-middleclick.sh), and make it executable (chmod +x ~/.scripts/xpad-middleclick.sh).

Now you have to tell Openbox to run the script whenever you middle click on the desktop. Open your rc.xml file and search for <mousebind action=”Press” button=”Middle”> in the mouse section, under <context name=”Root”>. The default is as follows:

<mousebind button="Middle" action="Press">
<action name="ShowMenu"><menu>client-list-combined-menu</menu></action>
</mousebind>

Change this into the following (make sure the path points to wherever you saved the above script):

<mousebind action="Press" button="Middle">
<action name="Execute">
<execute>~/.scripts/xpad-middleclick.sh</execute>
</action>
</mousebind>

Reconfigure Openbox, and you can quickly create an xpad note of the selected text whenever you middle click on the desktop.

If you don’t want Openbox to draw window decorations for xpad, add the following to your rc.xml (in the applications section):

<application name="xpad">
<decor>no</decor>
</application>

And here is a totally unnecessary picture of the end result:

xpadnote

(For those of you who prefer Tomboy: I’m not sure whether you can do this with Tomboy. Unlike xpad, Tomboy does not have a cli option to create a new note from file. Perhaps it is possible to achieve a similar result using tomboycli, but I have not tried to do so.)

4 Responses to “Middle click the desktop to create a new note”

  1. PK said

    Hi,

    it’s great you’ve tried something new! πŸ™‚

    Also I know you’re strong Openbox fan, may be you’d be interested in tiling WMs. Tiling is ineed strange by start, but in no time you’ll be at home, given user make some hotkeys at fingertips. I’d start with i3wm as it is well designed and simple (almost no confgi-feedling needed).

    Tiling WM layout windows (usually) in one layer on the visible surface. dividing space equally, user able to resize windows. There may be some floating windows (like open file dialogs, and user able to make any window floating), they are not resized by WM. User may move floating windows with Mod+LFM (as ususal) and Mod stands for any – Alt, Shift, Ctrl or Win key as user specifies. Also, Mod+RMB is for window resizing, even tiled windws could be resized. (very handy!)

    In extreme case, one maximized window takes whole physical screen (i3wm does this, others may stretch window across all available screens). So, how then should one use more than one window? In my expereince, the windows are centered around some task at hand of user; and there are multiple virtual desktops. So one user task (several windows) – one virtual desktop. There is ususally 10 virtual desktops in quick access (Mod+1…Mod+9,Mod+0).

    I’d also recomend to move all window management hotkeys to Win+ combinations for easy of use and (usually) no collisions.

    For example:
    – move current window to 3rd virtual screen: Win+Shift+3
    – switch focus to the window to the left of current: Win+Left
    – switch to 4th virtual workspace: Win+4
    – close current window (which has focus, it may be floating window): Win+Esc (this combination have proved to be uber-handy, very natural for one hand)
    – open terminal window (it is not window management, but usefull to get started): Win+Enter
    – and last, quick launch: Win+Space

    For the quick launch I use dmenu-run modified with my preferred applications. It is very convinient to launch browser. So, I use Chromium, it’s executable file is chromium. To launch it I type: Win+Space, iu, Enter. Vuala, Chromium window started at current worksapce.

    I use this setup at work (I’m a Software QAE) and at home; in the few days (may be a week, when I finished tinkering with compton shadows and such nonsense πŸ™‚ ), my work comfort somehow rised, I was switching between activities smoother and sharper at the same time. πŸ™‚

    Hope my little intervention with tiling WMs and non-conformists’ ideas will inspire you for something new and make you more productive.

    P.S. There is a caveat in tiling philosophy — programs with unlimited amount of windows just trash all the idea. Instant Messengers just pollutes workspace, producing tens of windows. Then tiling WM tries to squish them into one physical screen and chats becomes small and unusable, manual intervention required… πŸ™‚

    • PK said

      (Oh, I made some mistypes. What a shame. Please, excuse me!)

    • urukrama said

      I have used tiling window managers in the past (mainly awesome and musca), and still occasionally play with them, as earlier posts demonstrate, but I found it easier to use a non-tiling window manager like Openbox for work.

  2. Herman Schindler said

    Hi,

    I totally agree with your point of view about Openbox. I have been using Openbox for a long time and I am sticking to it too.

    Best regards,

    Herman

    El 01/12/14 a las 19:30, urukramas weblog escibiΓ³: > WordPress.com > urukrama posted: “I still use Openbox daily, but recently decided to > finally give some of the big desktop environments a serious try. The > last time I really tried Gnome or KDE was before their big shifts (to > 3. and 4. respectively). Recently, a friend had been speaking hig” >

Leave a comment