portfolio-performance / portfolio

Track and evaluate the performance of your investment portfolio across stocks, cryptocurrencies, and other assets.
http://www.portfolio-performance.info
Eclipse Public License 1.0
2.91k stars 600 forks source link

No icon in the dock on Ubuntu 20.04 using GNOME #1738

Closed bbatsov closed 2 months ago

bbatsov commented 4 years ago

I guess that's best illustrated with a screenshot of Ubuntu's app dock:

image

That iconless item is Portfolio Performance. I'm assuming that's because it doesn't ship a .desktop file. E.g. IB's TraderWorkstation (another Java app) has this file Trader Workstation.desktop:

#!/usr/bin/env xdg-open
[Desktop Entry]
Type=Application
Name=Trader Workstation
Exec="/home/bozhidar/Jts/tws" %U
Icon=/home/bozhidar/Jts/.install4j/tws.png
Categories=Application;
StartupWMClass=install4j-jclient-Launcher

I assume Portfolio Performance needs something similar.

Desktop (please complete the following information):

ohmer1 commented 3 years ago

This do the job for me:

[Desktop Entry]
Type=Application
Name=Portfolio Performance
Exec=/path/to/PortfolioPerformance/PortfolioPerformance
Icon=/path/to/PortfolioPerformance/icon.xpm
Categories=Application;
StartupWMClass=Portfolio Performance
vv01f commented 2 years ago

little script to generate the desktop file for a GNU/Linux with Debian-flavor, move it to the destination and with the option to remove the file as well.

usage

  1. put it in the PortfolioPerformance directory (right next to the binary and icon.xpm), make it executable
  2. run it in the terminal
  3. check for ${HOME}/.local/share/applications/ respectively /usr/share/applications/portfolio.desktop and the icon in your launcher/menu

install desktop file for single user

$ ./register-app.sh

install desktop file for all users

$ ./register-app.sh global

removing desktop file(s)

$ ./register-app.sh remove

Not all dependencies are checked. I guess some more things might be added/changed, feel free.

register-app.sh

gdir="/usr/share/applications/"
ddir=$(echo "${HOME}/.local/share/applications/")
fn="portfolio.desktop"
uname -a|grep -i linux >/dev/null || { echo "not a Linux, better verify the script manually."; exit 1; }
test ! -d "${ddir}" && {
    echo "directory not found: ${ddir} ."
    test ! -d "${gdir}" && {
        echo "global directory not found either: ${gdir} ."
        exit 1
    } || {
        echo "global directory found, changing destination directory to ${gdir} ."
        ddir="${gdir}"
        test "${1}" = "global" && shift
    }
}
#~ while $# -gt 1; do
    case ${1} in
        global)
            test ! -d "${gdir}" && { echo "local directory not found ${ldir} ."; exit 1; }
            echo "changing destination directory to ${gdir} ."
            ddir="${gdir}"
            ;;
        remove)
            test -f "${ddir}${fn}" && { echo "removing local desktop file."; sudo rm "${ddir}${fn}" ; } || { echo "local desktop file not found."; }
            test -f "${gdir}${fn}" && { echo "removing global desktop file."; sudo rm "${gdir}${fn}" ; } || { echo "global desktop file not found."; }
            test -f ./${fn} && { sudo rm ./${fn} ; }
            exit 0
            ;;
        #~ h)
        #~ help)
        *)
    esac
    #~ shift
#~ done
path=$(pwd)
icon=icon.xpm
test -f ${icon} && echo "icon file found." || { echo "icon file not found … this might hint you placed the executable in the wrong directory."; exit 1; }
test -f ${ddir}${fn} && { echo "desktop file already installed." ; exit 1; }
test -f ${fn} && echo "file already exists " || {
    echo "creating desktop file …"
    cat >${fn} <<EOF
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
StartupNotify=false
Exec="${path}/PortfolioPerformance"
Name=Portfolio Performance
GenericName=Personal finance
GenericName[de]=Persönliche Finanzen
Comment=Track your portfolio performance (finance)
Comment[de]=Portfolio verwalten und darstellen
Keywords=money;finances;stocks;shares;coin
Categories=Office;Finance;
Icon=${path}/${icon}
EOF
    sudo chmod 644 ./${fn}
    sudo chown root:root ./${fn}
    echo "installing desktop file …"
    sudo cp ./${fn} ${ddir}
}

Maybe someone can implement sth. like this in Java and add an option for it in the application itself, possibly also for other OSes. A suitable command line option could be --register-app as it is available for e.g. the tor browser bundle.