Simon Tatham’s Portable Puzzle Collection Launcher
Simon Tatham has written a collection of little puzzles, which are very useful little things to play with when you’ve got five minutes to spare. However, installing the Debian package (sgt-puzzles) doesn’t add the little games to your Gnome menu. I could just add a submenu and loads of .desktop files, one for each app, but I couldn’t be bothered with that. So, a tiny PyGtk program to launch them. This will only work on Debian/Ubuntu because it looks for the dpkg .list file to build the list of packages!
/usr/local/bin/sgt-index:
#!/usr/bin/python
import gtk, sys, os
try:
fp = open("/var/lib/dpkg/info/sgt-puzzles.list")
except:
print "sgt-puzzles not installed!"
sys.exit()
games = [
os.path.split(x.strip())[1]
for x in fp if x.startswith('/usr/games/')
]
games.sort()
def startgame(event, gamename):
os.system("/usr/games/"+gamename+" &")
gtk.main_quit()
win = gtk.Window()
hbox = gtk.HBox()
vbox1 = gtk.VBox()
vbox2 = gtk.VBox()
win.add(hbox)
hbox.add(vbox1)
hbox.add(vbox2)
count = 0
for g in games:
count += 1
b = gtk.Button(g)
b.connect("clicked", startgame, g)
if count % 2 == 1:
vbox1.add(b)
else:
vbox2.add(b)
win.connect("destroy", gtk.main_quit)
win.show_all()
gtk.main()
Then just add an item to the menu (right-click the Applications and say Edit Menus).
Damn you, I’ve now become completely addicted to “Slant”. I think I deserve compensation :)
7 days later
Thank you.
“Obviously” /usr/local/bin/sgt-index needs to be made executable for this to work.
17 weeks later
Ian: thanks for the correction!
41 weeks later