You are not logged in.

#1 2012-02-10 22:48:59

Toxcity
Member
From: Oxford
Registered: 2012-01-14
Posts: 40

[SOLVED] Openbox Application Menu

Good evening everyone!

Just done a clean install of Arch and now working on my applications menu. I want a automatically generated application menu exactly like ArchBang.
I have installed openbox-menu and all I get is "Menu not found, Please specify a menu specification file.". How do I get a menu like ArchBang without using ArchBang?

Thanks in advance!

Nic

Last edited by Toxcity (2012-02-11 16:34:27)

Offline

#2 2012-02-11 02:29:09

Mr_ED-horsey
Member
From: Portland, OR
Registered: 2011-04-06
Posts: 177

Re: [SOLVED] Openbox Application Menu

I don't think there are any automatically generated menus for openbox. ArchBang just comes with obmenu preconfigured on install. But to get the right click menu type:

pacman -S obmenu

launch the GUI menu editor by typing 'obmenu' from your terminal and edit the menu however you wish.


Desktop: Fedora 21 Mate + Compiz [x86_64] on 2 TiB HDD  /  Windows 7 Professional [x86_64] on 500 GiB HDD
Laptop: Arch Linux + Openbox [i686] 120 GiB SSD on Acer c720 Chromebook

Offline

#3 2012-02-11 02:48:38

SteveK
Member
Registered: 2010-06-11
Posts: 80

Re: [SOLVED] Openbox Application Menu

I don't know what archbang uses, but you could have a look at obmenugen in AUR.  It bases it's menu on *.desktop files.

Offline

#4 2012-02-11 03:26:38

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: [SOLVED] Openbox Application Menu

Did you follow the wiki to install openbox?  If so you should not get that error - you should have copied the default files to your ~/.config/openbox/ folder.

The default (for OB 3.5) even comes with pipe-menus set up by default.  No extra packages are needed - just read up on pipe-menus.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2012-02-11 10:34:38

Toxcity
Member
From: Oxford
Registered: 2012-01-14
Posts: 40

Re: [SOLVED] Openbox Application Menu

ArchBang uses openbox-menu to generate it's application menu, it also assigns the correct icons to the menu entries.
Basically, I want my menu like that without me having to manually create it.

I'm looking at obm-xdg at the moment.

Offline

#6 2012-02-11 10:44:42

Toxcity
Member
From: Oxford
Registered: 2012-01-14
Posts: 40

Re: [SOLVED] Openbox Application Menu

I've ended up using a script which I found in the Arch wiki page for Openbox. Working fine now. Thanks for the help guys!
Make sure you have gnome-menu installed. wink

How do I mark this as solved?

Last edited by Toxcity (2012-02-11 10:45:57)

Offline

#7 2012-02-11 15:12:25

Dustbin
Member
From: The Netherlands
Registered: 2011-12-07
Posts: 124

Re: [SOLVED] Openbox Application Menu

Toxcity wrote:

[...] How do I mark this as solved?

Edit your first post and change the title into for example '[SOLVED] Openbox Application Menu'...


If the Matrix was real, it would run on Arch...

Offline

#8 2012-02-16 08:43:59

donniezazen
Member
From: Salt Lake City
Registered: 2011-06-24
Posts: 671
Website

Re: [SOLVED] Openbox Application Menu

Toxcity wrote:

I've ended up using a script which I found in the Arch wiki page for Openbox. Working fine now. Thanks for the help guys!
Make sure you have gnome-menu installed. wink

How do I mark this as solved?

Care to elaborate on that. I am also looking for an easier way to get started. What script? and why gnome-menu? A picture would be great, please.

EDIT: I was able to make some changes using obmenu. I have configured xdg to generate list of installed softwares. I suppose I will have to manually run update-menus every time I want to see newly installed software. Will update-menus only add newly installed software or will it regenerate whole list? Would be great if it's automatic in line to following scheme.

CUSTOM ENTRIES
*****************
AUTOMATICALLY GENERATED LIST (APP, MUSIC, ETC)
*****************
MORE CUSTOM ENTRIES

Thank you.

Last edited by donniezazen (2012-02-16 09:42:20)

Offline

#9 2012-02-16 09:01:55

Toxcity
Member
From: Oxford
Registered: 2012-01-14
Posts: 40

Re: [SOLVED] Openbox Application Menu

It seems gnome-menu is used to give it the layout. I personally quite like the gnome menu layout so it's perfect for me.

apps_menu.png

Offline

#10 2012-02-16 09:44:32

donniezazen
Member
From: Salt Lake City
Registered: 2011-06-24
Posts: 671
Website

Re: [SOLVED] Openbox Application Menu

Thanks for posting that. Could you post your menu.xml or point me to the script that you found on Arch Linux.

Offline

#11 2012-02-16 09:59:40

Toxcity
Member
From: Oxford
Registered: 2012-01-14
Posts: 40

Re: [SOLVED] Openbox Application Menu

You're welcome mate! :)

<menu id="apps-menu" label="Applications" execute="python2 /home/nic/.config/openbox/scripts/apps"/>

That's the line I have in my menu.xml for the menu, it points to the script called apps. Below is the script:

#!/usr/bin/python
#
import xdg.Menu, xdg.DesktopEntry, xdg.Config
import re, sys, os
from xml.sax.saxutils import escape

icons = True
try:
	from gi.repository import Gtk
except ImportError:
	icons = False

def icon_attr(entry):
	if icons is False:
		return ''

	name = entry.getIcon()

	if os.path.exists(name):
		return ' icon="' + name + '"'

	# work around broken .desktop files
	# unless the icon is a full path it should not have an extension
	name = re.sub('\..{3,4}$', '', name)

	# imlib2 cannot load svg
	iconinfo = theme.lookup_icon(name, 22, Gtk.IconLookupFlags.NO_SVG)
	if iconinfo:
		iconfile = iconinfo.get_filename()
		iconinfo.free()
		if iconfile:
			return ' icon="' + iconfile + '"'
	return ''

def entry_name(entry):
	return escape(entry.getName().encode('utf-8', 'xmlcharrefreplace'))

def walk_menu(entry):
	if isinstance(entry, xdg.Menu.Menu) and entry.Show is True:
		print '<menu id="%s" label="%s"%s>' \
			% (entry_name(entry),
			entry_name(entry),
			escape(icon_attr(entry)))
		map(walk_menu, entry.getEntries())
		print '</menu>'
	elif isinstance(entry, xdg.Menu.MenuEntry) and entry.Show is True:
		print '	<item label="%s"%s>' % \
			(entry_name(entry.DesktopEntry).replace('"', ''),
			escape(icon_attr(entry.DesktopEntry)))
		command = re.sub(' -caption "%c"| -caption %c', ' -caption "%s"' % entry_name(entry.DesktopEntry), entry.DesktopEntry.getExec())
		command = re.sub(' [^ ]*%[fFuUdDnNickvm]', '', command)
		if entry.DesktopEntry.getTerminal():
			command = 'xterm -title "%s" -e %s' % \
				(entry_name(entry.DesktopEntry), command)
		print '		<action name="Execute">' + \
			'<command>%s</command></action>' % command
		print '	</item>'

if len(sys.argv) > 1:
	menufile = sys.argv[1] + '.menu'
else:
	menufile = 'applications.menu'

lang = os.environ.get('LANG')
if lang:
	xdg.Config.setLocale(lang)

# lie to get the same menu as in GNOME
xdg.Config.setWindowManager('GNOME')

if icons:
  theme = Gtk.IconTheme.get_default()

menu = xdg.Menu.parse(menufile)

print '<?xml version="1.0" encoding="UTF-8"?>'
print '<openbox_pipe_menu>'
map(walk_menu, menu.getEntries())
print '</openbox_pipe_menu>'

Make sure you have gnome-menu installed and it should work fine. I am not the author of the script so cannot take any praise for it. ;)

Offline

#12 2012-02-16 22:07:40

donniezazen
Member
From: Salt Lake City
Registered: 2011-06-24
Posts: 671
Website

Re: [SOLVED] Openbox Application Menu

This is pretty close to what I get from XDG menu but automatic. I do not want the menu under a sub-entry like XDG or Application but as a main entry.

Thanks for posting the script and picture.

Offline

Board footer

Powered by FluxBB