Stirling-Tools / Stirling-PDF

#1 Locally hosted web application that allows you to perform various operations on PDF files
https://stirlingpdf.com
MIT License
46.88k stars 3.83k forks source link

Creating a appmenu shortcut with unix local installation #2081

Open rain-jpg opened 1 month ago

rain-jpg commented 1 month ago

Semicolons prevent the .desktop file from being displayed in the appmenu. When I edit the semicolons with kwrite from /usr/share/applications/stirling-pdf.desktop , the appmenu shortcut is displayed but does not work when I click on it.

location=$(pwd)/gradlew image=$(pwd)/docs/stirling-transparent.svg

cat > ~/.local/share/applications/Stirling-PDF.desktop <<EOF [Desktop Entry] Name=Stirling PDF; GenericName=Launch StirlingPDF and open its WebGUI; Category=Office; Exec=xdg-open http://localhost:8080 && nohup $location bootRun &; Icon=$image; Keywords=pdf; Type=Application; NoDisplay=false; Terminal=true; EOF

Frooodle commented 1 month ago

does not work when I click on it

Can you expand on this? Any error messages?

rain-jpg commented 1 month ago

I deleted the semicolons from the code to make the shortcut showing up in the appmenu (thats solves the creating a application menu shortcut) but when i click on it to launch the tool it shows a little terminal icon jumping near the cursor and nothing happens. I checked if the terminal running in the background and it wasn't there. Btw there was no browser launch when I'm running the app manually via terminal. I was copy pasting to the browser. Sorry there wasn't any error messages. Let me check on a fresh fedora install. I will be back.

MrYsLab commented 1 day ago

I ran into the same issue. Although it is not elegant, I have a workaround solution.

I created a shell script which is called by the .desktop file.

#!/bin/bash

# stirling_pdf.sh

java -jar /opt/Stirling-PDF/Stirling-PDF-*.jar &
j=$!
sleep 10
firefox --new-window http://localhost:8080 &
sleep 2

while true; do
    if /usr/bin/pgrep firefox >/dev/null; then
        continue
    else
        kill -9 $j
        exit
    fi
done

Here is the modified .desktop file.

[Desktop Entry]
Name=Stirling PDF
GenericName=Launch StirlingPDF and open its WebGUI
Category=Office
Exec=/home/afy/.local/bin/stirling_pdf.sh
Icon=/home/afy/.git/Stirling-PDF/docs/stirling-transparent.svg
Keywords=pdf
Type=Application
Terminal=true

The shell script allows 10 seconds to allow Stirling-pdf to up before starting the web browser. When you kill the browser, stirling-pdf is also killed. However, if you have more than one browser instance open, Stirling will not close until you close all browser instances.