Hi Al, list,

Attached are patches to allow a line in the .auxlaunchrc file to
reference an <app>.desktop file, so that auxlaunch can get the
information that it needs from that file.  I find this useful, but I'm
curious what others may think, so please let me know.  Al, if you'd
like to incorporate this in the official auxlaunch, please feel free.

Regards,
         Neil
From 1d30d6ee0486b8e37329682c333a45366f1cdf37 Mon Sep 17 00:00:00 2001
From: Neil Jerram <neiljer...@googlemail.com>
Date: Tue, 29 Dec 2009 23:24:12 +0000
Subject: [PATCH 1/2] Prepare place to add code for processing a desktop reference

---
 auxlaunch |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/auxlaunch b/auxlaunch
index 80ac74b..01cda73 100755
--- a/auxlaunch
+++ b/auxlaunch
@@ -439,14 +439,21 @@ class ModelManager:
 			elif field[0][0].upper() == '-':	# Window title filter record
 				self.winDiscard.append(field[0][1:])
 			else:							# Item record
+			    	if field[0][0].upper() == '+': # .desktop ref
+					deskname = field[0][1:]
+			    	else:
+					label = field[0]
+					command = field[1]
+					iconname = field[2]
+
 				image = gtk.Image()
-				if field[2].rstrip() == '':
+				if iconname.rstrip() == '':
 					image.set_from_stock('gtk-execute', gtk.ICON_SIZE_DIALOG)
-				elif field[2][:4] == 'gtk-':
-					image.set_from_stock(field[2], gtk.ICON_SIZE_DIALOG)
+				elif iconname[:4] == 'gtk-':
+					image.set_from_stock(iconname, gtk.ICON_SIZE_DIALOG)
 				else:
-					image.set_from_file(field[2])
-				app = AppItem(image,field[0],field[1])
+					image.set_from_file(iconname)
+				app = AppItem(image,label,command)
 				curApps.append(app)
 
		# Flush last holding value		
 		if not (curGroup == INITGROUP and len(curApps) == 0):
-- 
1.6.5.7

From 331aa180f3e4cd8c38d1d839b187a253f06dfa1c Mon Sep 17 00:00:00 2001
From: Neil Jerram <neiljer...@googlemail.com>
Date: Fri, 1 Jan 2010 23:30:26 +0000
Subject: [PATCH 2/2] Implement .desktop file references

The idea of this is that many applications already ship with a .desktop
file, which contains the application's preferred name and icon, and the
command to use to launch it.  This patch makes auxlaunch interpret
"+<application>" as a reference to /usr/share/applications/<application>.desktop,
which means that it reads the .desktop file and extracts the name, icon and
command from that file.

"But the Debian menu system and -dms option already covers that!"  Yes, but
unfortunately the -dms option produces so many entries, in so many categories,
that I find it quite difficult to navigate the categories and select the
program that I want.  So now I'm preferring not to use -dms, and instead to
define groups that make sense to me for the programs that I want, using these
desktop references.

Finally, a caveat: the icon part doesn't work yet.
---
 auxlaunch |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/auxlaunch b/auxlaunch
index 01cda73..b576f17 100755
--- a/auxlaunch
+++ b/auxlaunch
@@ -440,7 +440,22 @@ class ModelManager:
 				self.winDiscard.append(field[0][1:])
 			else:							# Item record
 			    	if field[0][0].upper() == '+': # .desktop ref
-					deskname = field[0][1:]
+					deskname = field[0][1:].rstrip()
+					deskfile = open('/usr/share/applications/' + deskname + '.desktop')
+					label = None
+					command = None
+					iconname = None
+					for dline in deskfile:
+						field = dline.split('=')
+						if field[0] == 'Name':
+							label = field[1].rstrip()
+						elif field[0] == 'Exec':
+							command = field[1].rstrip()
+						elif field[0] == 'Icon':
+							iconname = field[1].rstrip()
+					deskfile.close()
+					if (label is None) or (command is None):  continue
+					if (iconname is None):  iconname = 'gtk-redo'
 			    	else:
 					label = field[0]
 					command = field[1]
-- 
1.6.5.7

_______________________________________________
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community

Reply via email to