Announcement

Collapse
No announcement yet.

Service Menus with Dolphin

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • wojcieche
    replied
    Originally posted by Don B. Cilly View Post
    It should execute directly if
    - It's set to +x (executable) and
    - has #!/bin/bash at the beginning.
    Originally posted by jlittle View Post
    Assuming the script is executable, and has the shebang, I would ask, where is the script? If it is sitting in the working directory specified in the .desktop file, as I expect given that sh zip.sh works, then there is a path ($PATH) issue. By default the current directory is not in the path. You can avoid the issue by invoking the script with "./" prepended, so, does this work?
    Code:
    Exec=./zip.sh %U
    Thanks guys! I had the script set to executable but was unaware of the shebang thing... ._. I added now and it works.
    I am still a newbie in many Linux areas, learning on the way by trying out new things - like just right here, sorry... ;-)

    I skipped the path to simplify the example, in fact I placed the script in a newly created directory in home and referenced to it using an absolute path, to make it reliable: ~/mybin/zip.sh
    Maybe it is just me but I feel the mybin as a directory name to store custom scripts is unpretty and misleading (sounds a bit like my trash bin not my binaries - although in root there is bin, oh well). Is there a Linux established location/naming convention where to put such user scripts?

    Also - how about the non-immediate refresh of context menu from .desktop files - looks like only I have this glitch? Maybe because of a different setup than yours - Arch + KDE Plasma + Dolphin...

    Leave a comment:


  • Don B. Cilly
    replied
    And just to b. cilly, the #!/bin/bash shebang will use bash, sh will use



    lrwxrwxrwx 1 root root 4 May 15 13:43 /bin/sh -> dash*

    Leave a comment:


  • jlittle
    replied
    Originally posted by wojcieche View Post
    ...will not launch:
    Code:
    Exec=zip.sh %U
    ... need to:
    Code:
    Exec=[B]sh[/B] zip.sh %U
    Assuming the script is executable, and has the shebang, I would ask, where is the script? If it is sitting in the working directory specified in the .desktop file, as I expect given that sh zip.sh works, then there is a path ($PATH) issue. By default the current directory is not in the path. You can avoid the issue by invoking the script with "./" prepended, so, does this work?
    Code:
    Exec=./zip.sh %U

    Leave a comment:


  • Don B. Cilly
    replied
    It should execute directly if
    - It's set to +x (executable) and
    - has #!/bin/bash at the beginning.

    Leave a comment:


  • wojcieche
    replied
    Context/Service menu refresh issue

    Originally posted by MoonRise View Post
    EDIT: Oddly I add that desktop entry to `/.kde/share/kde4/services/ServiceMenus/ but for some reason does not show up even on a reboot. Will play around some, but any feedback?
    Originally posted by vinnywright View Post
    are you running plasma5 ?

    try /home/vinny/.local/share/kservices5/ServiceMenus/ ,,,,,,,of corse change "vinny" to your user name and you may half to make the "kservices5" directory .
    Originally posted by oshunluvr View Post
    ..and rebooting isn't necessary. At the most closing and re-launching Dolphin, but even that shouldn't be necessary. They should be available immediately.
    Hmm, actually the refresh isn't immediate to me in Dolphin (and desktop) on Arch Linux, Plasma 5.16...
    At least when I change Name and Exec inside .desktop file, the command in context menu remains old.
    Does anyone know how to fix it so that refresh is immediate?

    I have discovered a workaround to it though - renaming the .desktop file (you may wish to do it back and forth) refreshes the action in context menu 100% reliably and immediately.
    Interestingly also moving in any direction between the two folders refreshes the context menu:
    /home/we/.local/share/kservices5/ServiceMenus/
    /home/we/.local/share/kservices5/
    because it turns out that .desktop files can be on either of these levels to work.

    Another discrepancy from advice in this thread I have noticed is that such Exec command will not launch a shell script from Service Menu:
    Code:
    Exec=zip.sh %U
    I need to launch a shell command and pass the script filename as parameter:
    Code:
    Exec=[B]sh[/B] zip.sh %U
    I guess this is because I do not have a default program for handling .sh files defined. In any case, it took me hours to identify this was the reason things didn't work for me, so I am sharing this.
    Last edited by wojcieche; Sep 11, 2019, 03:19 PM. Reason: Nothing changed, just turned on displaying smileys in this post.

    Leave a comment:


  • Rog131
    replied
    Remove selected thumbnails

    Part of the thumbnailtools/kenric: https://store.kde.org/p/1080815/ is the 'Remove selected thumbnails'.



    The servicemenu is using same code as the KDE to find the thumbnail names (kthumbnamefinder5):



    Preview clip with the Keneric - Scripting KDE video preview thumbnails:

    Direct: https://youtu.be/L694nghnPo8

    KDE Forums - Scripting KDE video preview thumbnails: https://forum.kde.org/viewtopic.php?...409077#p409077
    Last edited by Rog131; Dec 31, 2018, 07:11 PM.

    Leave a comment:


  • SDG10
    replied
    Originally posted by oshunluvr View Post
    ...
    I tested this here on an image, a libreoffice document, a pdf, and a plain text file. Works for me.
    Thank you very much,
    The script for Nautilus/Caja file managers has some more features than this, in fact it also gives the error message in case of non-printable files, and gives the possibility to print all the printable files contained in a folder simply selecting it ... but after all, your is very good for common needs.
    The only change I made is to put the capital F, which allows you to select and print multiple files.

    [Desktop Entry]
    Actions=print-file
    Icon=print
    MimeType=application/pdf;image/*;application/vnd.oasis.opendocument.text;text/plain;application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.opendocument.presentation;application/msword;application/vnd.ms-word;application/vnd.ms-excel;application/vnd.ms-powerpoint;application/vnd.openxmlformats-officedocument.wordprocessingml.document;applicati on/vnd.openxmlformats-officedocument.spreadsheet.sheet;application/vnd.openxmlformats-officedocument.presentationml.presentation;
    ServiceTypes=KonqPopupMenu/Plugin
    Encoding=UTF-8
    Type=Service
    X-KDE-Priority=TopLevel

    [Desktop Action print-file]
    Exec=lp %F
    Exec=libreoffice -p %F
    Icon=stock_print
    Name=Print
    The following procedure allows you to modify the previous script so that you can specify a different printer than the default one.

    Find the name of the printer you are using by typing in the terminal:
    lpstat -p -d
    Then replace the string 'Samsung-M2020-Series' with the name found using the command lpstat -p -d and 'PrintYourPrinter' with the name of your printer

    [Desktop Entry]
    Actions=print-file
    Icon=print
    MimeType=application/pdf;image/*;application/vnd.oasis.opendocument.text;text/plain;application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.opendocument.presentation;application/msword;application/vnd.ms-word;application/vnd.ms-excel;application/vnd.ms-powerpoint;application/vnd.openxmlformats-officedocument.wordprocessingml.document;applicati on/vnd.openxmlformats-officedocument.spreadsheet.sheet;application/vnd.openxmlformats-officedocument.presentationml.presentation;
    ServiceTypes=KonqPopupMenu/Plugin
    Encoding=UTF-8
    Type=Service
    X-KDE-Priority=TopLevel

    [Desktop Action print-file]
    Exec=lp -P Samsung-M2020-Series %F
    Exec=libreoffice -pt Samsung-M2020-Series %F
    Icon=stock_print
    Name=PrintYourPrinter
    Last edited by SDG10; Sep 15, 2018, 04:23 AM.

    Leave a comment:


  • sithlord48
    replied
    Originally posted by Rog131 View Post
    With the KDE Applications 18.08 (Dolphin) the 'Convert hard coded shortcuts to standard keys' has landed:

    - https://phabricator.kde.org/D11048
    - https://cgit.kde.org/dolphin.git/com...154782664d0835
    That diff looks familiar

    Leave a comment:


  • Rog131
    replied
    Dolphin dbus changes with the KDE Applications 18.08

    With the KDE Applications 18.08 (Dolphin) the 'Convert hard coded shortcuts to standard keys' has landed:

    - https://phabricator.kde.org/D11048
    - https://cgit.kde.org/dolphin.git/com...154782664d0835

    Before - reload:



    qdbus command:
    Code:
    $ qdbus org.kde.dolphin-914 /dolphin/Dolphin_1/actions/reload trigger
    After - redisplay:



    qdbus command:

    Code:
    qdbus org.kde.dolphin-2684 /dolphin/Dolphin_1/actions/view_redisplay trigger

    Leave a comment:


  • GreyGeek
    replied
    A post above gave the URL of a Dolphin PDF service menu:

    A sample: KDE 5 Service Menu PDF - https://store.kde.org/p/1227799/

    I attempted a few weeks ago to install GuiseppeBenigno's KDE 5 Service Menu PDF but no services were added after the install.

    Today I decided to uninstall it and try again. The results were the same. After investigating I found that without warning it would not install because a program, pdftk, was missing from the BIONIC repository and the upstream developers said it wouldn't be installed because it depended upon GJI, a java tool, which was no longer being maintained. Without that file the service menu failed to install.

    Looking around I found the deb package in ~/.local/share/servicemenu-download/kde-service-menu-pdf_1.0_all.deb

    All I needed was to do a workaround to get pdftk installed. I found it here: https://bugs.launchpad.net/ubuntu/+s...450/comments/4
    The following steps failed because it couldn't find gcc-6-base, which IS in the BIONIC repository. After I installed it the following steps installed pdftk:
    Code:
      wget [URL]http://archive.ubuntu.com/ubuntu/pool/universe/p/pdftk/pdftk_2.02-4build1_amd64.deb[/URL]
      wget [URL]http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-6/libgcj17_6.4.0-8ubuntu1_amd64.deb[/URL]
      wget [URL]http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-defaults/libgcj-common_6.4-3ubuntu1_all.deb[/URL]
      sudo dpkg -i pdftk_2.02-4build1_amd64.deb libgcj17_6.4.0-8ubuntu1_amd64.deb libgcj-common_6.4-3ubuntu1_all.deb
    Instead of installing gcc-6-base separately you can make the last line:
    sudo dpkg -i gcc-6-base pdftk_2.02-4build1_amd64.deb libgcj17_6.4.0-8ubuntu1_amd64.deb libgcj-common_6.4-3ubuntu1_all.deb

    With pdftk installed I used Dolphin to browse to and right clicked on kde-service-menu-pdf_1.0_all.deb and let QApt Package Installer install it. Dolphin's service menu options were populated with the services supplied by that deb package.
    Last edited by GreyGeek; Aug 11, 2018, 11:56 AM.

    Leave a comment:


  • Rog131
    replied
    Originally posted by SDG10 View Post
    OK thank you very much ,
    but it's not really the same thing.

    That script can print everything because it contains both the lpr and libreoffice commands, it also gives an error message if you select a non-printable file (eg mp3) and you can have it in the default printer version or you can specify which printer to use, so in the context menu you can get "print with HP" or "Print with Samsung", for instance, and I find this very useful.

    I'm new to Kubuntu and I would like to have the same thing as Ubuntu Mate, if possible.

    Is that too much to ask?
    KDE Service Menus
    ( https://techbase.kde.org/Development..._Service_Menus )

    In KDE-speak a "servicemenu" is a special entry that appears in a context menu (or other context-based interface) for a file (or for directory), depending on the type of files that are selected.
    The KDE context menus are file type specific. You can't print mp3 file from the PDF print menu - If you have in the service menu desktop file:

    Code:
    MimeType=application/pdf


    KDE applications

    If applications are build on the top of the KDE framework then they could have the service menus off the box.

    Calligra Words:

    Code:
    $ calligrawords --help
    calligra.lib.pigment: Legacy integer arithmetics implementation
    Usage: calligrawords [options] [file(s)]
    Word processor
    
    Options:
    -h, --help                       Displays this help.
    .
    .
    .
    --print                          Only print and exit
    .
    .
    .
    Arguments:
    [file(s)]                        File(s) or URL(s) to open
    There is a service menu available off the box...



    Free and open...

    If you want service menus with the non KDE application you could add them yourself as 'oshunluvr' did.

    Libreoffice:
    Code:
    $ libreoffice --help
    LibreOffice 6.0.6.2 00m0(Build:2)
    
    Usage: soffice [argument...]
      argument - switches, switch parameters and document URIs (filenames).
    
    .
    .
    .
    -p                  Prints following files to the default printer, after
                      which those files are closed. The splash screen does
                      not appear. If the file name contains spaces, then it
                      must be enclosed in quotation marks.
    .
    .
    .
    and you could share your service menus with us.

    AskUbuntu - https://askubuntu.com/questions/1405...-odt-documents :
    Code:
    libreoffice --writer -p --headless 'filename1' 'filename2'
    Last edited by Rog131; Aug 11, 2018, 10:25 AM.

    Leave a comment:


  • oshunluvr
    replied
    You can either install Caja to your system and use their script and Caja. Or if you want to stick to Dolphin, then rewrite the script to use the correct print commands for KDE ("lp" for plain files and "libreoffice -p" for office files) or you can just write your own servicemenu desktop files and put them in ~/.local/share/kservices5/ServiceMenus/.

    Here's a start for you; If you have libreoffice installed, it will print almost anything from the command line. It will use it's default print settings. Create a file from the code below and put it in ~/.local/share/kservices5/ServiceMenus/ and try it out:
    Code:
    [Desktop Entry]
    Actions=print-file
    Icon=print
    MimeType=application/pdf;image/*;application/vnd.oasis.opendocument.text;text/plain;application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.opendocument.presentation;application/msword;application/vnd.ms-word;application/vnd.ms-excel;application/vnd.ms-powerpoint;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/vnd.openxmlformats-officedocument.spreadsheet.sheet;application/vnd.openxmlformats-officedocument.presentationml.presentation;
    ServiceTypes=KonqPopupMenu/Plugin
    Encoding=UTF-8
    Type=Service
    X-KDE-Priority=TopLevel
    
    
    [Desktop Action print-file]
    Exec=lp %f
    Exec=libreoffice -p %f 
    Icon=stock_print
    Name=Print Now
    I tested this here on an image, a libreoffice document, a pdf, and a plain text file. Works for me.

    Leave a comment:


  • SDG10
    replied
    OK thank you very much ,
    but it's not really the same thing.

    That script can print everything because it contains both the lpr and libreoffice commands, it also gives an error message if you select a non-printable file (eg mp3) and you can have it in the default printer version or you can specify which printer to use, so in the context menu you can get "print with HP" or "Print with Samsung", for instance, and I find this very useful.

    I'm new to Kubuntu and I would like to have the same thing as Ubuntu Mate, if possible.

    Is that too much to ask?

    Leave a comment:


  • Rog131
    replied
    Originally posted by SDG10 View Post
    Can you make these scripts work in the dolphin menu?
    They are used to print the selected files without first opening them.
    They work in nautilus and derived file managers, but I do not know how to make them work in Kubuntu.

    https://ubuntu-mate.community/t/prin...-in-caja/15885

    Thanks
    There is no need 'to carry coals to Newcastle': https://idioms.thefreedictionary.com...s+to+Newcastle.

    A bit easier is to search from the KDE Store:

    The KDE Store: https://store.kde.org
    Dolphin Service Menus: https://store.kde.org/browse/cat/102/

    Searching - Search results for "pdf": https://store.kde.org/search/projectSearchText/pdf/

    A sample: KDE 5 Service Menu PDF - https://store.kde.org/p/1227799/

    Editing a bit (*)- Only adding the option to print selected files without first opening them:



    (*)
    1) Unpacking the 'kde-service-menu-pdf_1.0_all.tar.gz'
    2) Copying the executable 'pdfprint-kdialog' (**) to the $PATH.
    3) Adding a desktop file - pdfprintfiles.desktop:
    Code:
    [Desktop Entry]
    Type=Service
    Icon=printer
    X-KDE-ServiceTypes=KonqPopupMenu/Plugin
    MimeType=application/pdf
    Actions=printPdfFiles;
    X-KDE-Submenu=Pdf Print
    Encoding=UTF-8
    
    [Desktop Action printPdfFiles]
    Icon=printer
    Name=Print selected documents
    Name[de]=Ausgewählte Dokumente drucken
    Name[fr]=Imprimer les documents sélectionnés
    Name[it]=Stampa i documenti selezionati
    Name[ru]=Распечатать выбранные документы
    Exec=pdfprint-kdialog %F
    to the $HOME/.local/share/kservices5/ServiceMenus/

    (**)
    Though the script has name, pdfprint-kdialog, it will print other file types with the lpr if the user wants to.
    Last edited by Rog131; Aug 10, 2018, 03:27 PM.

    Leave a comment:


  • SDG10
    replied
    Can you make these scripts work in the dolphin menu?
    They are used to print the selected files without first opening them.
    They work in nautilus and derived file managers, but I do not know how to make them work in Kubuntu.

    https://ubuntu-mate.community/t/prin...-in-caja/15885

    Thanks

    Leave a comment:

Users Viewing This Topic

Collapse

There are 0 users viewing this topic.

Working...
X