Solved

KDE service menu

Posted on 2004-09-26
6
349 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
awk sed 8 64
ftp to port 21 4 53
bash file 10 49
FTP'ing Huge files ... How to ? FTP in segments -or- pick up ftp where you left off 5 54
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

839 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