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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/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).

I'm currently available for hire, to help you plan, architect, and build new systems, and for technical writing and articles. You can take a look at some projects I've worked on and some of my writing. If you'd like to talk about your upcoming project, do get in touch.

More in the discussion (powered by webmentions)

  • (no mentions, yet.)