当前位置: 首页 > 工具软件 > Ubuntu Studio > 使用案例 >

Ubuntu下创建Android Studio启动图标

端木渝
2023-12-01

问题

Linux发行版的Android Studio没有启动图标

解决方法1

第一次通过终端启动bin/studio.s脚本,会启动Android Studio,通过菜单 Tools > Create Desktop Entry… 就可以创建了

解决方法2

直接修改了SmartGit带的一个脚本(add-menuitem.sh),感兴趣的可以下载个smartgit/bin下看看这个脚本。

脚本

保存下面的脚本到android-studio-2020.3.1.25-linux/android-studio/bin目录下面,名称随意,当然可以直接还叫 add-menuitem.sh ,在当前目录打开终端执行下就好了,顺带说一下网上好些要你手动创建,涉及到权限不一定稳,自己要注意下,

脚本仅仅改动了必要的地方,有些没必要改动的就没有改动

#!/bin/bash
#
# Resolve the location of the SmartGit installation.
# This includes resolving any symlinks.
PRG=$0
while [ -h "$PRG" ]; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
    if expr "$link" : '^/' 2> /dev/null >/dev/null; then
        PRG="$link"
    else
        PRG="`dirname "$PRG"`/$link"
    fi
done

SMARTGIT_BIN=`dirname "$PRG"`

# absolutize dir
oldpwd=`pwd`
cd "${SMARTGIT_BIN}"
SMARTGIT_BIN=`pwd`
cd "${oldpwd}"

ICON_NAME=syntevo-smartgit
TMP_DIR=`mktemp --directory`
DESKTOP_FILE=$TMP_DIR/syntevo-smartgit.desktop
cat << EOF > $DESKTOP_FILE
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=Android Studio
Keywords=android
Comment=android studio
Type=Application
Categories=Development
Terminal=false
Exec="$SMARTGIT_BIN/studio.sh" %u
Icon=$ICON_NAME.png
EOF

# seems necessary to refresh immediately:
chmod 644 $DESKTOP_FILE

xdg-desktop-menu install $DESKTOP_FILE
xdg-icon-resource install --size 128 "$SMARTGIT_BIN/studio.png" $ICON_NAME

rm $DESKTOP_FILE
rm -R $TMP_DIR

另外附上SmartGit原来的脚本以供参考

#!/bin/bash
#
# Resolve the location of the SmartGit installation.
# This includes resolving any symlinks.
PRG=$0
while [ -h "$PRG" ]; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
    if expr "$link" : '^/' 2> /dev/null >/dev/null; then
        PRG="$link"
    else
        PRG="`dirname "$PRG"`/$link"
    fi
done

SMARTGIT_BIN=`dirname "$PRG"`

# absolutize dir
oldpwd=`pwd`
cd "${SMARTGIT_BIN}"
SMARTGIT_BIN=`pwd`
cd "${oldpwd}"

ICON_NAME=syntevo-smartgit
TMP_DIR=`mktemp --directory`
DESKTOP_FILE=$TMP_DIR/syntevo-smartgit.desktop
cat << EOF > $DESKTOP_FILE
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=SmartGit
Keywords=git
Comment=Git-Client
Type=Application
Categories=Development;RevisionControl
Terminal=false
StartupWMClass=SmartGit
Exec="$SMARTGIT_BIN/smartgit.sh" %u
MimeType=x-scheme-handler/git;x-scheme-handler/smartgit;
Icon=$ICON_NAME.png
EOF

# seems necessary to refresh immediately:
chmod 644 $DESKTOP_FILE

xdg-desktop-menu install $DESKTOP_FILE
xdg-icon-resource install --size  32 "$SMARTGIT_BIN/smartgit-32.png"  $ICON_NAME
xdg-icon-resource install --size  48 "$SMARTGIT_BIN/smartgit-48.png"  $ICON_NAME
xdg-icon-resource install --size  64 "$SMARTGIT_BIN/smartgit-64.png"  $ICON_NAME
xdg-icon-resource install --size 128 "$SMARTGIT_BIN/smartgit-128.png" $ICON_NAME

rm $DESKTOP_FILE
rm -R $TMP_DIR
 类似资料: