Announcement

Collapse
No announcement yet.

Another Dolphin/konqueror ServiceMenu

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

    Another Dolphin/konqueror ServiceMenu

    Here is another of my servicemenu idea's. I use the command line clamscan virus scanner to do my virus scanning. I like it because it seems quicker than bulky GUI virus tools. This servicemenu gives you a Dolphin / Konqueror right-click Action menu to scan selected files and directories. You will need to install kde-baseapps-bin for kdialog and clamav for clamscan.

    Put this file in /usr/share/kde4/services/ServiceMenus/clamav_clamscan.desktop

    Code:
    [Desktop Entry]
    Actions=ClamScan;
    Type=Service
    ServiceTypes=KonqPopupMenu/Plugin
    MimeType=all/all;
    
    [Desktop Action ClamScan]
    Exec=ClamScan %F
    Name=Perform Virus Scan on file
    Icon=/usr/share/icons/hicolor/48x48/apps/clam48.png
    And put this in a script called ClamScan and put the script in your path e.g. $HOME/bin or /usr/local/bin make sure it's executable

    Code:
    #!/bin/bash
    # ClamScan script
    # this script can be called from a servicemenu file or from the command prompt
    # Usage: ClamScan [file1|directory1] [file2|directory2] ...
    
    #Set your clamscan options here
    DIROPTS="--recursive=yes --bell --infected --cross-fs=no"
    FILEOPTS="--bell"
    
    # ClamScan some stuff
    while [[ "$1" ]];do
      target="$1"
      shift
      target_name="$(basename ${target})"
      if (test -f "${target}");then
            kdialog --title "ClamScan file ${target_name}" --msgbox "$(/usr/bin/clamscan $FILEOPTS ${target})" &
      else
            if (test -d "${target}");then
              kdialog --title "ClamScan directory ${target_name}" --msgbox "$(/usr/bin/clamscan ${DIROPTS} "${target}")" &
            else
              kdialog --title "  Usage  ERROR  " --msgbox "Select only files or directories to scan." &
            fi
      fi
    done
    EDIT: Selecting files or directories with spaces in the name probably will not work.
    Last edited by #!/bin/bash; May 18, 2012, 08:09 PM.
Working...
X