apeitheo / aletheia

Command-line media player with speed controls and voice feedback
GNU General Public License v3.0
3 stars 1 forks source link

.desktop files #5

Closed nater1983 closed 1 year ago

nater1983 commented 1 year ago

i would assume that the .desktop files should be installed in /usr/share/applications but they would also need to be renamed appropriately. Like aletheia.desktop that is if they are going to be used via the application menu.

apeitheo commented 1 year ago

Thanks for the feedback!

The latest commit should offer a better solution than I had previously. The reason it wasn't installed yet, and the reason that they were named as the terminals rather than 'aletheia.desktop' itself, was that I hadn't found a good solution to getting the launcher/icon correct with it named as such, and launching aletheia directly or indirectly.

Unfortunately, with aletheia being a command line application, it's not as simple as specifying the icon in the .desktop file and assuming it will show that icon everywhere in the DE. In GNOME, it correctly showed the launcher as aletheia.png, but upon clicking it, it showed a separate running icon in the dash, with a terminal icon instead of aletheia.png.

I had found a workaround by replacing xfce4-terminal's or gnome-terminal's .desktop file and specifying the icon that way, but it wasn't ideal as you had to dedicate that terminal to it, so I left it go for the time.

I've been working on a solution to this this afternoon and came up an aletheia.desktop file that defaults to GNOME/GNOME-Terminal, with commented out lines for XFCE/XFCE4-Terminal, and Konsole. For the other options, just copy the aletheia.desktop file to your local ~/.local/share/applications/ and edit the file to comment out the current Exec= line and uncomment the one you need.

I'm not entirely happy with this solution since it requires a little bit of legwork from the user for other DEs, but it offers another option and is now installed by default. Let me know if you find any issues or have any insights. Thanks again!

nater1983 commented 1 year ago

instead of running it threw a .desktop file why dont u script a script to look for either gnome-terminal or xfce-terminal or even konsole and let it load that way instead.

nater1983 commented 1 year ago

Something like this mite work but looking to see if the terminals are even installed and use it.

if [ -x /usr/libexec/gnome-terminal-server ]; then
echo "# Found Gnome Terminal" ; sleep 1
/bin/sh -c "/usr/libexec/gnome-terminal-server --app-id=org.gnome.aletheia --class=org.gnome.aletheia --name=org.gnome.aletheia >/dev/null 2>/dev/null & sleep 0.1; gnome-terminal --app-id=org.gnome.aletheia --hide-menubar --geometry=48x15 -- aletheia"
elif [ -x /usr/bin/xfce4-terminal]; then
echo "# Found XFCE4 Terminal" ; sleep 1
/bin/sh -c "/usr/bin/xfce4-terminal --command=aletheia --geometry 48x15 --icon=/usr/share/icons/aletheia.png"
elif [ -x /usr/bin/konsole ]; then
echo "# Found KDE Konsole" ; sleep 1
/bin/sh -c /usr/bin/konsole --hide-menubar --hide-tabbar --title "Aletheia" --icon /usr/share/icons/aletheia.png -e "aletheia"
else
echo "# Please Specify a terminal to run this program" ; sleep 1
fi
nater1983 commented 1 year ago

Perfect

On Mon, Jul 24, 2023 at 11:51 AM apeitheo @.***> wrote:

What do you think of the following? It provides an option to override with TERMINAL= in ~/.aletheia/config, but otherwise just checks for gnome-terminal, xfce4-terminal, or konsole in that order.

`#!/bin/bash This script launches aletheia with an available terminal. For use with aletheia.desktop file. To Override: Set TERMINAL= in ~/.aletheia/config to gnome-terminal, xfce4-terminal, or konsole

run_gnome_terminal() { /usr/libexec/gnome-terminal-server --app-id=org.gnome.aletheia --class=org.gnome.aletheia --name=org.gnome.aletheia >/dev/null 2>/dev/null & sleep 0.1 gnome-terminal --app-id=org.gnome.aletheia --hide-menubar --geometry=48x15 -- aletheia }

run_xfce4_terminal() { /usr/bin/xfce4-terminal --command=aletheia --geometry 48x15 --icon=/usr/share/icons/aletheia.png }

run_konsole_terminal() { /usr/bin/konsole --hide-menubar --hide-tabbar --title "Aletheia" --icon /usr/share/icons/aletheia.png -e "aletheia" } If no ~/.aletheia/config or no TERMINAL= override line, run what's available, starting with GNOME-Terminal

run_available() { if [ -x /usr/libexec/gnome-terminal-server ] && command -v gnome-terminal

/dev/null; then run_gnome_terminal elif (command -v /usr/bin/xfce4-terminal); then run_xfce4_terminal elif (command -v konsole); then run_konsole_terminal else if ( command -v zenity >/dev/null ); then zenity --info --text="No supported terminals available (i.e. GNOME-Terminal, XFCE4-Terminal, Konsole)." --ok-label="OK" 2>/dev/null fi exit 1 fi } Check if ~/.aletheia/config has a TERMINAL= override option

if [ -e "$HOME/.aletheia/config" ]; then choice="$(grep "TERMINAL=" "$HOME/.aletheia/config")" choice="${choice#*=}" choice="${choice//"/}" choice="${choice,,}" fi

if [ -n "$choice" ]; then if [ "$choice" == "gnome-terminal" ]; then run_gnome_terminal elif [ "$choice" == "xfce4-terminal" ]; then run_xfce4_terminal elif [ "$choice" == "konsole" ]; then run_konsole_terminal else run_available fi else run_available fi

exit 0`

— Reply to this email directly, view it on GitHub https://github.com/apeitheo/aletheia/issues/5#issuecomment-1648264436, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALBBAO3TNCWYHTGTCG4ZXT3XR2RXPANCNFSM6AAAAAA2UUIBOQ . You are receiving this because you authored the thread.Message ID: @.***>

-- Nathaniel & LeAnna Russell

apeitheo commented 1 year ago

What do you think of the following? It provides for a way to override in ~/.aletheia/config if you set TERMINAL= to one of the supported options (gnome-terminal, xfce4-terminal, or konsole), but otherwise just checks and runs gnome-terminal, xfce4-terminal, or konsole, in that order. GNOME-Terminal doesn't show the correct 'Aletheia' title though and --title doesn't work for whatever reason. Still working on it for now.

Thanks again for the feedback!

#!/bin/bash

# This script launches aletheia with an available terminal. For use with aletheia.desktop file.

# To Override:
# Set TERMINAL= in ~/.aletheia/config to gnome-terminal, xfce4-terminal, or konsole

run_gnome_terminal() {
    /usr/libexec/gnome-terminal-server --app-id=org.gnome.aletheia --class=org.gnome.aletheia --name=org.gnome.aletheia >/dev/null 2>/dev/null &
    sleep 0.1
    gnome-terminal --app-id=org.gnome.aletheia --hide-menubar --geometry=48x15 -- aletheia
}

run_xfce4_terminal() {
    /usr/bin/xfce4-terminal --command=aletheia --title=Aletheia --geometry 48x15 --icon=/usr/share/icons/aletheia.png
}

run_konsole_terminal() {
    /usr/bin/konsole --hide-menubar --hide-tabbar --title "Aletheia" --icon /usr/share/icons/aletheia.png -e "aletheia"
}

# If no ~/.aletheia/config or no TERMINAL= override line, run what's available, starting with GNOME-Terminal
run_available() {
    if [ -x /usr/libexec/gnome-terminal-server ] && command -v gnome-terminal > /dev/null; then
        run_gnome_terminal
    elif (command -v /usr/bin/xfce4-terminal); then
        run_xfce4_terminal
    elif (command -v konsole); then
        run_konsole_terminal
    else
        if ( command -v zenity >/dev/null ); then
            zenity --info --text="No supported terminals available (i.e. GNOME-Terminal, XFCE4-Terminal, Konsole)." --ok-label="OK" 2>/dev/null
        fi
        exit 1
    fi
}

# Check if ~/.aletheia/config has a TERMINAL= override option

if [ -e "$HOME/.aletheia/config" ]; then
    choice="$(grep "TERMINAL=" "$HOME/.aletheia/config")"
    choice="${choice#*=}"
    choice="${choice//\"/}"
    choice="${choice,,}"
fi

if [ -n "$choice" ]; then
    if [ "$choice" == "gnome-terminal" ]; then
        run_gnome_terminal
    elif [ "$choice" == "xfce4-terminal" ]; then
        run_xfce4_terminal
    elif [ "$choice" == "konsole" ]; then
        run_konsole_terminal
    else
        run_available
    fi
else
    run_available
fi

exit 0
apeitheo commented 1 year ago

I added support for a couple other terminals (gnome-terminal, xfce4-terminal, konsole, xterm, urxvt, alacritty, kitty, and mate-terminal). You can override with TERMINAL= to any one of those options, which may be necessary in some cases if the icon isn't showing up correctly in the dock, etc. Also aletheia.desktop, the icon, and the new aletheia_desktop_launcher script are all installed now via install scripts and for the packages as well.

Thanks for the suggestions!

Edit: I closed this to let people know the support is there now, but if there is any reason we need to re-open this, just let me know. Thanks again.