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

ServiceMenu Script Help

Tags: None
(comma "," separated)
Xplorer4x4
Registered Member
Posts
206
Karma
0
OS

ServiceMenu Script Help

Sat Jun 23, 2012 11:32 pm
I am trying to write a service menu that can search directories for RAR files. I placed the .desktop file in /usr/share/kde4/services/ServiceMenus/ but it does not show up. Where did I go wrong? Here is the contents of the .desktop: http://pastebin.com/2Uubw2vZ

Last edited by Xplorer4x4 on Sun Jun 24, 2012 5:08 pm, edited 1 time in total.


Intel Core i7 2600K CPU
MSI P67A-G45 Mobo
2x4GB Corsair Vengance RAM
Sapphire Raedon 4890HD Vapor-X GPU
1x180 GB Intel 330 SSD
1x80GB Intel X25-M G2 SSD
2x1TB Western Digital HDDs
2x2TB Wester Digital HDDS
Corsair HX520W PSU
Thermaltake Mozart TX Case
Xplorer4x4
Registered Member
Posts
206
Karma
0
OS
Ok so I realized that the .desktop needed to be in ~/.kde/share/kde4/services/ServiceMenus/ but I am still having trouble with the exec line. I assume I need to change it to first launch Konsole then execute the command but I am not sure how I would do that.


Intel Core i7 2600K CPU
MSI P67A-G45 Mobo
2x4GB Corsair Vengance RAM
Sapphire Raedon 4890HD Vapor-X GPU
1x180 GB Intel 330 SSD
1x80GB Intel X25-M G2 SSD
2x1TB Western Digital HDDs
2x2TB Wester Digital HDDS
Corsair HX520W PSU
Thermaltake Mozart TX Case
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: ServiceMenu Script Help

Mon Jun 25, 2012 2:17 am
For the command, you probably want to alter it to look like this first:
Code: Select all
konsole --workdir %f -e 'find -type f -name *.rar -exec unrar e {} \;'


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
Xplorer4x4
Registered Member
Posts
206
Karma
0
OS

Re: ServiceMenu Script Help

Mon Jun 25, 2012 2:34 am
Sorry I forgot to update this with the solution(too much going on today) but here is what the guys on kubuntuforums came up with:
Code: Select all
Exec=konsole --hold --workdir %f -e find -type f -name '*.rar' -exec unrar e '{}' ';'

However I have not had time to look in to it, but is it possible to have Konsole only hold/keep the session open if there is an error but close on a sucesful out put? I was also hoping to make it compatible with split archives using the naming scheme of part 01.rar part02.rar and so on but have no idea how to include an if/else type check here.


Intel Core i7 2600K CPU
MSI P67A-G45 Mobo
2x4GB Corsair Vengance RAM
Sapphire Raedon 4890HD Vapor-X GPU
1x180 GB Intel 330 SSD
1x80GB Intel X25-M G2 SSD
2x1TB Western Digital HDDs
2x2TB Wester Digital HDDS
Corsair HX520W PSU
Thermaltake Mozart TX Case
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: ServiceMenu Script Help

Mon Jun 25, 2012 5:42 am
The option "--hold" or "--noclose" may be helpful here.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
Xplorer4x4
Registered Member
Posts
206
Karma
0
OS

Re: ServiceMenu Script Help

Wed Jun 27, 2012 5:08 am
bcooksley wrote:The option "--hold" or "--noclose" may be helpful here.

Aren't those redundant? As you can see I am using --hold currently and that holds the windows open when the process is complete.

1. I also have some more service menu questions, is the Exec line simply bash commands like you would enter in Konsole?
2. Is it possible to execute commands from the exec line in a progressive matter? For example you select 4 folders with split RAR archives. I assume I would need to use ark directly rather then unrar? Would I need to resort to executing a shell script instead?
3.Where is the "move to trash" context menu entry located? I can't seem to find it.


Intel Core i7 2600K CPU
MSI P67A-G45 Mobo
2x4GB Corsair Vengance RAM
Sapphire Raedon 4890HD Vapor-X GPU
1x180 GB Intel 330 SSD
1x80GB Intel X25-M G2 SSD
2x1TB Western Digital HDDs
2x2TB Wester Digital HDDS
Corsair HX520W PSU
Thermaltake Mozart TX Case
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: ServiceMenu Script Help

Wed Jun 27, 2012 5:39 am
Yes, --hold and --noclose are redundant and do the same job. Unfortunately I did not see them in your command when I mentioned it. Sorry about that.

For 1) I am not aware of the exact conditions, but it very possibly is executed under a shell. You would have to test to confirm this (and if it is not, explicitly requesting a shell should work fine).

For 3) I believe this is a programmed in action, and does not use the service menus framework to function.

For 2) If you had access to a full shell, using '&&' in between each command should achieve this, as long as each command does not fork (in which case, it will execute the next action when it forks).

In regards to split archives, I believe if you give unrar the first archive (.001 usually I think) then it will find the other ones as well, if they are in the same directory automatically.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
Xplorer4x4
Registered Member
Posts
206
Karma
0
OS

Re: ServiceMenu Script Help

Wed Jun 27, 2012 5:50 am
bcooksley wrote:Yes, --hold and --noclose are redundant and do the same job. Unfortunately I did not see them in your command when I mentioned it. Sorry about that.

For 1) I am not aware of the exact conditions, but it very possibly is executed under a shell. You would have to test to confirm this (and if it is not, explicitly requesting a shell should work fine).

For 3) I believe this is a programmed in action, and does not use the service menus framework to function.

For 2) If you had access to a full shell, using '&&' in between each command should achieve this, as long as each command does not fork (in which case, it will execute the next action when it forks).

In regards to split archives, I believe if you give unrar the first archive (.001 usually I think) then it will find the other ones as well, if they are in the same directory automatically.

As for --hold and --noclose, no worries I just wanted to check.

1.Ok I will test something basic tomorrow and see what I can come up with.

2. I am aware of & and && but I am not sure it would work with the command above based on the way it functions. Obviously "sudo apt-get update && sudo apt-get upgrade works fine, but we are dealing with a single action at a time.

3(trash).I have installed one of the "root actions" service menu and the only thing it lacks is a move to recycle bin. Thinking about it though, this would move it to the recycle bin(sorry trash can, after ages of windows usage it sticks in your head :p) for the user root rather then my users recycle bin, correct?


Intel Core i7 2600K CPU
MSI P67A-G45 Mobo
2x4GB Corsair Vengance RAM
Sapphire Raedon 4890HD Vapor-X GPU
1x180 GB Intel 330 SSD
1x80GB Intel X25-M G2 SSD
2x1TB Western Digital HDDs
2x2TB Wester Digital HDDS
Corsair HX520W PSU
Thermaltake Mozart TX Case
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: ServiceMenu Script Help

Wed Jun 27, 2012 6:17 am
For the Trash action, yes that would be correct - it would use root's trash folder.


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


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell