Skip to content

Instantly share code, notes, and snippets.

@webghostx
Last active June 10, 2024 08:43

Revisions

  1. webghostx revised this gist Jun 10, 2024. 1 changed file with 2 additions and 9 deletions.
    11 changes: 2 additions & 9 deletions Copy-File-Path-from-Context-Menu-LXQt.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ In this example, a function will be added to the context menu that allows copyin

    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 `copy-path.desktop` within that directory with the following content:
    Create a file named like `copy-path.desktop` within that directory with the following content:

    ```
    [Desktop Entry]
    @@ -23,13 +23,7 @@ In this example, a function will be added to the context menu that allows copyin
    Exec=sh -c 'echo -n %f | xclip -selection clipboard'
    ```

    2. **Ensure the file is executable:**
    Run the following command in the terminal to make the file executable:
    ```
    chmod +x $HOME/.local/share/file-manager/actions/copy-path.desktop
    ```

    3. **Install `xclip`:**
    2. **Install `xclip`:**
    Install `xclip` if it is not already installed:
    ```
    sudo apt install xclip
    @@ -38,7 +32,6 @@ In this example, a function will be added to the context menu that allows copyin
    ### Notes

    - **Directory structure:** The file must be located in the directory `$HOME/.local/share/file-manager/actions/`.
    - **Permissions:** Ensure the file is executable (`chmod +x`).
    - **Dependencies:** `xclip` or an alternative must be installed (`sudo apt install xclip`).

    ### References
  2. webghostx revised this gist Jun 9, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Copy-File-Path-from-Context-Menu-LXQt.md
    Original file line number Diff line number Diff line change
    @@ -45,3 +45,4 @@ In this example, a function will be added to the context menu that allows copyin

    - [lxqt/pcmanfm-qt custom Actions](https://github.com/lxqt/pcmanfm-qt/wiki/custom_actions)
    - [xclip](https://manpages.ubuntu.com/manpages/xenial/man1/xclip.1.html)
    - [Manjaro Wiki](https://wiki.manjaro.org/index.php/PCmanFM-Qt)
  3. webghostx created this gist Jun 9, 2024.
    47 changes: 47 additions & 0 deletions Copy-File-Path-from-Context-Menu-LXQt.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    ## 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 `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. **Ensure the file is executable:**
    Run the following command in the terminal to make the file executable:
    ```
    chmod +x $HOME/.local/share/file-manager/actions/copy-path.desktop
    ```

    3. **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/`.
    - **Permissions:** Ensure the file is executable (`chmod +x`).
    - **Dependencies:** `xclip` or an alternative must be installed (`sudo apt install xclip`).

    ### References

    - [lxqt/pcmanfm-qt custom Actions](https://github.com/lxqt/pcmanfm-qt/wiki/custom_actions)
    - [xclip](https://manpages.ubuntu.com/manpages/xenial/man1/xclip.1.html)