Skip to content

Instantly share code, notes, and snippets.

@laerreal
Last active May 14, 2019 10:58
Show Gist options
  • Save laerreal/4ee3b4107409f3df408dfeb6b9245786 to your computer and use it in GitHub Desktop.
Save laerreal/4ee3b4107409f3df408dfeb6b9245786 to your computer and use it in GitHub Desktop.
Tcl/Tk GUI for sha1sum
#!/bin/sh
#\
exec wish "$0" "$@"
wm title . "sha1sum front-end"
for {set i 0} {$i < $argc} {incr i} {
set file [lindex $argv $i]
# label ".lab$i" -text "Computing SHA1 of $file..."
global "var$i"
set "var$i" "Computing SHA1 of $file..."
entry ".lab$i" -state readonly -textvariable "var$i" -width [string length [set "var$i"]]
pack ".lab$i" -fill x -side top
set io "sha1io$i"
set $io [open "|sha1sum $file" r]
fconfigure [set $io] -blocking false
set update_code "
global var$i
# puts \"Update\"
set read \[gets [set $io] sha1\]
# puts \$read
if {\$read > 0} {
# puts \"\$sha1\"
# .lab$i configure -text \"\$sha1\"
set var$i \"\$sha1\"
.lab$i configure -width \$read
} else {
after 100 update$i
}
"
# puts $update_code
proc "update$i" {} $update_code
after 100 "update$i"
}
@laerreal
Copy link
Author

Designed to be a Nautilus script ($HOME/.local/share/nautilus/scripts).
It can be applied to set of selected files.

Рабочее место 1_121

sha1sum front-end_118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment