This forum has been archived. All content is frozen. Please use KDE Discuss instead.

custom service menu for Dolphin

Tags: None
(comma "," separated)
User avatar
urgo
Registered Member
Posts
8
Karma
0
OS

custom service menu for Dolphin

Mon Apr 14, 2014 6:20 pm
Hello everybody,
I want to create zip archive from all files in the current folder. Here is the code from my .desktop file:

Code: Select all
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=all/all;
Name=Android_Developer
Actions=Create_updateZIP;
X-KDE-Submenu=Compress
X-KDE-Submenu=Android Developer
X-KDE-StartupNotify=false
X-KDE-Priority=TopLevel
Icon=ark

[Desktop Action Create_updateZIP]
Name=Create update.zip file
Exec=zip -r9 update.zip %F
Icon=ark


It gives me an update.zip file as a result but... for example:
If I have opened "/home/user/Desktop/WorkingFolder" in Dolphin where is located 1 file - "a.txt", and I run my script there
it gives me the file compressed but the result zip file is placed in "/home/user" and inside the zip you can see that structure "/home/user/Desktop/WorkingFolder/a.txt".

I would like to have "update.zip" file placed to "/home/user/Desktop/WorkingFolder" with "a.txt" file inside only.

Any idea how to do it?
User avatar
google01103
Manager
Posts
6668
Karma
25

Re: custom service menu for Dolphin

Mon Apr 14, 2014 7:06 pm
for the file name stripped of the path:

Code: Select all
Exec=zip -r9 --junk-paths update.zip %F


per the man page: --junk-paths stores just the name of a saved file

for all of what you want:

Code: Select all
Exec=(cd %d && zip -r9 --junk-paths update.zip  %F)

got this from the CompressIT.desktop file found in my ServiceMenus folder

ps - not tested


OpenSuse Leap 42.1 x64, Plasma 5.x

User avatar
urgo
Registered Member
Posts
8
Karma
0
OS

Re: custom service menu for Dolphin

Mon Apr 14, 2014 8:03 pm
I will test and let you know ;)

----------

It is already checked. It doesn't work. :(
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: custom service menu for Dolphin

Thu Apr 17, 2014 9:33 am
To fix this you'll need to create a wrapper script which first changes into the desired directory (I recommend the "dirname" command to find this out) then invokes zip as desired.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
urgo
Registered Member
Posts
8
Karma
0
OS

Re: custom service menu for Dolphin

Thu Apr 17, 2014 8:34 pm
I tried to use this
Code: Select all
[Desktop Action Create_updateZIP]

Name=Create update.zip file

Exec=cd dirname %f  >> ~/Desktop/log.txt; zip -r9 update.zip %F

Icon=ark


but the result in log.txt is /home/user

---

okay, I solved my problem by using absolut path:

Code: Select all
[Desktop Action Create_updateZIP]

Name=Create update.zip file

Exec=cd ~/Desktop/working_folder; zip -r9 update.zip %F; kdialog --title="Create update.zip file" --msgbox "Ready! File saved to ~/Desktop/working_folder/update.zip"

Icon=ark


... but it would be nice to know how to create an update.zip file by using the relative (current folder) path.

Last edited by urgo on Thu Apr 17, 2014 8:58 pm, edited 2 times in total.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: custom service menu for Dolphin

Thu Apr 17, 2014 8:36 pm
As far as I am aware, the Exec= line doesn't support bash/shell style statements. Hence why you need to place them all in a separate script stored elsewhere, and have the service menu execute that script instead.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], gfielding, Google [Bot], markhm, sethaaaa, Sogou [Bot], Yahoo [Bot]