Even though I really do like the shell, I always use Dolphin to mount my digicam SD card and copy the photos onto my computer. I finally added a context menu item in Dolphin to create a forest stroll directory with the current date in order to save some typing:

Image

The following goes in ~/.local/share/kservices5/ServiceMenus/galmkdir.desktop:

[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin,inode/directory
Actions=Waldspaziergang;

[Desktop Action Waldspaziergang]
Name=Heutigen Waldspaziergang anlegen…
Icon=folder-green
Exec=~/src/gelbariab/galmkdir "%f"

In order to update the KDE desktop cache and make this action menu item available in Dolphin, I ran:

kbuildsycoca5

The referenced galmkdir script looks like that:

#!/bin/sh
set -e

current_dir="$1"
if [ -z "$current_dir" ]; then
    echo "Usage: $0 DIRECTORY" >&2
    exit 1
fi

dir="$(kdialog \
    --geometry 350x50 \
    --title "Heutigen Waldspaziergang anlegen" \
    --inputbox "Neues Verzeichnis in „$current_dir“ anlegen:" \
    "waldspaziergang-$(date +%Y-%m-%d)")"
mkdir "$current_dir/$dir"
dolphin "$current_dir/$dir"

This solution is far from perfect, though. Ideally, I’d love to have it in the “Create New” menu instead of the “Actions” menu. But that doesn’t really work. I cannot define a default directory name, not to mention even a dynamic one with the current date. (I would have to update the .desktop file every day or so.) I also failed to create an empty directory. I somehow managed to create a directory with some other templates in it for some reason I do not really understand.

Let’s see how that works out in the next days. If I like it, I might define a few more default directory names.

⤋ Read More

Participate

Login or Register to join in on this yarn.