Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FreeDesktop config files for native support in graphical desktop environments #294

Merged
merged 4 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/build-firmware-and-emulator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ jobs:
emu_artifacts:
- swadge_emulator
- version.txt
- install.sh
- icon.png
- SwadgeEmulator.desktop
idf_install: ~/.espressif

runs-on: ${{ matrix.runner }}
Expand Down Expand Up @@ -169,6 +172,13 @@ jobs:
run: |
make SwadgeEmulator.app

- name: Create Linux FreeDesktop files
if: matrix.emulator && matrix.family == 'linux'
run: |
cp emulator/resources/install.sh .
cp emulator/resources/icon.png .
cp emulator/resources/SwadgeEmulator.desktop .

- name: Create Emulator zip
if: matrix.emulator && matrix.family != 'windows'
run: |
Expand Down
15 changes: 13 additions & 2 deletions docs/EMULATOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ wireless connection.

The Linux version of the emulator does not require any other software to operate. Simply extract the
`.zip` file anywhere you like and run the `swadge_emulator` program, either by opening it from your
file browser or by running `./swadge_emulator` from the command-line.
file browser or by running `./swadge_emulator` from the command-line. The Linux emulator includes a
script, `install.sh`, which can be run to install the Swadge Emulator as a desktop application, which
will allow you to open the emulator directly from many desktop environments, and to asssociate the
emulator with MIDI files using the "Open with..." option in your file browser. If you do not want these
features, there is no need to run the script. You will need to run this script again if you download a
new version of the emulator. By default, the installation script will install to `~/.local`, but you
can specify an alternate installation root such as `/usr/local` by passing it as an argument to
the `install.sh` script:

./install.sh /usr/local

### Mac

Expand Down Expand Up @@ -257,7 +266,9 @@ time.

MIDI Files (`.mid`, `.midi`, and `.kar`) can be played in directly by passing the name of
the MIDI file as a command-line argument to the Swadge Emulator. On Windows, you should also be able
to drag a MIDI file on top of `SwadgeEmulator.exe` to play it.
to drag a MIDI file on top of `SwadgeEmulator.exe` to play it. On Linux, you should be able to open
MIDI files with the emulator using your file browser's "Open with..." option after running the included
install script.

The Swadge Emulator includes MIDI support, which simulates the USB-MIDI behavior of the real Swadge
using the system MIDI implementation. Note that MIDI implementation and behavior will vary between
Expand Down
11 changes: 11 additions & 0 deletions emulator/resources/SwadgeEmulator.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Desktop Entry]
Name=Swadge Emulator
GenericName=Swadge Emulator
Comment=Emulate the MAGFest Swadge
Exec=$ROOT/bin/swadge_emulator %U
Terminal=false
Type=Application
StartupNotify=true
MimeType=audio/midi;audio/x-midi;
Icon=$ROOT/share/icons/SwadgeEmulator/icon.png
Categories=Game;Emulator;AudioVideo;Audio;Midi;Player;Development;
57 changes: 57 additions & 0 deletions emulator/resources/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
set -e
# Uncomment this to print all script lines
# set -x

if [ -e swadge_emulator ]; then
BIN_SRC="swadge_emulator"
elif [ -e ../../swadge_emulator ]; then
BIN_SRC="../../swadge_emulator"
else
echo "Error: install file 'swadge_emulator' not found! Are you running this script from the correct directory?"
exit 1
fi

if [ -e SwadgeEmulator.desktop ]; then
DESKTOP_SRC="SwadgeEmulator.desktop"
elif [ -e emulator/resources/SwadgeEmulator.desktop ]; then
DESKTOP_SRC="emulator/resources/SwadgeEmulator.desktop"
else
echo "Error: install file 'SwadgeEmulator.desktop' not found! Are you running this script from the correct directory?"
exit 1
fi

if [ -e icon.png ]; then
ICON_SRC="icon.png"
elif [ -e emulator/resources/icon.png ]; then
ICON_SRC="emulator/resources/icon.png"
else
echo "Error: install file 'ico.png' not found! Are you running this script from the correct directory?"
fi

INSTALL_DIR="${HOME}/.local"

if [ "$#" -gt "0" ]; then
INSTALL_DIR="${1}"
fi

echo "Installing the Swadge Emulator to: ${INSTALL_DIR}"

mkdir -p "${INSTALL_DIR}/bin" "${INSTALL_DIR}/share/icons/SwadgeEmulator" "${INSTALL_DIR}/share/applications"

cp "${BIN_SRC}" "${INSTALL_DIR}/bin/swadge_emulator"
cp "${ICON_SRC}" "${INSTALL_DIR}/share/icons/SwadgeEmulator/icon.png"
sed "s,\$ROOT,${INSTALL_DIR},g" "${DESKTOP_SRC}" > "${INSTALL_DIR}/share/applications/SwadgeEmulator.desktop"

if ! [[ ":$PATH:" == *":$INSTALL_DIR/bin:"* ]]; then
echo "WARNING: ${INSTALL_DIR}/bin is not in your PATH!"
echo " If you want to be able to start the Swadge Emulator from the command-line,"
echo " you can run this command to update your PATH for this session,"
echo " or add it to a file like ~/.bash_profile:"
echo
echo " export PATH=\"\$PATH:${INSTALL_DIR}/bin\""
echo
fi

echo
echo "Installation complete!"
Loading