A SH script to generate .desktop
files for the
Ren'Py visual novel engine
(GitHub).
- Generate desktop files for your Ren'Py games
- Install the generated files or create them in the current directory
- Create a desktop file that searches for the most recent version for you (by default, when all versions are installed to the same directory)
- Rudimentary GUI and desktop file for drag and drop support (needs
zenity
) - Searches for icons automatically if none were given (and ability to download ones)
- Handles all that pesky (believe me) icon stuff for you while adhering to the specification (needs ImageMagick)
- Install for your user or system wide
- The game directory can be determined from many sources
To use the script clone this repository or download the latest release as a
tar.gz
or zip
archive. In case you downloaded a zip
you may have to make
the files renpy_desktop_generator.sh
, renpy_desktop_generator.desktop
and
make_absolute.sh
executable (e.g. with
chmod +x renpy_desktop_generator.sh
).
After that you can execute the file renpy_desktop_generator.sh
from your file
manager or the console.
If the script does not have the permissions to edit a file, it will try to
acquire them using sudo
.
You can provide the script with a direct path to the game start script (usually called NAME.sh), a path to your Ren'Py game's directory (as well as subdirectories), or an icon file.
The script will search for the game directory from these sources (in that order). If no argument is given, the current directory will be used.
To install the script you can add the directory to the PATH. Alternatively, you can create a link to the script in a directory that is already in the PATH with a name of your choosing.
$ sudo ln -s ./renpy_desktop_generator.sh /usr/local/bin/rdg
or if you have enabled local installations
$ ln -sr ./renpy_desktop_generator.sh ~/.local/bin/rdg
Due to the wonders of modern technology you can also drag and drop the game start script (usually called NAME.sh), the game directory or the game's icon file on the desktop file. When you drop multiple files onto the desktop file, the best matching location will be chosen.
The desktop file expects renpy_desktop_generator.sh
to be in the same
directory before make_absolute.sh
has been run.
The specification demands that the paths to scripts that should be executed are
absolute. Because of this file managers might refuse to execute it or assume
an incorrect current working directory.
If the desktop file does not work, try running make_absolute.sh
. Some file
managers assume their working directory (the directory from which they
were started) as relative location for renpy_desktop_generator.sh
. After
making the paths absolute, renpy_desktop_generator.sh
should not be moved to
a different location.
You may also want to install the desktop file to have access to its actions.
To do that see desktop-file-install
.
If you want to still use the terminal interface after you called the script,
e.g. because you don't want to install zenity
, you can set the Terminal
field in the desktop file to true
. Please keep in mind that the used terminal
may be not your default terminal or may even be hard-coded. The terminal might
also quit immediately because the script did not wait for user input.
Please note that this feature may is not supported by all file managers. Sometimes, activating running executable files will help. I made some tests and got the following results:
Name | Desktop Environment | Status |
---|---|---|
caja |
MATE (Mint) | ✔️ Works |
deepin-file-manger |
Deepin | ✔️ Works |
dolphin |
KDE | ➖ Works (only full path) |
liri-files |
Liri | ❌ Does not work. |
GNOME Files (nautilus ) |
GNOME (Ubuntu) | ❌ Does not work. (Maybe that's a bug?) |
nemo (nautilus fork) |
Cinnamon (Mint) | ✔️ Works |
thunar |
Xfce (Mint) | ✔️ Works |
xfe |
❌ Does not work. |
Some file managers also support starting the script directly. In this case you
should be asked for a starting point for the game directory search using
zenity
.
This script was written with GNU/BSD tools in mind. It will most likely not work in other environments. If you find a way to make it work, please contact me.
All of these should already be installed on a normal system.
/bin/sh basename cat cd command cp cut dirname eval exit file find grep head ln
id mkdir mkfifo mv printf read readlink return rm sed set shift sudo sort test
tr trap unset
⚠️ If you want to use the script without a terminal (e.g. running it from the file manager or desktop file), the GUI toolzenity
should be installed on your system. Otherwise, the script will silently log to the system log and choose some defaults that you may not want.
In the case that you cannot or don't want to do this you may want to setTerminal=true
inrenpy_desktop_generator.desktop
.- For the correct handling of icons either the ImageMagick suite or FFmpeg
must be installed. FFmpeg should be pre-installed on most systems
because it's a dependency of most browsers and media applications. If the
icon is not in
.png
format, some launchers might not support it.
If you have an Apple Icon Image format file,icns2png
must be installed.
At least one of these programs should be installed.
These are not required but add more features to the script:
Name | Purpose |
---|---|
base64 |
Used in current version search script (to escape escaping hell). |
curl /wget |
Download fallback icon. |
desktop-file-install |
Check and install the generated desktop file. |
env |
Used in current version search script. |
icns2png |
Handle the Apple Icon Image format correctly. |
logger |
Log to the system log. |
magick /ffmpeg |
Extract and convert icons to correct format. |
magick /ffprobe |
Identify icon (container) metadata. |
mktemp |
Ensure no naming conflicts for temporary files. |
uniq |
Used in current version search script. |
update-desktop-database |
Check the installed generated desktop file and make it findable. |
xargs |
Used in current version search script. |
zenity |
Create a rudimentary GUI. |
$PAGER /less |
Pager to display the help. |
The full documentation can be found in the
Wiki or by starting the script
with the --help
option. The desktop file also provides an action to display
the help but to access that you most likely have to install it.
Show all the options you have with -h
(--help
)
$ ./renpy_desktop_generator.sh -h
Force the use of the GUI with -g
(--gui
)
$ ./renpy_desktop_generator.sh ../../path/to/your/vn -g
Install without any prompts with version search support with -i
(--install
)
and -v
(--current-version-search
)
$ ./renpy_desktop_generator.sh ./TSR/game/gui/window_icon.png -iv
If the script cannot determine the name of the game correctly or the name is
not descriptive, you can use the -N
(--display-name
) option
$ ./renpy_desktop_generator.sh ./EchoRoute65.sh -N "Echo: Route 65"
Desktop files provide a keyword feature to add more meta data that can be used
for searches. You can add additional keywords by using the -k
(--keywords
)
option
$ ./renpy_desktop_generator.sh ./Arches.sh -k 'horror' 'echo' 'sequel'
By default, NAME will be added as a keyword so that the game can be found by
searching for it even if -N
was used.
This script was originally only to generate desktop files for the visual novel
PASSWORD by
Grizz. If you want to recreate the
original behaviour, you could do the following (-V
,
--no-current-version-search
)
$ cd ./path/to/your/password/installation
$ ./path/to/renpy_desktop_generator.sh -V
Make the script talk a lot (verbosity: ‘debug’). This is good if you want to
see the changes to your file system and what will be executed with sudo
with
-l
and -L
(--log-level
, --gui-log-level
)
$ ./renpy_desktop_generator.sh ../../path/to/your/vn -l 4 -L 4
If you want to avoid checking for optional dependencies and thus make the script
less verbose, you can either set CHECK_OPTIONAL_DEPENDENCIES=false
at the
start of the script or export RENPYDESKGEN_CHECK_OPTIONAL_DEPENDENCIES=false
beforehand.
This script is based on a script by 🐲Shin from the PASSWORD Discord server. This version can be found here.
Other versions can be found in the release section or in the commit history.