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

getting the path from dolphin->contextmenu->actions

Tags: None
(comma "," separated)
baumnkraxler
Registered Member
Posts
5
Karma
0
Hi there,

please excuse my maybe not perfect english. Also i work in a german setup, so hopefully all transcriptions are correct.

For my daily work i want to create a context-menu entry for directories that calls a shellscript.
I created the .desktop-file in
/home/frank/.local/share/kservices5/ServiceMenus/
and i get my script called via right-click->context-menu->actions->etc... , so this part works.
For testing purposes i just echo things out to the terminal and a .txt-file.
Here is the .desktop-entry:
Code: Select all
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
MimeType=inode/directory
Actions=quer_Kunden_GA;quer_Kunden_Baumbilder;quer_GA_Baumbilder;quer_Kunden_GA_Baumbilder;quer_GA_TMS
X-KDE-Submenu=Querlinks

[Desktop Action quer_Kunden_GA]
Name=Links Kunden-GA
Name[en]=links Kunden-Gutachten
Icon=background
Exec=/bin/bash -c "sh /home/frank/bin/kde/querlinks/quer_Kunden_Gutachten.sh"

>...and the other entrys, but i use this first one for testing...<

and here the called shell-script:
Code: Select all
echo "PWD ist "$PWD
echo "u ist str 0 1 2  "$0  $1  $2 $u %u
echo
echo "PWD ist "$PWD >> /home/frank/bin/kde/querlinks/text.txt
echo "u ist str 0 1 2  "$0  $1  $2 $u $%u >> /home/frank/bin/kde/querlinks/text.txt

read -p "Eingabe " input

The "read -p ..." line is for keeping the terminal open, for this i tried
Exec=konsole -e /bin/bash --rcfile /home/frank/bin/fsync/sisd &
.
"echo ... $u %u" was for trying just anything.

As expected i get
Code: Select all
PWD ist /home/frank/.local/share/kservices5
as $PWD, which i actually don´t need to work on further with.
Also i get $0,
Code: Select all
u ist str 0 1 2  /home/frank/bin/kde/querlinks/quer_Kunden_Gutachten.sh %u
which is path and name of my shellscript (plus "%u", so this didn´t work).

But i did not manage to get the path from where i called the
actions
-action.
I tried any iteration of using sh or bash, with or without ' " ' on different places and so on.

I followed this https://develop.kde.org/docs/dolphin/service-menus/ tutorial, telling
Tip
If you have a complex task that requires more than one command (for example if we wanted to copy the image file somewhere first and then use D-Bus to set it as the background) use a shell:

Exec=/bin/sh -c ";<YOUR COMMANDS HERE>"


also inserting the " ; " inside the ' " ', then nothing at all happened.

After hours of trying i urge for solution... how can i use the desired variable, which is reffered to as
%u
for use with d-bus, in my shellscript?

Thanks in advance, i appreciate any help,

Frank


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], lockheed, Sogou [Bot], Yahoo [Bot]