Registered Member
|
Hi,
i know how to create a new context menu when i click right on a file in a normal way. i want to have a new contect menu when i press F2 (rename a file or a folder) and then right click to the selected file. here i can copy the file or folder name (or a part of that) to the clipboard. what i want is a context menu to copy the file/folder name or a part of that to a simple text file. is this possible? fmeier |
Registered Member
|
Just to make sure I understand what you want:
You want to initiate a rename (inline or pop-up?), select all/part of the file name, right-click and have an option show up to save the selected (part of the) file name to a new file? A couple of ideas: * Add a new service menu item for Copy Name To New File. You can use a script which pops up a dialog (with e.g. kdialog) with the selected file's name in the input so you can cut out whatever and give the target file a name and then save. Another option here could be have the service menu open kwrite with e.g. "echo '%f' | kwrite --stdin" to open a new file with the file name as the contents. * Set up a Klipper Action to do this when you copy the file name (insofar as you can figure out a good regex to match these file names and not other things you might get in your clipboard).
airdrik, proud to be a member of KDE forums since 2008-Dec.
|
Registered Member
|
When i select a file or folder and press F2 i can rename the file or folder. when i right click on the selected file name or folder name i have a different context menu as the menu when i normally right click on a file/folder (without F2). i want to edit this menu and add a new option "save to text file".
i don't think this is necessary. normally when i press f2 the whole file name (exept the extention) is highlighted. here the whole file name would e copied to a text file. i can change the highlighted text to that part of the file name that i want to copy to a text file. so i think i don't need a pop up.
and how can i do this? i know how to create a new context menu for the normal right click menu (*.desktop file in ~/.local/share/kservices5/ServiceMenus). but here are no files for the other context menu? |
Registered Member
|
For an overview on writing a service menu you may refer to: https://techbase.kde.org/Development/Tu ... vice_Menus
There are also a few service menus in the kde store which you can use as examples for writing your own. Of course this suggestion will still open kwrite with the file name in it and require you to remove the parts of the file name that you don't want (unless you can come up with a reliable shell command to trim it down). If you are insistent that you want the new file creation to happen when you select the part of the file name you want and not be bothered with anything popping up, you should look into using Klipper to do that (that's really the only way to trigger something off of a selection like this).
airdrik, proud to be a member of KDE forums since 2008-Dec.
|
Registered users: Bing [Bot], gfielding, Google [Bot], markhm, sethaaaa, Sogou [Bot], Yahoo [Bot]