Solved

KDE service menu

Posted on 2004-09-26
6
345 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
  • 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now