Last active
August 29, 2015 14:14
-
-
Save shadowbq/43af562fffb02facf153 to your computer and use it in GitHub Desktop.
Zenity (Gnome) Shell popup to show Exif data or Hash files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
AppVer="1.0.1-shadowbq" | |
if [ "$1" = "" ]; then | |
SelectedFile=`zenity --title="Choose a file to check" --file-selection` | |
fi | |
if [ "$SelectedFile" = "" ]; then | |
if [ $# -gt 1 ]; then | |
zenity --error --text="You must select one file only!" | |
exit 1 | |
fi | |
if [ "$1" = "" ]; then | |
exit 1 | |
fi | |
fi | |
if [ -d "$1" ]; then | |
zenity --error --text="<b>$1</b> is a folder. | |
This script cannot work with folders!" | |
exit 1 | |
fi | |
if [ "$SelectedFile" = "" ]; then | |
SelectedFile="$1" | |
fi | |
SelectedFileNameFix="${SelectedFile//'&'/&}" # Fix for ampersand simbol | |
if [ `stat --printf="%s" "$SelectedFile"` = "0" ]; then | |
zenity --warning --text="<b>$SelectedFileNameFix</b> has 0 bytes! | |
Checking Exif of this file is pointless!" | |
exit 1 | |
fi | |
if [ -d "${SelectedFile%/*}" ]; then # Check if dir or file | |
FileNoPath="${SelectedFileNameFix##*/}" | |
FilePath="${SelectedFile%/*}/" # md5sum, sha1sum and sha256sum need file path | |
else | |
FileNoPath="$SelectedFileNameFix" | |
FilePath="./" # md5sum, sha1sum and sha256sum need file path | |
fi | |
if ! [ -e "$SelectedFile" ]; then | |
zenity --error --text "Cannot find <b>$FileNoPath</b> file!\nFile is either renamed, moved or removed!" | |
exit 1 | |
fi | |
zenity --info --title="Exif Checker $AppVer" --no-wrap --text="File: <b>$FileNoPath</b> | |
\n`identify -format \"%[exif:*time*]\" \"$SelectedFile\"`" | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ============================================================================================================================================================= # | |
# Hash Checker script for md5/sha1/sha256 hashes, version 4.0.7 by Cooleech | |
# e-mail to: [email protected] | |
# English by Cooleech | |
# ============================================================================================================================================================= # | |
AppVer="4.0.8-shadowbq" | |
HConFile="$HOME/.HashCheck/HC.conf" | |
SavedSettings=`cat $HConFile` | |
which xdg-user-dirs-update | |
if [ $? = 0 ]; then | |
. ~/.config/user-dirs.dirs # Import variables | |
fi | |
# Set desktop icon dir | |
if [ "$XDG_DESKTOP_DIR" = "" ]; then | |
if [ -d "$HOME/Desktop" ]; then | |
XDG_DESKTOP_DIR="$HOME/Desktop" | |
else | |
XDG_DESKTOP_DIR="$HOME" | |
fi | |
fi | |
if [ -e $HConFile ]; then | |
. $HConFile # Import variables | |
fi | |
if [ "$1" = "" ]; then | |
SelectedFile=`zenity --title="Choose a file to check" --file-selection` | |
fi | |
if [ "$SelectedFile" = "" ]; then | |
if [ $# -gt 1 ]; then | |
zenity --error --text="You must select one file only!" | |
exit 1 | |
fi | |
if [ "$1" = "" ]; then | |
exit 1 | |
fi | |
fi | |
if [ -d "$1" ]; then | |
zenity --error --text="<b>$1</b> is a folder. | |
This script cannot work with folders!" | |
exit 1 | |
fi | |
if [ "$SelectedFile" = "" ]; then | |
SelectedFile="$1" | |
fi | |
SelectedFileNameFix="${SelectedFile//'&'/&}" # Fix for ampersand simbol | |
if [ `stat --printf="%s" "$SelectedFile"` = "0" ]; then | |
zenity --warning --text="<b>$SelectedFileNameFix</b> has 0 bytes! | |
Checking hash of this file is pointless!" | |
exit 1 | |
fi | |
if [ -d "${SelectedFile%/*}" ]; then # Check if dir or file | |
FileNoPath="${SelectedFileNameFix##*/}" | |
FilePath="${SelectedFile%/*}/" # md5sum, sha1sum and sha256sum need file path | |
else | |
FileNoPath="$SelectedFileNameFix" | |
FilePath="./" # md5sum, sha1sum and sha256sum need file path | |
fi | |
function DELETE_OLD_HASH_FILE { | |
zenity --question --title="Hash Checker $AppVer" --text="Found old hash file:\n<b>$FileNoPath$HashFile</b>\n\nWould you like to delete it (recommended)?" \ | |
--cancel-label="_Keep it" --ok-label="_Delete it" | |
if [ $? = 0 ]; then | |
rm -f "$SelectedFile$HashFile" # Must keep path | |
fi | |
} | |
if [ -e "$SelectedFile".md5sum ]; then # Must keep path | |
HashFile=".md5sum" | |
DELETE_OLD_HASH_FILE | |
fi | |
if [ -e "$SelectedFile".sha1sum ]; then # Must keep path | |
HashFile=".sha1sum" | |
DELETE_OLD_HASH_FILE | |
fi | |
if [ -e "$SelectedFile".sha256sum ]; then # Must keep path | |
HashFile=".sha256sum" | |
DELETE_OLD_HASH_FILE | |
fi | |
# Get last states | |
if [ "$MD5_HASH_CHECKED" = "" ]; then | |
MD5state="TRUE" | |
else | |
MD5state="$MD5_HASH_CHECKED" | |
fi | |
if [ "$SHA1_HASH_CHECKED" = "" ]; then | |
SHA1state="FALSE" | |
else | |
SHA1state="$SHA1_HASH_CHECKED" | |
fi | |
if [ "$SHA256_HASH_CHECKED" = "" ]; then | |
SHA256state="FALSE" | |
else | |
SHA256state="$SHA256_HASH_CHECKED" | |
fi | |
if [ "$SAVE_TO_TEXT_FILE" = "" ]; then | |
TextFileState="FALSE" | |
else | |
TextFileState="$SAVE_TO_TEXT_FILE" | |
fi | |
TypeOfHash="MD5|SHA1|SHA256" | |
if ! [ -e "$SelectedFile" ]; then | |
zenity --error --text "Cannot find <b>$FileNoPath</b> file!\nFile is either renamed, moved or removed!" | |
exit 1 | |
fi | |
echo $TypeOfHash | |
# Reset all | |
MD5state="FALSE" | |
SHA1state="FALSE" | |
SHA256state="FALSE" | |
TextFileState="FALSE" | |
case $TypeOfHash in | |
MD5*) # MD5 with any other | |
MD5state="TRUE" | |
( | |
echo "# Checking MD5 hash. Depending on '$FileNoPath' file size,\ndisc and CPU speed, it could take up to several minutes. Please wait..." | |
openssl md5 "$SelectedFile" |grep -o '= .*' > /tmp/"$FileNoPath".md5sum | |
) | zenity --width="400" --progress --title="Checking MD5 hash" --text="" --percentage=0 --auto-close --pulsate | |
esac | |
case $TypeOfHash in | |
*SHA1*) # SHA1 with any other | |
SHA1state="TRUE" | |
( | |
echo "# Checking SHA1 hash. Depending on '$FileNoPath' file size,\ndisc and CPU speed, it could take up to several minutes. Please wait..." | |
openssl sha1 "$SelectedFile" |grep -o '= .*' > /tmp/"$FileNoPath".sha1sum | |
) | zenity --width="400" --progress --title="Checking SHA1 hash" --text="" --percentage=0 --auto-close --pulsate | |
esac | |
case $TypeOfHash in | |
*SHA256*) # SHA256 with any other | |
SHA256state="TRUE" | |
( | |
echo "# Checking SHA256 hash. Depending on '$FileNoPath' file size,\ndisc and CPU speed, it could take up to several minutes. Please wait..." | |
openssl sha256 "$SelectedFile" |grep -o '= .*' > /tmp/"$FileNoPath".sha256sum | |
) | zenity --width="400" --progress --title="Checking SHA256 hash" --text="" --percentage=0 --auto-close --pulsate | |
esac | |
case $TypeOfHash in | |
*Save*) # Save in text file with any other | |
TextFileState="TRUE" | |
esac | |
case $TypeOfHash in | |
Save*) # Save in text file only | |
exit 1 | |
esac | |
case $TypeOfHash in | |
"") # No selection | |
exit 1 | |
esac | |
CurrentSettings="# HASH CHECKER SETTINGS | |
MD5_HASH_CHECKED=$MD5state | |
SHA1_HASH_CHECKED=$SHA1state | |
SHA256_HASH_CHECKED=$SHA256state | |
SAVE_TO_TEXT_FILE=$TextFileState" | |
if [ ! "$SavedSettings" = "$CurrentSettings" ]; then | |
echo "$CurrentSettings" > $HConFile | |
fi | |
if [ -e /tmp/"$FileNoPath".md5sum ]; then | |
MD5hash=`cat /tmp/"$FileNoPath".md5sum` | |
MD5WithoutPath="${MD5hash%% $SelectedFile}" | |
else | |
MD5WithoutPath="N/A" | |
fi | |
if [ -e /tmp/"$FileNoPath".sha1sum ]; then | |
SHA1hash=`cat /tmp/"$FileNoPath".sha1sum` | |
SHA1WithoutPath="${SHA1hash%% $SelectedFile}" | |
else | |
SHA1WithoutPath="N/A" | |
fi | |
if [ -e /tmp/"$FileNoPath".sha256sum ]; then | |
SHA256hash=`cat /tmp/"$FileNoPath".sha256sum` | |
SHA256WithoutPath="${SHA256hash%% $SelectedFile}" | |
else | |
SHA256WithoutPath="N/A" | |
fi | |
if [ "$TextFileState" = "TRUE" ]; then | |
if [ -e /tmp/"$FileNoPath".md5sum ]; then | |
md5hashFile=`cat /tmp/"$FileNoPath".md5sum` | |
echo "$md5hashFile" >> "$SelectedFile".md5sum | |
fi | |
if [ -e /tmp/"$FileNoPath".sha1sum ]; then | |
sha1hashFile=`cat /tmp/"$FileNoPath".sha1sum` | |
echo "$sha1hashFile" >> "$SelectedFile".sha1sum | |
fi | |
if [ -e /tmp/"$FileNoPath".sha256sum ]; then | |
sha256hashFile=`cat /tmp/"$FileNoPath".sha256sum` | |
echo "$sha256hashFile" >> "$SelectedFile".sha256sum | |
fi | |
fi | |
zenity --info --title="Hash Checker $AppVer" --no-wrap --text="File: <b>$FileNoPath</b> | |
\nMD5 hash: <b>$MD5WithoutPath</b>\nSHA1 hash: <b>$SHA1WithoutPath</b>\nSHA256 hash: <b>$SHA256WithoutPath</b>" | |
# Cleanup /tmp | |
if [ -e /tmp/"$FileNoPath".md5sum ]; then | |
rm -f /tmp/"$FileNoPath".md5sum | |
fi | |
if [ -e /tmp/"$FileNoPath".sha1sum ]; then | |
rm -f /tmp/"$FileNoPath".sha1sum | |
fi | |
if [ -e /tmp/"$FileNoPath".sha256sum ]; then | |
rm -f /tmp/"$FileNoPath".sha256sum | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment