Solved

KDE service menu

Posted on 2004-09-26
6
350 Views
Last Modified: 2008-02-01
I have partaly created a service menu. It calls up shred for me whenever I right click on a file or folder. The problem is shred is very limited and will not shred files contained within sub-folders when the command is issued. I use to issue the command from a command prompt "find /home/AD/Desktop/Trash/joe2 -iname "*" -exec shred {} -v -f -u -z \;" and this would delete all of the files recursivly in all subfolders. Anyone know how I can call this out in this service menu file to do the same thing. Also maybe someone can help me simplify the install script I created since I stink at scripting : )

here is the install script for the service menu file.
----------------------------------------------------------
cd /usr/share/apps/konqueror/servicemenus/
rm -f shred_files.desktop
echo shred_files.desktop
echo "[Desktop Entry]" >> shred_files.desktop
echo "Encoding=UTF-8" >> shred_files.desktop
echo "ServiceTypes=all/all" >> shred_files.desktop
echo "Actions=shredfiles;shred-folder-contents" >> shred_files.desktop
echo "X-KDE-Submenu=Shred Files" >> shred_files.desktop
echo "X-KDE-Priority=TopLevel" >> shred_files.desktop
echo "Icon=stop" >> shred_files.desktop
echo "" >> shred_files.desktop
echo "[Desktop Action shredfiles]" >> shred_files.desktop
echo "Name=Shred File(s)" >> shred_files.desktop
echo "Icon=stop" >> shred_files.desktop
echo "Exec=shred -vfuxz %F" >> shred_files.desktop
echo "" >> shred_files.desktop
echo "[Desktop Action shred-folder-contents]" >> shred_files.desktop
echo "Name=Shred Folder(s) Contents" >> shred_files.desktop
echo "Icon=stop" >> shred_files.desktop
echo "Exec=shred -vfuxz" >> shred_files.desktop
----------------------------------------------------------
0
Comment
Question by:illtbagu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:EinarTh
ID: 12159251
No problem.

1) create a wrapper script that execs your find command.

2) Make the desktop entry/service menu execute your script.

3) Profit ;)

regarding your install script, here's the more conventional way to write a file via a script:
-------------------------------
#!/bin/bash

#location depends on distro....
SERVICEMENUS=/opt/kde3/share/apps/konqueror/servicemenus/

cd $SERVICEMENUS
rm -f shred_files.desktop 2> /dev/null

cat > shred_files.desktop << EOF
[Desktop Entry]
Encoding=UTF-8
ServiceTypes=all/all
Actions=shredfiles;shred-folder-contents
X-KDE-Submenu=Shred Files
X-KDE-Priority=TopLevel
Icon=stop

[Desktop Action shredfiles]
Name=Shred File(s)
Icon=stop
Exec=shred -vfuxz %F

[Desktop Action shred-folder-contents]
Name=Shred Folder(s) Contents
Icon=stop
Exec=shred -vfuxz

EOF
-------------------------------
0
 
LVL 1

Expert Comment

by:DMS-X
ID: 12165095
I posted my service menu here http://kdelook.org/content/show.php?content=16565

Nice nothing better than a good Unix scripter to get things cleaned up :)

>Make the desktop entry/service menu execute your script
How can I write my script containing my find command to be executed on the folder(s) that gets selected?

Thanks again
0
 
LVL 4

Expert Comment

by:EinarTh
ID: 12169303
Lets create a litle program that does this (I'm a programmer so strictly speaking I should charge you $100 an hour, but since I'm not, I wont debug or even try to run it ;)

-----------8< --------------
#!/bin/bash
# if it's a directory, we first find all the
# files inside (recursively) and shred them,
# then remove the directory recursively
if[ -d $1 ]
  find $1 -type f -exec shred -vfuxz \{\} \;"
  rm -rf $1
else # its a file; just shred it
  shred -vfuxz $1
fi
------------8< -------------

Now, save this somewhere in your $PATH (or forever use the full path to the file) as, say shred_wrapper.sh, and make it executable (chmod u+x shred_wrapper.sh)

Then make the service menu execute this script, as in :

....
Exec=shred_wrapper.sh %F
....

cheers.

0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 1

Author Comment

by:illtbagu
ID: 12175945
You make me sick : )

I don't understand the -d or the \{\} \;"

Thanks
0
 
LVL 4

Accepted Solution

by:
EinarTh earned 300 total points
ID: 12180608
$1 == first argument to program

-d == "is the following a directory"

\{\} \; the backslashes are there so find can see them; otherwise bash eats up the special characters and bash will complain.

The extra " at the end of that line is a type-o
0
 
LVL 1

Expert Comment

by:DMS-X
ID: 12214336
>The extra " at the end of that line is a type-o
Maybe thats why I couldn't get it to work
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question