4

I know how to create a symbolic link to a folder. However, when you access the target folder (e.g. from a symbolic link on the Desktop), it appears as if the target folder is a child of the Desktop folder. I'd like it to work as in Windows where you actually get to the folder and can see it in its real context.

I've come across similar questions, one of which suggests creating a launcher. I believe this is meant for GNOME/Unity Ubuntu and I'm not sure what the equivalent on KDE would be.

How can I achieve this on Kubuntu 19.10 with KDE Plasma?

3 Answers 3

3

Suppose you want a link in ~/Desktop/ to this folder:

~/Documents/my-project/

You can do this with dolphin like so:

  • Navigate Dolphin to ~/Desktop.

  • Right-click → "Create New" → "Link to Location (URL)..."

    Right-click menu

  • In the "File name" field, enter "my-project.desktop"

    Dolphin - Create link to URL

  • In the "Enter link to location (URL)" field, click the folder icon ("Open file dialog") and navigate to ~/Documents/my-project, then click "Open".

    Fields filled in.

  • Click "OK".

This will create a link to the folder on the desktop that looks like this:

my-project.desktop

Double-clicking it will open Dolphin to this path:

~/Documents/my-project/

You can also move this desktop file to any other directory and it will work just the same.

The contents of the text file are:

[Desktop Entry]
Icon=folder
Type=Link
URL[$e]=file:$HOME/Documents/my-project/

This is an example of a Link-type desktop file, which is part of a FreeDesktop standard. If you want to ensure it works the same on other desktops, open it in a text editor and add a Name field and change the URL field to a standard file:// URL:

[Desktop Entry]
Name=my-project
Icon=folder
Type=Link
URL=file:///home/my-user-name/Documents/my-project/
5
  • This seems to work quite nicely! The only drawback is that there doesn't seem to be any visual indication of whether a folder is a real folder or a link (if I create a symbolic link with ln -s, there's a small icon on a folder indicating a link).
    – Gigi
    Aug 11, 2020 at 20:58
  • 1
    @Gigi Yeah, dolphin only does that for symbolic links. You could use a different icon like Icon=folder-green or Icon=folder-violet, though. Aug 11, 2020 at 21:38
  • Interesting. Is there a list of standard icons somewhere?
    – Gigi
    Aug 13, 2020 at 16:41
  • 1
    @Gigi There is a standard list, but colored folders aren't included. I just ran dpkg -L breeze-icon-theme; you could also check the filelist. Aug 13, 2020 at 20:23
  • Create new link should be run in the folder where you want the link to sit
    – ijuneja
    May 26, 2021 at 10:09
1

This works for me in Kubuntu 19.10:

Create the following file in your Desktop folder:

#!/usr/bin/env xdg-open
[Desktop Entry]
Name=---
Exec=dolphin ---
Icon=system-file-manager
Type=Application
X-DocPath=dolphin/index.html
Categories=Qt;KDE;System;FileTools;FileManager;
GenericName=---
Terminal=false
MimeType=inode/directory;
InitialPreference=10
X-DBUS-ServiceName=org.kde.dolphin
StartupWMClass=dolphin

And save it as template.txt.

Now, each time you want to create a folder shortcut on your desktop, edit template.txt and change each occurrence of --- to whatever is appropriate and save the file with the appropriate prefix with .desktop as the suffix.

Two examples:

Example 1

This will open your $HOME/Videos folder:

#!/usr/bin/env xdg-open
[Desktop Entry]
Name=OpenVideos
Exec=dolphin $HOME/Videos
Icon=smtube
Type=Application
X-DocPath=dolphin/index.html
Categories=Qt;KDE;System;FileTools;FileManager;
GenericName=OpenVideos
Terminal=false
MimeType=inode/directory;
InitialPreference=10
X-DBUS-ServiceName=org.kde.dolphin
StartupWMClass=dolphin

Note: I've changed Icon=system-file-manager to Icon=smtube. You can give the folders distinctive icons by right-clicking on the icon on your desktop, opening Properties and then, in the window that appears, clicking on the icon itself: doing so will allow you to select an icon.

Example 2

This will open /var/log/apt:

#!/usr/bin/env xdg-open
[Desktop Entry]
Name=OpenApt-logs
Exec=dolphin /var/log/apt
Icon=system-file-manager
Type=Application
X-DocPath=dolphin/index.html
Categories=Qt;KDE;System;FileTools;FileManager;
GenericName=Apt-logs
Terminal=false
MimeType=inode/directory;
InitialPreference=10
X-DBUS-ServiceName=org.kde.dolphin
StartupWMClass=dolphin

Adding folders to desktop

And this is how the .desktop files in ~/Desktop looks like in konsole:

$ ls -l
total 36
drwxr-xr-x  4 dkb dkb 4096 Jan  2 07:41  ./
drwxr-xr-x 18 dkb dkb 4096 Jan  2 07:19  ../
-rwxrw-r--  1 dkb dkb  346 Jan  2 07:41  Apt-History.desktop*
-rw-rw-r--  1 dkb dkb 2414 Sep 28 16:35  autoremove.txt
-rw-r--r--  1 dkb dkb   50 Sep 28 14:12  .directory
drwxrwxr-x  2 dkb dkb 4096 Sep 28 16:17  MyNext/
drwxrwxr-x  2 dkb dkb 4096 Dec 25 10:15 'New Folder'/
-rwxrw-r--  1 dkb dkb  345 Jan  2 07:36  OpenVideos.desktop*
$ 

Of course, there are other ways to open specific folders in Dolphin directly.

One way is to specify keyboard shortcuts to open a specific folder. For example, I've set Ctrl+Meta+N to open my Downloads folder.

Another way is to use Rofi. In the image below, I typed 12. Pressing Enter now would open ~/.local/share in Dolphin. Similarly, I could open ~/bin, ~/.config, ~/Downloads, etc. The same screen also lets me launch certain scripts (that don't need to be run from a terminal), and to open documents.

Using Rofi to open folders

0

I'm not using kde, but this working with xfce, and you should be able to Create launcher in kde too with

kd-open <full-dir-path>

or

xdg-open <full-dir-path>

for the command and then, use Desktop for the working dir.

BUT if that doesn't work try..

right click the desktop background and select 'Create URL link' give it a name and the full path to dir as the URL this will give you a link which when opened will show the actual path

Once opened you can drag anything you want into that dir.

If you're not familiar with the basic file management commands I highly recommend learning the basics.

One other thing that came to mind that may be of use to you is creating an alias in the .bash_aliases file.

Use

alias <command-name>='xdg-open <full-dir-path>'

or

alias <command-name>='kd-open <full-dir-path>'

and then, source it with

source .bash_aliases

and you will be able to use the alias as a command to open the gui from anywhere i the terminal.

Ctrl+Alt+T should open a terminal emulator.

You must log in to answer this question.

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