Next: GUI for SECurity

GUI for SECurity

Create a file called security.sh under ~/myscript directory
 
#!/bin/bash

unsecAction()
{
  retValue=$(zenity --password   --title="SECurity")
  
  case $? in
      0)
		 	password=$(echo $retValue | cut -d'|' -f1) 
		 	~/bin/security $fileSec $password
			;;
	  1)
            endmenu
            ;;
     -1)
		    endmenu
		   ;;
  esac  
	  
   
}

secAction()
{
  retValue=$(zenity --forms --title="SECurity" --text="Add a security password" --add-password="Password" --add-password="Re-password" )
  
  case $? in
      0)
		 	password1=$(echo $retValue | cut -d'|' -f1)
		 	password2=$(echo $retValue | cut -d'|' -f2) 
		 	
		 	if [ $password1 == $password2 ]
            then         
              ~/bin/security $fileSec $password1           
            else
              zenity --info --text="Different Passwords" 
              secAction       
            fi		 	
			;;
	  1)
            endmenu
            ;;
     -1)
		    endmenu
		   ;;
  esac  
	  
   
}

endmenu() {
  echo "Bye bye."
  exit 0;
}


mainmenu() 
{
 declare -i count
 count=0
 
 IFS=$(echo -en "\n\b")
 read -ra files <<< "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" 
   
 for file in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
 do
     let count++
 done
 
 
 
 if [ $count -gt 1 ]
 then
   zenity --info --text="Select only one file"
 else
 
   if [ -f $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS ]
   then
       ext="${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS##*.}"
       fileSec=$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
       
       if [ $ext == "sec" ]
       then         
         unsecAction           
       else
        secAction        
       fi
	      
   else
	   zenity --info --text="Select a file. It's a directory"   
   fi 
 fi
}

mainmenu

create a link of security.sh file called SECurity
and move it under ~/.local/share/nautilus/scripts

run the command 

chmod +x ~/myscript/security.sh
chmod +x ~/.local/share/nautilus/scripts/SECurity

Now when you open the context menu you will see:




Now download this file (security) from  here   
and put under ~/bin directory

then run the command:

chmod +x ~/bin/security