I just discovered Desura’s Linux client and, given the opportunity to have a DRM-free package repository system for my Humble Bundle games, I jumped at the chance.
Of course, I still wanted to keep all my games together in one launcher menu, so I went looking for a way to give the manually installed things like Super Meat Boy proper icons. Luckily, Desura turned out to have a pretty simple approach to specifying icons. Just a couple of columns in an ordinary SQLite database.
Here’s a little Python script I wrote which, in theory, should let you set/change the icon on ANY game in your Linux Desura library. I’ve only tested it on local ones though.
#!/usr/bin/env python# -*- coding: utf-8 -*-"""Simple script to set icons on locally-installed games in Desura.
--snip--
Requirements:- Python 2.x- PyXDG (python-xdg in Ubuntu)
Usage:1. Place inside the desura folder2. Run `./set_icon.py GameName icon_name_or_path
Examples: ./set_icon.py DOSBox dosbox ./set_icon.py "Super Meat Boy" /usr/share/icons/supermeatboy/32.png"""
__appname__ = "Desura Game Icon Setter"__author__ = "Stephan Sokolow (deitarion/SSokolow)"__version__ = "0.1"__license__ = "MIT"
from urllib import pathname2urlimport os, sqlite3, sys
from xdg import IconTheme
DESURA_PATH = os.path.dirname(__file__)DB_PATH = os.path.join(DESURA_PATH, '.settings/iteminfo_c.sqlite')
if not os.path.isfile(DB_PATH): raise Exception("%s must be placed in the desura folder" % os.path.basename(__file__))
if __name__ == '__main__': from optparse import OptionParser parser = OptionParser(version="%%prog v%s" % __version__, usage="%prog <game title> <icon name or path>", description=__doc__.replace('\r\n','\n').split('\n--snip--\n')[0])
# Allow pre-formatted descriptions parser.formatter.format_description = lambda description: description opts, args = parser.parse_args()
if len(args) != 2: parser.print_help() sys.exit(1)
title, icon_name = args
iconpath = os.path.abspath(icon_name) if not os.path.isfile(iconpath): iconpath = IconTheme.getIconPath(icon_name) if not iconpath or not os.path.isfile(iconpath): print("Could not find icon: %s" % icon_name) sys.exit(2)
if iconpath.endswith('.svg') or iconpath.endswith('.xpm'): print("Unsupported icon format for Desura: %s" % iconpath) #TODO: At least support converting XPM automatically. sys.exit(2)
conn = sqlite3.connect(DB_PATH) conn.execute("UPDATE iteminfo SET iconurl=?, icon=? WHERE name=?", [ 'file://' + pathname2url(iconpath), os.path.relpath(iconpath, DESURA_PATH), title]) conn.commit()
