我已经在 KDE 中为一些应用程序创建了一个 .desktop .local/share/applications
,我想知道是否可以从终端将它们添加到应用程序启动器中的“收藏夹”,因为我是从脚本创建 .desktop 的,类似于这个问题从命令行将应用程序添加到收藏夹但对于 KDE
提前致谢
答案1
收藏夹由kactivitymanagerd
服务存储。我们可以让脚本与服务对话:
# <Have your script create the .desktop file>
DESKTOP_FILE_NAME=org.kde.dolphin.desktop # Specify the name of the file
# Add to application launcher favorites
if pgrep -cfU $UID '^/usr/lib/x86_64-linux-gnu/libexec/kactivitymanagerd$' > /dev/null; then
# The service is running so ask it to add the new favorite
# in the same way plasmashell would ask it to.
dbus-send --type=method_call --dest=org.kde.ActivityManager /ActivityManager/Resources/Linking org.kde.ActivityManager.ResourcesLinking.LinkResourceToActivity string:org.kde.plasma.favorites.applications string:applications:"$DESKTOP_FILE_NAME" string::any
# Refresh the display
kquitapp5 plasmashell &> /dev/null
kstart5 plasmashell &> /dev/null
else
# The service is not running, so modify the favorites database.
echo "INSERT INTO ResourceLink(usedActivity,initiatingAgent,targettedResource) VALUES (':global','org.kde.plasma.favorites.applications','applications:$DESKTOP_FILE_NAME');" | sqlite3 ~/.local/share/kactivitymanagerd/resources/database
fi