1

When creating a new Dolphin service menu to create a new text file using Kate (given there is no shortcut for that like for folders and that the menu option is rather hidden under multiple clicks as said here), using a desktop file like this

[Desktop Entry]
Type=Service
Icon=kate
Actions=new-file
ServiceTypes=KonqPopupMenu/Plugin,inode/directory
X-KDE-Priority=TopLevel

[Desktop Action new-file]
Name=New text file
Icon=kate
Exec=kate %u

Kate creates the file not within the selected directory, but at the same path as that directory, one level up than expected: selecting folder /PATH/TO/MY_DIRECTORY and using the context menu service, the text file is ready to be saved at /PATH/TO instead of /PATH/TO/MY_DIRECTORY.

The same happens with Exec=kate -n new.txt %u, as the file is created and saved.

How to make Kate save or offer to save within the selected directory?

How to do it inside the selected folder?

1
  • 1
    I got a possible solution using a script, check my edited answer. Oct 19, 2021 at 23:41

1 Answer 1

1

As %u is expanded to the current directory, you can do something like this (it works in my testing):

Create an executable script with the following content:

#!/bin/bash

c=0

for f in "$1/"new*.txt; do
  if [[ -f "$f" ]]; then
    ((c++)) 
  fi
done

f="$1/new-$c.txt"
touch "$f"
kate "$f"

Then in your desktop file:

...
Exec=/path/to/script/script %f
...
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .