initial commit
This commit is contained in:
commit
6296539128
|
@ -0,0 +1,8 @@
|
|||
all: install
|
||||
|
||||
.PHONY: install
|
||||
|
||||
install:
|
||||
install -m 755 -o root -g root obamenu /usr/bin/obamenu
|
||||
install -d -m 755 -o root -g root /usr/share/doc/obamenu
|
||||
install -m 644 -o root -g root obamenu.txt /usr/share/doc/obamenu/doc
|
|
@ -0,0 +1,31 @@
|
|||
obamenu for Debian
|
||||
-----------------
|
||||
|
||||
obamenu (New version 1.1.7) is a free open source utility that automagically
|
||||
creates menus for openbox, an X window manager.
|
||||
|
||||
openbox does have built-in menu capabilities. Unfortunately, though, those
|
||||
menus must be created manually in openbox's menu.xml config file. While some
|
||||
users (and potential users!) find this generally cumbersome it is also
|
||||
unwieldy when installing new applications.
|
||||
|
||||
That's where obamenu enters the scene. obamenu automagically creates complete
|
||||
openbox menus based on looking at, analyzing, and working on xdg information
|
||||
provided by most applications. Being badass fast obamenu can be included as a
|
||||
dynamic item in menu.xml (example is in the docu) providing the user with an
|
||||
always up to date menu. In case you install a new application, simply have
|
||||
obox restart (which takes ~ 1 second) to find the new application right away
|
||||
in the menu.
|
||||
|
||||
While efforts were undertaken to keep obamenu small, resource friendly and
|
||||
fast (i.e. in line with the philosophy of small windows manager) it is
|
||||
actually quite capable and knows some tricks such as associating the proper
|
||||
icons with a menu entry.
|
||||
|
||||
Of course, obamenu does not interfere with any "hard wired" menu entries you
|
||||
might have made but rather complements them and nicely fits in, either in the
|
||||
root menu or in some sub menu like "Applications".
|
||||
|
||||
|
||||
-- ***REMOVED*** <fosslinux@tilde.team> Tue, 08 Jan 2019 13:37:54 +1100
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
obamenu (1.1.7-1) unstable; urgency=medium
|
||||
|
||||
* Upstream release 1.1.7
|
||||
* add debian packaging
|
||||
* add Makefile
|
||||
|
||||
-- ***REMOVED*** <fosslinux@tilde.team> Tue, 08 Jan 2019 13:37:54 +1100
|
|
@ -0,0 +1 @@
|
|||
11
|
|
@ -0,0 +1,36 @@
|
|||
Source: obamenu
|
||||
Section: x11
|
||||
Priority: optional
|
||||
Maintainer: TildeLinux Maintainers <tildelinux@tidleverse.org>
|
||||
Build-Depends: debhelper (>= 11)
|
||||
Standards-Version: 4.1.3
|
||||
Homepage: http://rmoe.anukis.de/obamenu.html
|
||||
|
||||
Package: obamenu
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, openbox
|
||||
Description: A utility that creates menus for openbox.
|
||||
obamenu (New version 1.1.7) is a free open source utility that automagically
|
||||
creates menus for openbox, an X window manager.
|
||||
.
|
||||
openbox does have built-in menu capabilities. Unfortunately, though, those
|
||||
menus must be created manually in openbox's menu.xml config file. While some
|
||||
users (and potential users!) find this generally cumbersome it is also
|
||||
unwieldy when installing new applications.
|
||||
.
|
||||
That's where obamenu enters the scene. obamenu automagically creates complete
|
||||
openbox menus based on looking at, analyzing, and working on xdg information
|
||||
provided by most applications. Being badass fast obamenu can be included as a
|
||||
dynamic item in menu.xml (example is in the docu) providing the user with an
|
||||
always up to date menu. In case you install a new application, simply have
|
||||
obox restart (which takes ~ 1 second) to find the new application right away
|
||||
in the menu.
|
||||
.
|
||||
While efforts were undertaken to keep obamenu small, resource friendly and
|
||||
fast (i.e. in line with the philosophy of small windows manager) it is
|
||||
actually quite capable and knows some tricks such as associating the proper
|
||||
icons with a menu entry.
|
||||
.
|
||||
Of course, obamenu does not interfere with any "hard wired" menu entries you
|
||||
might have made but rather complements them and nicely fits in, either in the
|
||||
root menu or in some sub menu like "Applications".
|
|
@ -0,0 +1,36 @@
|
|||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: obamenu
|
||||
Source: <url://example.com>
|
||||
|
||||
Files: *
|
||||
Copyright: 2018 rmoe <rmoe.anukis.de>
|
||||
License: GPL-2+
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Files: debian/* Makefile
|
||||
Copyright: 2019 TildeLinux Maintainers <tildelinux@tildeverse.org>
|
||||
License: GPL-3+
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
@ -0,0 +1 @@
|
|||
README.source
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/make -f
|
||||
# See debhelper(7) (uncomment to enable)
|
||||
# output every command that modifies files on the build system.
|
||||
#export DH_VERBOSE = 1
|
||||
|
||||
|
||||
# see FEATURE AREAS in dpkg-buildflags(1)
|
||||
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
|
||||
|
||||
# see ENVIRONMENT in dpkg-buildflags(1)
|
||||
# package maintainers to append CFLAGS
|
||||
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
|
||||
# package maintainers to append LDFLAGS
|
||||
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
|
||||
|
||||
|
||||
%:
|
||||
dh $@
|
||||
|
||||
|
||||
# dh_make generated override targets
|
||||
# This is example for Cmake (See https://bugs.debian.org/641051 )
|
||||
#override_dh_auto_configure:
|
||||
# dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
|
||||
|
|
@ -0,0 +1 @@
|
|||
3.0 (quilt)
|
|
@ -0,0 +1,210 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Version 1.1.7
|
||||
# ---- config ---
|
||||
applications_dirs = ("/usr/share/applications", )
|
||||
image_dir_base = "/usr/share" # without "pixmaps" -/usr/local/share in FreeBSD, /usr/share on linux
|
||||
icon_Theme = "Humanity"
|
||||
image_cat_prefix = "applications-" # if empty will create no icon text only menu
|
||||
application_groups = ("Office", "Development", "Graphics", "Internet", "Games", "System", "Multimedia", "Utilities", "Settings")
|
||||
group_aliases = {"Audio":"Multimedia","AudioVideo":"Multimedia","Network":"Internet","Game":"Games", "Utility":"Utilities", "GTK":"", "GNOME":""}
|
||||
ignoreList = ("evince-previewer", "Ted", "wingide3.2", "python3.4", "feh","xfce4-power-manager-settings" )
|
||||
terminal_string = "evte -e" # your favourites terminal exec string
|
||||
simpleOBheader = False # print full xml style OB header
|
||||
# --- End of user config ---
|
||||
|
||||
import glob
|
||||
|
||||
class dtItem(object):
|
||||
def __init__(self, fName):
|
||||
self.fileName = fName
|
||||
self.Name = ""
|
||||
self.Comment = ""
|
||||
self.Exec = ""
|
||||
self.Terminal = None
|
||||
self.Type = ""
|
||||
self.Icon = ""
|
||||
self.Categories = ()
|
||||
|
||||
def addName(self, data):
|
||||
self.Name = xescape(data)
|
||||
|
||||
def addComment(self, data):
|
||||
self.Comment = data
|
||||
|
||||
def addExec(self, data):
|
||||
if len(data) > 3 and data[-2] == '%': # get rid of filemanager arguments in dt files
|
||||
data = data[:-2].strip()
|
||||
self.Exec = data
|
||||
|
||||
def addIcon(self, data):
|
||||
self.Icon = ""
|
||||
if image_cat_prefix == "":
|
||||
return
|
||||
image_dir = image_dir_base + "/pixmaps/"
|
||||
di = data.strip()
|
||||
if len(di) < 3:
|
||||
#"Error in %s: Invalid or no icon '%s'" % (self.fileName, di)
|
||||
return
|
||||
dix = di.find("/") # is it a full path?
|
||||
if dix >= 0 and dix <= 2: # yes, its a path (./path or ../path or /path ...)
|
||||
self.Icon = di
|
||||
return
|
||||
#else a short name like "myapp"
|
||||
tmp = image_dir + di + ".*"
|
||||
tmp = glob.glob(tmp)
|
||||
if len(tmp) > 0:
|
||||
self.Icon = tmp[0]
|
||||
return
|
||||
|
||||
def addTerminal(self, data):
|
||||
if data == "True" or data == "true":
|
||||
self.Terminal = True
|
||||
else:
|
||||
self.Terminal = False
|
||||
|
||||
def addType(self, data):
|
||||
self.Type = data
|
||||
|
||||
def addCategories(self, data):
|
||||
self.Categories = data
|
||||
|
||||
def getCatIcon(cat):
|
||||
iconDir = image_dir_base + "/icons/" + icon_Theme + "/categories/24/"
|
||||
cat = image_cat_prefix + cat.lower()
|
||||
tmp = glob.glob(iconDir + cat + ".*")
|
||||
if len(tmp) > 0:
|
||||
return tmp[0]
|
||||
return ""
|
||||
|
||||
def xescape(s):
|
||||
Rep = {"&":"&", "<":"<", ">":">", "'":"'", "\"":"""}
|
||||
for p in ("&", "<", ">", "'","\""):
|
||||
sl = len(s); last = -1
|
||||
while last < sl:
|
||||
i = s.find(p, last+1)
|
||||
if i < 0:
|
||||
done = True
|
||||
break
|
||||
last = i
|
||||
l = s[:i]
|
||||
r = s[i+1:]
|
||||
s = l + Rep[p] + r
|
||||
return s
|
||||
|
||||
def process_category(cat, curCats, appGroups = application_groups, aliases = group_aliases ):
|
||||
# first process aliases
|
||||
if aliases.has_key(cat):
|
||||
if aliases[cat] == "":
|
||||
return "" # ignore this one
|
||||
cat = aliases[cat]
|
||||
if cat in appGroups and cat not in curCats: # valid categories only and no doublettes, please
|
||||
curCats.append(cat)
|
||||
return cat
|
||||
return ""
|
||||
|
||||
|
||||
def process_dtfile(dtf, catDict): # process this file & extract relevant info
|
||||
active = False # parse only after "[Desktop Entry]" line
|
||||
fh = open(dtf, "r")
|
||||
lines = fh.readlines()
|
||||
this = dtItem(dtf)
|
||||
for l in lines:
|
||||
l = l.strip()
|
||||
if l == "[Desktop Entry]":
|
||||
active = True
|
||||
continue
|
||||
if active == False: # we don't care about licenses or other comments
|
||||
continue
|
||||
if l == None or len(l) < 1 or l[0] == '#':
|
||||
continue
|
||||
if l[0]== '[' and l != "[Desktop Entry]":
|
||||
active = False
|
||||
continue
|
||||
# else
|
||||
eqi = l.split('=')
|
||||
if len(eqi) < 2:
|
||||
print "Error: Invalid .desktop line'" + l + "'"
|
||||
continue
|
||||
# Check what it is ...
|
||||
if eqi[0] == "Name":
|
||||
this.addName(eqi[1])
|
||||
elif eqi[0] == "Comment":
|
||||
this.addComment(eqi[1])
|
||||
elif eqi[0] == "Exec":
|
||||
this.addExec(eqi[1])
|
||||
elif eqi[0] == "Icon":
|
||||
this.addIcon(eqi[1])
|
||||
elif eqi[0] == "Terminal":
|
||||
this.addTerminal(eqi[1])
|
||||
elif eqi[0] == "Type":
|
||||
if eqi[1] != "Application":
|
||||
continue
|
||||
this.addType(eqi[1])
|
||||
elif eqi[0] == "Categories":
|
||||
if eqi[1][-1] == ';':
|
||||
eqi[1] = eqi[1][0:-1]
|
||||
cats = []
|
||||
# DEBUG
|
||||
dtCats = eqi[1].split(';')
|
||||
for cat in dtCats:
|
||||
result = process_category(cat, cats)
|
||||
this.addCategories(cats)
|
||||
else:
|
||||
continue
|
||||
# add to catDict
|
||||
#this.dprint()
|
||||
if len(this.Categories) > 0: # don't care about stuff w/o category
|
||||
for cat in this.Categories:
|
||||
catDict[cat].append(this)
|
||||
|
||||
categoryDict = {}
|
||||
|
||||
if __name__ == "__main__":
|
||||
# init the application group dict (which will contain list of apps)
|
||||
for appGroup in application_groups:
|
||||
categoryDict[appGroup] = []
|
||||
|
||||
# now let's look into the app dirs ...
|
||||
for appDir in applications_dirs:
|
||||
appDir += "/*.desktop"
|
||||
dtFiles = glob.glob(appDir)
|
||||
|
||||
# process each .desktop file in dir
|
||||
for dtf in dtFiles:
|
||||
skipFlag = False
|
||||
for ifn in ignoreList:
|
||||
if dtf.find(ifn) >= 0:
|
||||
skipFlag = True
|
||||
if skipFlag == False:
|
||||
process_dtfile(dtf, categoryDict)
|
||||
|
||||
# now, generate jwm menu include
|
||||
if simpleOBheader == True:
|
||||
print '<openbox_pipe_menu>' # magic header
|
||||
else:
|
||||
print '<?xml version="1.0" encoding="UTF-8" ?><openbox_pipe_menu xmlns="http://openbox.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://openbox.org/" >' # magic header
|
||||
appGroupLen = len(application_groups)
|
||||
for ag in range(appGroupLen ):
|
||||
catList = categoryDict[application_groups[ag]]
|
||||
if len(catList) < 1:
|
||||
continue # don't create empty menus
|
||||
catStr = "<menu id=\"openbox-%s\" label=\"%s\" " % (application_groups[ag], application_groups[ag])
|
||||
tmp = getCatIcon(application_groups[ag])
|
||||
if tmp != "":
|
||||
catStr += "icon=\"%s\"" % tmp
|
||||
print catStr, ">"
|
||||
for app in catList:
|
||||
progStr = "<item "
|
||||
progStr += "label=\"%s\" " % app.Name
|
||||
if app.Icon != "":
|
||||
progStr += "icon=\"%s\" " % app.Icon
|
||||
progStr += "><action name=\"Execute\"><command><![CDATA["
|
||||
if app.Terminal == True:
|
||||
progStr += terminal_string + " "
|
||||
progStr += "%s]]></command></action></item>" % app.Exec
|
||||
print progStr
|
||||
print "</menu>"
|
||||
print "</openbox_pipe_menu>" # magic footer
|
||||
pass # done/debug break
|
|
@ -0,0 +1,101 @@
|
|||
obamenu
|
||||
|
||||
(news and updates can be found at the bottom)
|
||||
|
||||
obamenu (openbox automenu) is a menu generator for the openbox window manager. Rather than striving for full and complete xdg compliance
|
||||
obamenu offers a reasonable basic level of xdg compliance and focuses on low resource usage and pragmatic issues.
|
||||
|
||||
obamenu consists of a single python file without any exotic imports. It has been developed with Python 2.7 should, however, work fine with
|
||||
any Python > 2.5 (possibly even older) and with Python's standard included batteries.
|
||||
|
||||
Usage:
|
||||
|
||||
obamenu
|
||||
|
||||
That's it. No options, no parameters, simple as that. But ...
|
||||
|
||||
As openbox users are not afraid of editing config files, a decision was taken to make obamenu's configuration powerful yet simple not by
|
||||
command line üarameters or a config file but by having a short config section right within obamenu itself.
|
||||
|
||||
The basic idea
|
||||
|
||||
It seems reasonable to assume that openbox users are quite different from users of the more common and usually monstrous window managers.
|
||||
And while obamenu is perfectly capable to just splash the usual full menu into your .jwmrc the authors needs (and assumptions on other
|
||||
openbox users needs) and accordingly obamenu's capabilities are somewhat more refined.
|
||||
|
||||
First some basics. On pretty much any halfway modern Unixoid OS, there is some directory with ".desktop" files which contain information
|
||||
about applications needed by the OS; things like its name, the command, possibly some comment, and so on. On most linuxes and BSD
|
||||
this directory is "/usr/share/applications". Of course, as with every standard, there's some idio^H^H^H^H players (like Gnome) who don't
|
||||
care that much and dump their .desktop files elsewhere and anywhere.
|
||||
Similarly there is also a place for all those nice application (not OS!) icons. Usually they are in "/usr/share/pixmaps".
|
||||
Last but not least, there are "Categories" into which applications are grouped in menus. Btw, obamenu does not show empty categories to
|
||||
avoid senseless clutter.
|
||||
|
||||
So, let's have a look at a obamenu's config section and its bits and pieces:
|
||||
|
||||
# ---- config ---
|
||||
applications_dirs = ("/usr/share/applications", )
|
||||
image_dir = "/usr/share/pixmaps"
|
||||
application_groups = ("Office", "Development", "Graphics", "Internet", "Games", "System", "Multimedia", "Utility", "Settings")
|
||||
group_aliases = {"Audio":"Multimedia","AudioVideo":"Multimedia","Game":"Games", "GTK":""}
|
||||
ignoreList = ("evince-previewer", "python3.4", "feh","xfce4-power-manager-settings" )
|
||||
terminal_string = "svte -e" # your favourites terminal exec string
|
||||
# --- End of user config ---
|
||||
|
||||
The first one, "applications_dirs" is a list of directories in which .desktop files are to be found. The default, which should be fine for most
|
||||
users, is where .desktop files are usually put by linux or BSD. Feel free to add more, for instance some subdirectory within your $HOME.
|
||||
The next one, "image_dir", is quite similar but is about icon images for applications. A small caveat, though: While most applications are
|
||||
nicely putting their .desktop files into the standard directory, the story with icons is quite different. Particularly the wm behemoths like
|
||||
Gnome tend to spread icon files all over the place. Often, for instance, icon files are to be found in some obscure subdirectory of
|
||||
"/usr/share/icons" buried deep depending in the chosen theme and the icon size. The author of obamenu admits freely to have taken a
|
||||
rather deliberate choice in that regard by having image_dir be a simple string rather than a list, which might seem to be a reasonable way
|
||||
to some. The author, however, didn't consider it wise to play find and catch with ignorance and idiosyncrasies of some parties. He rather
|
||||
chose to use the trusted Unix mechanism of links. In other words: You are advised to soft link all icon files outside the standard icon directory
|
||||
to /usr/share/pixmaps or similar. ("find" is your friend, e.g. find /usr/share/icons -name 'foo.*').
|
||||
|
||||
The next setting, "application_groups" looks innocent enough but has some power with it. Obviously the entries in that list are "menu
|
||||
groups" or categories into which xdg menus put the applications depending on some .desktop data. You might want to keep in mind
|
||||
that obamenu keeps categories in the the order of this setting, i.e. you will find those categories in the menu in that order, too.
|
||||
And then there are buts ...
|
||||
The first but is that you almost certaintly don't want more categories than the number of citizens in your home town. Another and more
|
||||
interesting but is that, obviously, usage profiles are different. For me as a developer, for instance, a "shows coloured stuff or makes sound"
|
||||
category seems sensibly sufficient; some movie editing people though might have quite different views... which brings us to the next
|
||||
setting.
|
||||
"group_aliases" is a list of string pairs, the first one being what is put as category in the .desktop file(s) and the second one being the
|
||||
category it will end up in. In other words: this is your chance to rearrange things the way you want them. The author, for instance, has a
|
||||
rather frugal attitude regarding multimedia; accordingly, he simply throws anything audio or video related into one category "multimedia".
|
||||
To illustrate, though admittedly somewhat construed, another potentially useful feature, have a look at "GTK" in those string pairs. Its second
|
||||
string is empty which comes down to telling obamenu "ignore that stuff. Don't put it into my menu". The reason being that openbox *only*
|
||||
creates menus for applications being sorted into a category. No category, no menu entry.
|
||||
Hint: This setting may also be used to have translated strings in your menu; simply have the english cat. string aliased to a translated version.
|
||||
|
||||
The second to last setting, "ignoreList" is what its name suggests. It's a list of .desktop file names (without the ".desktop" part) you wish to
|
||||
ignore, i.e. to not have in your menu for whatever reason.
|
||||
Finally the last setting, "terminal_string", is telling obamenu how to call your favourite terminal emulator for console applications like "htop".
|
||||
(obamenu automagically takes care of having console applications called in a terminal emulator).
|
||||
|
||||
Note that the auto-generated menu can be put right into the menu section of an openbox menu.xml
|
||||
Last but not least you can, of course, also send obamenu's output to a file which can be edited, inserted manually, feed your cat, and all
|
||||
the other things Unixoids can do with files.
|
||||
|
||||
Just to avoid misunderstandings, here's an example (the authors usage) of obamenu in a ob menu.xml file:
|
||||
|
||||
<menu id="desktop-app-menu" label="Applications" icon="/usr/share/icons/applications.png" execute="~/obamenu" />
|
||||
|
||||
|
||||
License:
|
||||
obamenu is under a dual license depending on who you are. If you are using it as a private person (which also means non-commercially)
|
||||
it's under a 3 clause BSD license. If you are using it as or in the context of anything not private, for instance, in a business or an agency,
|
||||
it's under GPL v.2.
|
||||
|
||||
Disclaimer: The author uses mainly jwm. While obamenu has been tested to work properly it has been considerably less tested than the authors
|
||||
jwmamenu (same thing but for jwm. In fact, obamenu has been derived from jwmamenu).
|
||||
|
||||
The main motivation behind obamenu was the fact that openbox-menu (probably the most used menu generator for ob) doesn't compile properly on FreeBSD
|
||||
and the author saw absolutely no reason why a menu generator couldn't - and shouldn't - be cross platform (e.g. using Python).
|
||||
|
||||
News & Updates:
|
||||
|
||||
- ported (from jwmamenu) smarts to get rid of '%x' target specifiers in Exec spec. (used for file managers but disturbing in menus)
|
||||
- ported search for category icons in configurable Theme
|
||||
- some cleaning up and small enhancements, mainly for speed.
|
Loading…
Reference in New Issue