New app icon, packaged with a menu entry for Linux
The icon is a plate wearing headphones with a red Nordic house cookie on it. It replaces the default Godot icon, so the game window, Windows and macOS builds use it. Linux programs can't carry their own icon, so the build now also makes MusicPlayer_<version>_linux.tar.gz with the game, the icon as a PNG, a .desktop menu entry and install.sh, which installs them for the current user. The bare Linux binary is still published.
This commit is contained in:
1 parent
29b11560b5
commit
10e9e7b2a4
10 files changed
+239
-6
No files matched your search
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
# Installs Music Player Randomizer for the current user, with an app menu entry and icon.
|
||||
# Run it from the unpacked release folder: ./install.sh
|
||||
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
bin_dir="${XDG_BIN_HOME:-$HOME/.local/bin}"
|
||||
data_dir="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||
binary="$bin_dir/music-player-randomizer"
|
||||
|
||||
icon_dir="$data_dir/icons/hicolor/256x256/apps"
|
||||
mkdir -p "$bin_dir" "$icon_dir" "$data_dir/applications"
|
||||
install -m755 MusicPlayer.x86_64 "$binary"
|
||||
install -m644 music-player-randomizer.png "$icon_dir/music-player-randomizer.png"
|
||||
# The menu entry needs the full path, since ~/.local/bin is not always on PATH
|
||||
sed "s|^Exec=.*|Exec=$binary|" music-player-randomizer.desktop \
|
||||
> "$data_dir/applications/music-player-randomizer.desktop"
|
||||
|
||||
# Refresh menu and icon caches where the tools exist; most desktops also notice on their own
|
||||
command -v update-desktop-database > /dev/null \
|
||||
&& update-desktop-database "$data_dir/applications" || true
|
||||
command -v gtk-update-icon-cache > /dev/null \
|
||||
&& gtk-update-icon-cache -q "$data_dir/icons/hicolor" || true
|
||||
|
||||
echo "Installed. Start it from your app menu, or run: $binary"
|
||||
echo "To uninstall, delete:"
|
||||
echo " $binary"
|
||||
echo " $data_dir/applications/music-player-randomizer.desktop"
|
||||
echo " $icon_dir/music-player-randomizer.png"
|
||||
@@ -0,0 +1,8 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Music Player Randomizer
|
||||
Comment=Guess the video game soundtrack with your friends
|
||||
Exec=music-player-randomizer
|
||||
Icon=music-player-randomizer
|
||||
Terminal=false
|
||||
Categories=Game;Audio;
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
# Packages an exported Linux build with its icon, app menu entry and install script.
|
||||
#
|
||||
# Usage: linux/package.sh <exported binary> <version> <output dir>
|
||||
# Creates <output dir>/MusicPlayer_<version>_linux.tar.gz. Godot is taken from $GODOT,
|
||||
# or `godot` on PATH, to render the icon.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 3 ]]; then
|
||||
echo "Usage: $0 <exported binary> <version> <output dir>" >&2
|
||||
exit 1
|
||||
fi
|
||||
binary="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
|
||||
version="$2"
|
||||
out_dir="$(mkdir -p "$3" && cd "$3" && pwd)"
|
||||
linux_dir="$(cd "$(dirname "$0")" && pwd)"
|
||||
project_dir="$(dirname "$linux_dir")"
|
||||
godot_bin="${GODOT:-godot}"
|
||||
|
||||
staging="$(mktemp -d)"
|
||||
trap 'rm -rf "$staging"' EXIT
|
||||
package_dir="$staging/MusicPlayer"
|
||||
mkdir -p "$package_dir"
|
||||
|
||||
install -m755 "$binary" "$package_dir/MusicPlayer.x86_64"
|
||||
install -m755 "$linux_dir/install.sh" "$package_dir/install.sh"
|
||||
install -m644 "$linux_dir/music-player-randomizer.desktop" "$package_dir/"
|
||||
# Run outside the project so Godot only renders the icon
|
||||
(cd "$staging" && "$godot_bin" --headless -s "$linux_dir/render_icon.gd" -- \
|
||||
"$project_dir/icon.svg" "$package_dir/music-player-randomizer.png" 256)
|
||||
|
||||
archive="$out_dir/MusicPlayer_${version}_linux.tar.gz"
|
||||
tar -czf "$archive" -C "$staging" MusicPlayer
|
||||
echo "Created $archive"
|
||||
@@ -0,0 +1,24 @@
|
||||
extends SceneTree
|
||||
## Renders an SVG to a square PNG, used to package the icon for Linux.
|
||||
##
|
||||
## Usage: godot --headless -s render_icon.gd -- <input.svg> <output.png> <size>
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
var args: PackedStringArray = OS.get_cmdline_user_args()
|
||||
if args.size() != 3:
|
||||
printerr("Usage: godot --headless -s render_icon.gd -- <input.svg> <output.png> <size>")
|
||||
quit(1)
|
||||
return
|
||||
var svg: String = FileAccess.get_file_as_string(args[0])
|
||||
var source: Image = Image.new()
|
||||
# Load at 1x to read the SVG's own size, then scale so the result is <size> pixels
|
||||
var error: int = source.load_svg_from_string(svg)
|
||||
if error == OK:
|
||||
var image: Image = Image.new()
|
||||
error = image.load_svg_from_string(svg, float(args[2]) / source.get_width())
|
||||
if error == OK:
|
||||
error = image.save_png(args[1])
|
||||
if error != OK:
|
||||
printerr("Could not render %s to %s (error %d)" % [args[0], args[1], error])
|
||||
quit(error)
|
||||
@@ -0,0 +1 @@
|
||||
uid://b51oybupn7ns7
|
||||
Reference in new issue
Block a user