如何将碎片添加到 KDE 上下文菜单以安全删除 file/folder?

How to add shred to KDE context menu for safe deletion of file/folder?

如何将 shred 实用程序添加到 Dolphin (Linux Mint 18 KDE) 的上下文菜单中以删除文件和 文件夹?

  1. 使用以下内容创建文件 shred.desktop
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=all/allfiles;
Actions=Shred
#X-KDE-Submenu=Shred

[Desktop Action Shred]
Name=Safe Remove
Name[ru]=Удалить навсегда
Icon=trash-empty
Exec=shred -u -f -z -n3 %u
  1. 使用以下内容创建文件 shred_folder.desktop
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=inode/directory;
Actions=Shred
#X-KDE-Submenu=Shred

[Desktop Action Shred]
Name=Safe Folder Remove
Name[ru]=Удалить папку навсегда
Icon=trash-empty
Exec=find %u -type f -exec shred -u -f -z -n3 {} \;
#Exec=find %u -type f -exec notify-send {} '' \;
  1. 将这些文件放在这里:/usr/share/kservices5/ServiceMenus/ (how to find this path?)
  2. 重启(或重启会话)

结果:

附加信息:

  1. MimeType 对于文件是 all/allfiles,对于文件夹是 inode/directory
  2. 使用的切碎选项:
-u  - After shredding a file, deallocate it (if possible) and then remove it.
-f  - Change permissions to allow writing if necessary.
-z  - Add a final overwrite with zeros to hide shredding.
-n3 - Use 3 passes of overwriting.
%u  - The file path for removing.
  1. 使用碎片删除文件夹的具体说明:https://unix.stackexchange.com/a/27029/330017
  2. 这里有更多关于创建上下文菜单项的信息:​​KDE documentation

这是一个略有改动的版本,实现了一个确认对话框和一个更合适的图标(恕我直言)

  • 文件
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=all/allfiles;
Actions=Shred
#X-KDE-Submenu=Shred

[Desktop Action Shred]
Name=Safe Remove
Icon=edit-delete-shred
Exec=/bin/bash -c 'kdialog --title "Safe Delete" --warningcontinuecancel "Safe Delete: Are you sure?" && shred -u -f -z -n3 %u'
  • 目录
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=inode/directory;
Actions=Shred
#X-KDE-Submenu=Shred

[Desktop Action Shred]
Name=Safe Folder Remove
Icon=edit-delete-shred
Exec=/bin/bash -c 'kdialog --title "Safe Delete" --warningcontinuecancel "Safe Delete: Are you sure?" && find %u -type f -exec shred -u -f -z -n3 {} \; && rmdir %u'