将自定义应用程序添加到GNOME启动器


69

寻找一种实用程序,使我可以将项目插入GNOME知道的应用程序列表中。

例如:
我已经下载了Eclipse EE(我有一些需要使用的非常特殊的插件,而这些插件“不喜欢”默认存储库中的可用版本)。我在Ubuntu 11.10上使用GNOME 3。因此,我想执行Eclipse,而无需打开终端并运行它。

它一定很简单。


png图像不起作用,请尝试jpg

Answers:


67

您可以为此使用主菜单。如果没有,请先安装:

sudo apt-get install alacarte

1.打开主菜单

2.参见示例

主菜单

之后,您可以使用名称“ command_of_application”来调用应用程序。

编辑:我想念您曾要求您的主目录中的应用程序。如果是这样,则命令必须是该应用程序的完整路径。


这就是我想要的。
Shaftoe2702

在德语Ubuntu 17.10中,搜索“Menüberabeitung”
Christopher

谢谢,幸运的是,这个软件包也包含在fedora中。
Sukumaar '18

60

Gnome知道的应用程序启动器是/usr/share/applications和中的.desktop文件~/.local/share/applications。您可以通过手动创建和编辑自定义.desktop文件,或使用旧的Gnome菜单编辑器Alacarte,为主文件夹中的任何内容创建自定义启动器。

Gnome桌面文件文档可能会有所帮助:https : //developer.gnome.org/integration-guide/stable/desktop-files.html.en

自定义启动器只是一个文本文件,例如,名为EclipseEE.desktop,具有以下内容:

[Desktop Entry]
Name=Eclipse EE
Exec=/home/mrPeterson/path_to_executable
StartupNotify=true
Terminal=false
Type=Application
Icon=/optional/path/to/icon.png

第一条链接断开了
nispio

9

(从原始OP重新发布)

这是在其他地方指出的巧妙技巧:

gnome-desktop-item-edit ~/Desktop/ --create-new

现在,我有一个图标。绑定到上下文菜单是一个很好的功能,但是,我看不到它。


我默认未安装该程序;必须做的sudo apt-get install --no-install-recommends gnome-panel
yuikonnu

5

我喜欢Jorge的简单gnome-desktop-item-edit解决方案。但是,如果我将.desktop文件放在~/Desktop/上面,它不会显示为应用程序,而只会显示为gnome菜单中的文件。所以我做:

sudo gnome-desktop-item-edit /usr/share/applications/ --create-new

但是,要为所有gnome用户创建菜单,您应该将其放置在~/.local/share/applications文件夹中,并避免使用sudo
RousseauAlexandre

1

我知道这个线程有点旧,但是我想与大家分享我刚刚做的bash函数,因为...因为我可以。如果您发现它有用,请随时使用!

警告:我刚刚做到了。这可能并不完美。

new-gnome-launcher-app(){
    # This functions adds some executable file to the gnome launcher.
    # It does the following:
    #   - Add symlink to /usr/bin
    #   - Add entry for gnome launcher

    # TODO: Check image file extension

    # Check if root
    # if [ "$(id -u)" != "0" ]; then 
    #   echo "Must run as root"
    #   return 1
    # fi

    # If parameter is entered, assume it's the executable's directory.
    # Else, ask for it
    if [ "$?" -gt "1" ]; then
        exec_path="$1"
    else
        echo -n "Enter executable file name: "
        read exec_path
    fi
    # Check if file exists
    if [ ! -f "$exec_path" ] || [ ! -f "$(pwd)/$exec_path" ]; then
        echo "File doesn't exist"
        unset exec_path
        return 1
    fi
    # Get absolute path to file
    if [ "${exec_path:0:1}" != "/" ]; then
        echo "'$exec_path' was not an absolute path"
        exec_path="$(pwd)/$exec_path"
        echo "Assuming path '$exec_path'"
    fi
    exec_basename="$(basename "$exec_path")"
    # Check if symlink already exists
    if [ -f "/usr/bin/$exec_basename" ]; then
        echo "File '/usr/bin/$exec_basename' already exists. We wont be able to create the symlink."
        unset exec_basename
        unset exec_path
        return 1
    fi
    # Add entry for gnome panel
    gnome_panel_entry_path="/usr/share/applications/$exec_basename.desktop"
    if [ -f "$gnome_panel_entry_path" ]; then
        echo "Entry '$(basename "$gnome_panel_entry_path")' already exists!"
        unset exec_basename
        unset gnome_panel_entry_path
        unset exec_path
        return 2
    fi
    # ask for display name
    while [ "$USER_RESPONSE" != "y" ] && [ "$USER_RESPONSE" != "Y" ]; do
        echo -n "Enter the program's name: "
        read APP_NAME
        while [ "$APP_NAME" == "" ]; do
            echo -n "Please enter something: "
            read APP_NAME
        done
        # ask for a description
        echo -n "Enter a short description: "
        read APP_DESCRIPTION
        # ask for an icon file
        echo -n "Enter absolute path to an icon image (empty for none): "
        read APP_ICON
        while [ "$APP_ICON" != "" ] && [ ! -f "$APP_ICON" ]; do
            echo -n "File doesn't exist. Retry: "
            read APP_ICON
        done 
        # ask if it needs a terminal
        echo -n "Will this program need a terminal? [y/n]: "
        read APP_TERMINAL
        while [ "$APP_TERMINAL" != "y" ] && [ "$APP_TERMINAL" != "n" ]; do
            echo -n "Please enter something: "
            read APP_TERMINAL
        done
        if [ "$APP_TERMINAL" == "y" ]; then
            APP_TERMINAL="true"
        else
            APP_TERMINAL="false"
        fi
        # ask for tags
        echo -n "Enter some categories that fit your program (';' separated): "
        read APP_CATEGORIES
        # Check if user is satisfied
        while [ "$USER_RESPONSE" == "" ] || [ "$USER_RESPONSE" != "y" ] && [ "$USER_RESPONSE" != "Y" ] && [ "$USER_RESPONSE" != "n" ] && [ "$USER_RESPONSE" != "N" ]; do
            echo -e "Is this information correct?\n"
            echo -e "\tName: \t\t$APP_NAME"
            echo -e "\tExecutable: \t$exec_path"
            echo -e "\tDescription: \t$APP_DESCRIPTION"
            echo -e "\tIcon File: \t$APP_ICON"
            echo -e "\tTerminal: \t$APP_TERMINAL"
            echo -e "\tCategories: \t$APP_CATEGORIES"
            echo -n "(y/n): "
            read USER_RESPONSE
        done
        if [ "$USER_RESPONSE" == "n" ] || [ "$USER_RESPONSE" == "N" ]; then
            echo "Then please enter everything again, kind sir"
            unset USER_RESPONSE
        fi
    done
    # User is happy
    # Add link to /usr/bin
    echo "Adding link to /usr/bin"
    sudo ln -s "$exec_path" "/usr/bin/$exec_basename"
    # Add gnome panel entry
    echo "Creating gnome-panel entry"
    echo "[Desktop Entry]" | sudo tee -a "$gnome_panel_entry_path" > /dev/null
    echo "Type=Application" | sudo tee -a "$gnome_panel_entry_path" > /dev/null
    echo "Encoding=UTF-8" | sudo tee -a "$gnome_panel_entry_path" > /dev/null
    echo "Name=$APP_NAME" | sudo tee -a "$gnome_panel_entry_path" > /dev/null
    echo "Comment=$APP_DESCRIPTION" | sudo tee -a "$gnome_panel_entry_path" > /dev/null
    echo "Icon=$APP_ICON" | sudo tee -a "$gnome_panel_entry_path" > /dev/null
    echo "Exec=$exec_path" | sudo tee -a "$gnome_panel_entry_path" > /dev/null
    echo "Terminal=$APP_TERMINAL" | sudo tee -a "$gnome_panel_entry_path" > /dev/null
    echo "Categories=$APP_CATEGORIES" | sudo tee -a "$gnome_panel_entry_path" > /dev/null
    echo "Entry added in '$gnome_panel_entry_path'"
    unset USER_RESPONSE
    unset APP_NAME
    unset APP_CATEGORIES
    unset APP_TERMINAL
    unset APP_DESCRIPTION
    unset APP_ICON
    unset exec_path
    unset exec_basename
    unset gnome_panel_entry_path
    return 0
}

:+1:为您节省时间:),很高兴拥有一个命令行工具
DanielPérez18年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.