def _desktop_escape(s):
    """Escape a filepath for use in a .desktop file"""
    escapes = {' ': R'\s', '\n': R'\n', '\t': R'\t', '\\': R'\\'}
    s = str(s)
    for unescaped, escaped in escapes.items():
        s = s.replace(unescaped, escaped)
    return s