From 190c7e0c417ce00d49aecf79f3bc276e335f4eac Mon Sep 17 00:00:00 2001 From: Dylan Whichard Date: Sat, 21 Sep 2024 15:47:53 -0700 Subject: [PATCH 1/4] Add Linux FreeDesktop file and install script --- .../workflows/build-firmware-and-emulator.yml | 10 ++++ emulator/resources/SwadgeEmulator.desktop | 11 ++++ emulator/resources/install.sh | 56 +++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 emulator/resources/SwadgeEmulator.desktop create mode 100755 emulator/resources/install.sh diff --git a/.github/workflows/build-firmware-and-emulator.yml b/.github/workflows/build-firmware-and-emulator.yml index 850739ef8..4f42db1a7 100644 --- a/.github/workflows/build-firmware-and-emulator.yml +++ b/.github/workflows/build-firmware-and-emulator.yml @@ -55,6 +55,9 @@ jobs: emu_artifacts: - swadge_emulator - version.txt + - install.sh + - icon.png + - SwadgeEmulator.desktop idf_install: ~/.espressif runs-on: ${{ matrix.runner }} @@ -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: | diff --git a/emulator/resources/SwadgeEmulator.desktop b/emulator/resources/SwadgeEmulator.desktop new file mode 100644 index 000000000..1a7481498 --- /dev/null +++ b/emulator/resources/SwadgeEmulator.desktop @@ -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; diff --git a/emulator/resources/install.sh b/emulator/resources/install.sh new file mode 100755 index 000000000..f047ac821 --- /dev/null +++ b/emulator/resources/install.sh @@ -0,0 +1,56 @@ +#!/bin/bash +set -e +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!" From 6bf11357a87b1773d47bf567c67a3b3ac8602037 Mon Sep 17 00:00:00 2001 From: Dylan Whichard Date: Sat, 21 Sep 2024 16:10:33 -0700 Subject: [PATCH 2/4] Add docs for Linux installation script --- docs/EMULATOR.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/EMULATOR.md b/docs/EMULATOR.md index 4657e5e96..2da1d5f5b 100644 --- a/docs/EMULATOR.md +++ b/docs/EMULATOR.md @@ -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 From 7bb3d6308db965e4df225322ee154ca78e675d1e Mon Sep 17 00:00:00 2001 From: Dylan Whichard Date: Sat, 21 Sep 2024 16:27:00 -0700 Subject: [PATCH 3/4] Include Linux in MIDI file opening docs --- docs/EMULATOR.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/EMULATOR.md b/docs/EMULATOR.md index 2da1d5f5b..db3c69cda 100644 --- a/docs/EMULATOR.md +++ b/docs/EMULATOR.md @@ -266,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 From 536a46a081fe66196b794746dd998edd07fa2b6f Mon Sep 17 00:00:00 2001 From: gelakinetic Date: Sun, 22 Sep 2024 10:50:46 +0000 Subject: [PATCH 4/4] Comment out echoing all script lines --- emulator/resources/install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/emulator/resources/install.sh b/emulator/resources/install.sh index f047ac821..cdbc336ea 100755 --- a/emulator/resources/install.sh +++ b/emulator/resources/install.sh @@ -1,6 +1,7 @@ #!/bin/bash set -e -set -x +# Uncomment this to print all script lines +# set -x if [ -e swadge_emulator ]; then BIN_SRC="swadge_emulator"