Announcement

Collapse
No announcement yet.

Disable Trash / KGPG Default Setting / Context Menu

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

    #16
    Re: Disable Trash / KGPG Default Setting / Context Menu

    Hmm - myencryptfolder.desktop is alpha ( )version. It is works only with small folders. If there is larger folder, gpg starts before ark (zip) is finished.

    myencryptfolder.desktop (versio 0.00002) :
    Code:
    [Desktop Entry]
    ServiceTypes=inode/directory
    Actions=MYencrypt
    
    [Desktop Action MYencrypt]
    Name=Archive & Encrypt Folder (GPG)
    Icon=gpg
    Exec=myfolderencrypter %U
    myfolderencrypter script:
    Code:
    #!/bin/sh
    
    # killing ark prosesses
    kill `ps -e | awk '/ark/ { print $1 }'`
    
    # packing folder
    ark --add-to $1 $1.zip
    
    # waiting ark to shut down
    while [ `ps -e | grep ark | wc -l` -gt 0 ]
    do
      sleep 1
    done
    
    # encrypting zip package
    gpg -c $1.zip
    
    # removing zip package
    rm -f $1.zip
    Note
    - Make script file
    - Make it executable.
    - Drop it in the /usr/bin/
    - It is clumsy way (first in the mind) to do this


    Example, decrypting and extracting

    mydecrypt.desktop:
    Code:
    [Desktop Entry]
    ServiceTypes=all/allfiles
    ExcludeServiceTypes=kdedevice/*
    Actions=MYdecrypt
    
    [Desktop Action MYdecrypt]
    Name=Decrypt & Unzip (GPG)
    Icon=gpg
    Exec=decrypter %U
    decrypter script:
    Code:
    #!/bin/sh
    
    # Where is the new subfolder
    WHERE=`kdialog --getexistingdirectory ~/`
    
    # removing .gpg extension
    PACKAGE=`echo $1 | sed s/".gpg"//g`
    
    # decrypting package
    gpg -d $1 > $PACKAGE
    
    # unpacking to the new subfolder
    unzip $PACKAGE -d $WHERE

    Note #1
    This service menu, script-file pair will ask where to decrypt/unpack. It is using KDE dialogs:

    Shell Scripting with KDE dialogs
    http://developer.kde.org/documentati...dialog/t1.html

    Note #2
    These seem to work . Testing needed !


    Links:
    Bash Reference Manual
    http://www.gnu.org/software/bash/manual/bashref.html

    The GNU Awk User's Guide
    http://www.gnu.org/software/gawk/manual/gawk.html

    DashAsBinSh
    https://wiki.ubuntu.com/DashAsBinSh

    man pages
    Before you edit, BACKUP !

    Why there are dead links ?
    1. Thread: Please explain how to access old kubuntu forum posts
    2. Thread: Lost Information

    Comment


      #17
      Re: Disable Trash / KGPG Default Setting / Context Menu



      Cool, that works pretty good!

      It has only a problem with spaces in the file/folder name (please see attachment). I guess the name is cut somehow, but I don't understand why. "ark --add-to $1 $1.zip" from where does $1 come? I guess there is the mistake..?

      I added this to my /usr/share/apps/d3lphin/servicemenus/ folder
      myencryptfile.desktop
      Code:
      [Desktop Entry]
      ServiceTypes=all/allfiles
      Actions=MYencrypt
      
      [Desktop Action MYencrypt]
      Name=Archive & Encrypt File (GPG)
      Icon=gpg
      Exec=myfolderencrypter %U
      I guess the same argument for big folders are true for big files.

      Is it possible to show the "decrypt"-servicemenu entry only by an GPG extension? Right now it will shown by every extension.

      Those scripts should be standard in KDE at least in Kubuntu. I think this would encourage more ppl to use encryption. I will make a proposal (when I found the place to do this ).

      Great work Rog131!!


      Attached Files

      Comment


        #18
        Re: Disable Trash / KGPG Default Setting / Context Menu

        "ark --add-to $1 $1.zip" from where does $1 come?
        $1 (and $2, $3...) =>

        Howto read command line arguments in a bash script
        http://howto.wikia.com/wiki/Howto_re..._a_bash_script


        Is it possible to show the "decrypt"-servicemenu entry only by an GPG extension?
        Should be:
        Creating Konqueror Service Menus
        http://developer.kde.org/documentati...vicemenus.html

        For images (png, jpeg):

        Code:
        [Desktop Entry]
        ServiceTypes=image/png,image/jpeg
        but i can't find what is working with gpg's (tried encrypted/gpg, application/gpg...)

        File associations: Control Centre (kcontrol) > KDE Components > File Associations -> .gpg...


        Where that error came ?
        Before you edit, BACKUP !

        Why there are dead links ?
        1. Thread: Please explain how to access old kubuntu forum posts
        2. Thread: Lost Information

        Comment


          #19
          Re: Disable Trash / KGPG Default Setting / Context Menu

          The error comes straight after you try to use the "archive & encrypt" service with a file or folder name which contains a space...

          Is it because "kill `ps -e | awk '/ark/ { print $1 }'`" prints no spaces (that's a general problem with Linux, right?)?

          Comment


            #20
            Re: Disable Trash / KGPG Default Setting / Context Menu

            Is it because "kill `ps -e | awk '/ark/ { print $1 }'`" prints no spaces (that's a general problem with Linux, right?)?
            Yes and no .

            That line is for killing ark prosesses. It is working. The problem is:
            Example - trying to pack and encrypt folder A 012:
            Code:
            myfolderencrypter /media/sda6/tmp/A 012
            -> myfolderencrypter is trying to process folder /media/sda6/tmp/A

            fix:
            Code:
            myfolderencrypter "/media/sda6/tmp/A 012"
            Same thing with "$1" and "$U"

            So:
            myencryptfile.desktop needs:
            Code:
            Exec=myfolderencrypter "%U"
            and in the myfolderencrypter:
            Code:
            ark --add-to "$1" "$1.zip"

            A quick guide to writing scripts using the bash shell
            http://www.panix.com/~elflord/unix/bash-tute.html
            while I have quotes in my example, they are not always necessary. where you need quotes is when your variable names include spaces. For example,

            X=hello world # error
            X="hello world" # OK
            Before you edit, BACKUP !

            Why there are dead links ?
            1. Thread: Please explain how to access old kubuntu forum posts
            2. Thread: Lost Information

            Comment


              #21
              Re: Disable Trash / KGPG Default Setting / Context Menu



              Now the compressing part works, but not the encrypting part. I'll have a look later into this, I'm short in time right now.

              Update
              ====
              Got it:

              You have to add this to the "myfolderencrypter" located in "/usr/bin"
              Code:
              # encrypting zip package
              gpg -c "$1.zip"
              
              # removing zip package
              rm -f "$1.zip"
              The only thing that is missing is to show the decrypt menu entry only to encrypted files and the encrypt entry only to files who are actually not encrypted. I'll try to figure that out later.

              Thanks Rog131! You helped me here a lot and I really appreciate that. Kubuntu is indeed way better than Ubuntu

              Comment


                #22
                Re: Disable Trash / KGPG Default Setting / Context Menu

                I've updated the scripts from Rog131 a little bit.

                /usr/bin/decrypter
                Code:
                #!/bin/sh
                
                # Where is the new subfolder
                WHERE=`kdialog --getexistingdirectory ~/`
                
                # removing .gpg extension
                PACKAGE=`echo $1 | sed s/".gpg"//g`
                
                # decrypting package
                gpg -d "$1" > "$PACKAGE"
                
                # unpacking to the new subfolder
                unzip "$PACKAGE" -d "$WHERE"
                
                while [ `ps -e | grep unzip | wc -l` -gt 0 ]
                do
                  sleep 1
                done
                
                # removing zip package
                rm -f "$PACKAGE"
                /usr/bin/myfolderencrypter
                Code:
                #!/bin/sh
                
                # killing ark prosesses
                kill `ps -e | awk '/ark/ { print $1 }'`
                
                # packing folder
                ark --add-to "$1" "$1.zip"
                
                # waiting ark to shut down
                while [ `ps -e | grep ark | wc -l` -gt 0 ]
                do
                  sleep 1
                done
                
                # encrypting zip package
                gpg -c "$1.zip"
                
                # removing zip package
                rm -f "$1.zip"
                /usr/share/apps/d3lphin/servicemenus/mydecrypt.desktop
                Code:
                [Desktop Entry]
                ServiceTypes=all/allfiles
                ExcludeServiceTypes=kdedevice/*
                Actions=MYdecrypt
                
                [Desktop Action MYdecrypt]
                Name=Decrypt and Unzip (GPG)
                Icon=gpg
                Exec=decrypter "%U"
                /usr/share/apps/d3lphin/servicemenus/myencryptfile.desktop
                Code:
                [Desktop Entry]
                ServiceTypes=all/allfiles
                Actions=MYencrypt
                
                [Desktop Action MYencrypt]
                Name=Archive and Encrypt File (GPG)
                Icon=gpg
                Exec=myfolderencrypter "%U"
                /usr/share/apps/d3lphin/servicemenus/myencryptfolder.desktop
                Code:
                [Desktop Entry]
                ServiceTypes=inode/directory
                Actions=MYencrypt
                
                [Desktop Action MYencrypt]
                Name=Archive and Encrypt Folder (GPG)
                Icon=gpg
                Exec=myfolderencrypter "%U"

                Open Issues
                ------------------
                * I wasn't able to find a solution to show the encrypt/decrypt servicemenu entry only to uncrypted/encrypted files. There is the "application/x-kgpg" as a MIME-type, but that does somehow not work
                * I would like to have a check if the file/folder already exists while decrypting/encrypting

                Comment


                  #23
                  Re: Disable Trash / KGPG Default Setting / Context Menu

                  Here is example with a check if the file/folder exists.

                  Encrypting:




                  Decrypting:




                  cryptic.desktop:
                  Code:
                  [Desktop Entry]
                  ServiceTypes=all/allfiles,inode/directory
                  Actions=Encrypt;Decrypt;
                  Encoding=UTF-8
                  X-KDE-Submenu=Encrypt and Decrypt
                  
                  [Desktop Action Encrypt]
                  Type=Application
                  Name=Pack and Encrypt (GPG)
                  Icon=forward
                  Exec=encrypter "%U"
                  
                  [Desktop Action Decrypt]
                  Type=Application
                  Name=Decrypt and Unpack (GPG)
                  Icon=back
                  Exec=decrypter "%U"
                  Note #1
                  You need to edit edcrypter and decrypter scripts. There is:
                  # temporary workdirectory
                  WORKDIR="/home/YOURNAMEHERE/temp"
                  Note #2
                  It seems to work


                  encrypter and decrypter scripts:
                  Attached Files
                  Before you edit, BACKUP !

                  Why there are dead links ?
                  1. Thread: Please explain how to access old kubuntu forum posts
                  2. Thread: Lost Information

                  Comment


                    #24
                    Re: Disable Trash / KGPG Default Setting / Context Menu

                    Hi Rog131

                    Thank you for this! I just changed the temporary directory to "/tmp/".

                    Right now I've not enough time to look into this, but it seems to me the decrypt function does not work. None of the options are working and the question is always coming up, even if there is no file/folder with the same name.

                    I'll test it further tomorrow and maybe I'll find even the bug...

                    Comment


                      #25
                      Re: Disable Trash / KGPG Default Setting / Context Menu

                      Thank you for this! I just changed the temporary directory to "/tmp/".
                      You can use /tmp but not /tmp/ !. Scripts are making temporary folders: /path/something#. # is timestamp (date +%s -> now it is 1202066658)

                      DATE(1) User Commands DATE(1)

                      NAME
                      date - print or set the system date and time

                      SYNOPSIS
                      date [OPTION]... [+FORMAT]
                      date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

                      DESCRIPTION
                      Display the current time in the given FORMAT, or set the system date.
                      %s seconds since 1970-01-01 00:00:00 UTC

                      Note
                      Scripts last step is to REMOVE tempory folder !
                      Before you edit, BACKUP !

                      Why there are dead links ?
                      1. Thread: Please explain how to access old kubuntu forum posts
                      2. Thread: Lost Information

                      Comment


                        #26
                        Re: Disable Trash / KGPG Default Setting / Context Menu

                        Ok. I changed it to "/home/user/temp"

                        Now the decryption works almost perfectly. I've two issues so far. One is the overwriting does not work properly and I get an old timestamp (2005-09-10 04:25) by the unpacked files and even if I create new files...

                        Gotta go now. Sorry.

                        Comment

                        Working...
                        X