我没有找到一种“正常”的方法来做到这一点,所以我制作了一个 bash 脚本来完成这项工作。
好吧,这是脚本:
#!/bin/bash
#This script adds to launcher a specific document that the user has selected
#After specifying the document and its icon DO NOT remove them from their original position in your disk
#THE ICON SHOULD NOT HAVE SPACES IN ITS PATH AND TO BE A PNG FILE
# VALID PATH EXAMPLE:
# /usr/share/pixmaps/wallch.png
# INVALID PATH EXAMPLE:
# /home/alex/Pictures/MY PICS/pic.png
document=$(zenity --file-selection --title="Select the document")
if [[ "$document" == "" ]]; then
exit #no document specified
fi
icon=$(zenity --file-selection --title="Select an icon for it")
if [[ "$icon" == "" ]]; then
exit #no icon specified
fi
name=$(basename "$document")
desktop_name=$(echo $name | tr ' ' '_')
echo "
[Desktop Entry]
Name=$name
Comment=Open me
Exec=xdg-open \"$document\"
Icon=$icon
Terminal=0
Type=Application
Encoding=UTF-8
Categories=Utility;Application;" > ~/.local/share/applications/$desktop_name.desktop
echo "The file ~/.local/share/applications/$desktop_name.desktop has been created, pointing to $document"
Run Code Online (Sandbox Code Playgroud)
要运行上述脚本,请使用 Gedit 将其复制并粘贴到一个文件中,然后将其另存为add_document_to_launcher.sh,右键单击它?特性 ?权限?选中允许将文件作为程序执行。然后(首选方法是)打开一个终端并通过那里运行脚本或双击该文件并选择“运行”。
将弹出一个对话框,要求您提供文档,然后会弹出另一个对话框,要求您提供此文档的图标。选择您喜欢的任何图标但是:它必须是 PNG 并且其路径不能包含空格。
在此之后,将创建~/.local/share/applications一个扩展名为 .desktop 的文件。
如果您打开 DASH 并使用其文件名搜索您的文档,它将显示在“应用程序”下(而不是文件和文件夹下)。您只需将文档拖放到启动器上即可!就是这样 :)
编辑:记住:在此之后,不要从其路径或您选择的图标中删除文档!
| 归档时间: |
|
| 查看次数: |
135 次 |
| 最近记录: |