Skip to content

Instantly share code, notes, and snippets.

@nocturnaltortoise
Created January 7, 2016 18:59
Show Gist options
  • Save nocturnaltortoise/b95d034cd5b9dacd772c to your computer and use it in GitHub Desktop.
Save nocturnaltortoise/b95d034cd5b9dacd772c to your computer and use it in GitHub Desktop.
A simple python script to write .desktop files.
app_name = input("Application Name: ")
comment = input("Tooltip: ")
generic_name = input("Generic Name: ")
exec_name = input("Path to exec: ")
icon = input("Path to icon: ")
app_type = "Application"
categories = []
more_categories = True
while(more_categories):
more_categories_input = input("Add more categories? y/n")
if(more_categories_input != "y"):
more_categories = False
new_category = input("Category: ")
categories.append(new_category + ";")
print(app_name, comment, generic_name, exec_name, icon, app_type, categories)
file_name = app_name + ".desktop"
with open(file_name, "w") as file:
file.write("[Desktop Entry]\n")
file.write("Name=" + app_name + "\n")
file.write("Comment=" + comment + "\n")
file.write("GenericName=" + generic_name + "\n")
file.write("Exec=" + exec_name + "\n")
file.write("Icon=" + icon + "\n")
file.write("Type=" + app_type + "\n")
file.write("Categories=")
file.writelines(categories)
#TODO: add more parts of the .desktop spec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment