Skip to content

Instantly share code, notes, and snippets.

@webghostx
Last active June 10, 2024 08:43
Show Gist options
  • Save webghostx/3be4ed786fdf3e7bc5b23a8606b67c21 to your computer and use it in GitHub Desktop.
Save webghostx/3be4ed786fdf3e7bc5b23a8606b67c21 to your computer and use it in GitHub Desktop.
Copy File Path from Context Menu in LXQt/pcmanfm-qt

Copy File Path from Context Menu in LXQt/pcmanfm-qt

In this example, a function will be added to the context menu that allows copying the absolute file path or the path of a directory to the clipboard. The xclip package is used for this purpose. Alternatively, the xsel package can be used.

Instructions

  1. Create a .desktop file: Create the directory $HOME/.local/share/file-manager/actions/ if it doesn't already exist. This name is expected by LXQt and pcmanfm-qt. Create a file named like copy-path.desktop within that directory with the following content:

    [Desktop Entry]
    Type=Action
    Profiles=profile1
    
    Name=Copy path
    Name[de]=Pfad kopieren
    
    Icon=edit-copy
    
    [X-Action-Profile profile1]
    MimeTypes=all/allfiles;inode/directory;
    Exec=sh -c 'echo -n %f | xclip -selection clipboard'
    
  2. Install xclip: Install xclip if it is not already installed:

    sudo apt install xclip
    

Notes

  • Directory structure: The file must be located in the directory $HOME/.local/share/file-manager/actions/.
  • Dependencies: xclip or an alternative must be installed (sudo apt install xclip).

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment