KDE Dolphin Explorer hotkey to extract here

KDE Dolphin Explorer hotkey to extract here

is there a hot key in KDE Dolphin file explorer to Extract Here?

Leo AI said:
There is no default keyboard shortcut in KDE Dolphin to extract an archive "here" directly.  However, you can achieve this functionality using a custom setup. 

Option 1: Use the built-in "Extract Here" context menu item

  • Ensure Ark (the archive manager) is installed, as it provides the core extraction functionality. 
  • Right-click on an archive file in Dolphin and select "Extract Here" from the context menu.  This is the standard method, but it requires a mouse click. 

Option 2: Create a custom keyboard shortcut

  • You can create a custom script and assign a keyboard shortcut to it.
  • Use a script like ark -ba %u && rm %u (where %u is the archive file path) to extract the archive and delete the original file.
  • Save this script (e.g., extract_and_delete.sh), make it executable (chmod +x extract_and_delete.sh), and assign it to a custom global shortcut in System Settings > Shortcuts > Custom Shortcuts
  • Use %f or %u as the argument to pass the selected file. 

Option 3: Use Dolphin's "Open Archives as Folders" feature

  • Go to Settings > Configure Dolphin > Navigation > General
  • Enable "Open archives as folders"
  • This allows you to double-click on a ZIP file to open it directly as a folder, which is often faster than extracting. 

For a true hotkey, custom shortcuts (Option 2) are the most effective solution. 

You said:
How do I create a script for 'Extract Here' in KDE?

Leo AI said:
To create a script for "Extract Here" in KDE Dolphin:

  1. Restart Dolphin or log out/in. Right-clicking an archive will now show "Extract Here". 

(Optional) Integrate into Dolphin's context menu by creating a .desktop service menu in ~/.local/share/kservices5/ServiceMenus/extract_here.desktop:

[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=application/zip;application/x-tar;application/gzip;application/x-bzip;application/x-xz;application/x-7z-compressed;application/x-rar;
Actions=extractHere
X-KDE-Priority=TopLevel

[Desktop Action extractHere]
Name=Extract Here
Exec=ark -ba %u
Icon=archive-extract

Make the script executable:

chmod +x ~/extract_here.sh

Create a script file (e.g., extract_here.sh) with the following content:

#!/bin/bash
ark -ba "$1"

This uses Ark (ark) with -ba to extract the archive in the current directory. 

For a keyboard shortcut, go to System Settings > Shortcuts > Custom Shortcuts, create a new command, and assign a key to run ark -ba %u (ensure %u passes the selected file). 

You said:
Can I add a keyboard shortcut to Extract Here?

Leo AI said:
Yes, you can add a keyboard shortcut for "Extract Here" in KDE Dolphin by creating a custom global shortcut:

  1. Open System Settings > Shortcuts > Custom Shortcuts
  2. Click + to add a new shortcut. 
  3. Name it (e.g., "Extract Here").
  4. Assign a keyboard shortcut (e.g., Ctrl+Alt+E).
  5. Click Apply.

In the Command field, enter:

ark -ba %u

Now, when you select an archive in Dolphin and press the shortcut, it will extract it in place. 

Alternatively, use xdotool to simulate a right-click and navigate the context menu:

  • Install xdotool (sudo apt install xdotool).
  • Set the command to: xdotool click 3 && sleep 0.5 && xdotool key Down Down Enter (adjust arrow keys based on menu position).