?
Solved

KDE service menu

Posted on 2004-09-26
6
Medium Priority
?
354 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

752 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