Samstag, 23. Februar 2013

Editing the context menu

When you right-click onto your Linux desktop you get a context menu like this:


I took this screenshot using Knoppix 7.0. My goal for today is to configure this menu.First step is to open a console and call

pcmanfm --desktop-pref

and select Advanced -> "Show menus provided by window managers when desktop is clicked":



Now you will not see a desktop menu when you right-click onto your desktop. But we will change this now. First install the window manager openbox:

sudo apt-get update
sudo apt-get install openbox

And run it

openbox --replace

You find that the menu has changed. You want to know which configuration files are used to build this menu so you run

cd
strace -e open openbox --replace 2>strace.txt

Now looking at strace.txt I find a line

open("/etc/xdg/openbox/menu.xml", O_RDONLY|O_LARGEFILE) = 6

ok, so it seems like openbox is using /etc/xdg/openbox/menu.xml for its menu structure. And indeed, we find there exactly the entries we see in the context menu. Once I changed it and re-ran

openbox --replace

my dream-menu for right-clicks was there:


The interesting thing is that I had no idea how to call the file manager (for "open files") from the command line. So I clicked on it and used the command xprop to find out its program name. I found it is pcmanfm.

So here is my /etc/xdg/openbox/menu.xml:

<?xml version="1.0" encoding="UTF-8"?>

<openbox_menu xmlns="http://openbox.org/"

        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://openbox.org/
                file:///usr/share/openbox/menu.xsd">

<menu id="root-menu" label="Openbox 3">

  <item label="Open a console">
    <action name="Execute"><execute>x-terminal-emulator</execute></action>
  </item>
  <item label="Browse the web">
    <action name="Execute"><execute>x-www-browser</execute></action>
  </item>
  <item label="Open files">
    <action name="Execute"><execute>pcmanfm</execute></action>
  </item>
  <item label="Take a screenshot...">
    <action name="Execute"><execute>ksnapshot</execute></action>
  </item>
  <separator />
  <item label="Configure desktop...">
    <action name="Execute"><execute>pcmanfm --desktop-pref</execute></action>
  </item>
  <item label="Restart">
    <action name="Restart" />
  </item>
  <separator />
  <item label="Exit">
    <action name="Exit" />
  </item>
</menu>

</openbox_menu>


Keine Kommentare:

Kommentar veröffentlichen

Raspberry Pi, test my internet connection

Since start of Corona times, I use my internet at home also for work. So its reliability and performance has become crucial. Performance see...