mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-11-12 15:56:28 +00:00
fixes to tomb-status
This commit is contained in:
parent
12f92e7aef
commit
23244bdedd
@ -1,4 +1,4 @@
|
|||||||
#!/bin/zsh
|
#!/bin/zsh -x
|
||||||
#
|
#
|
||||||
# Tomb, the Crypto Undertaker
|
# Tomb, the Crypto Undertaker
|
||||||
#
|
#
|
||||||
@ -23,47 +23,62 @@
|
|||||||
# startup wrapper to open tombs
|
# startup wrapper to open tombs
|
||||||
|
|
||||||
|
|
||||||
|
echo "arg: $1"
|
||||||
|
|
||||||
try() {
|
try() {
|
||||||
which ${1} > /dev/null
|
which ${1} > /dev/null
|
||||||
if [ $? = 0 ]; then return 0;
|
if [ $? = 0 ]; then return 0;
|
||||||
else return -1; fi
|
else return -1; fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# if no arguments are given, run in terminal
|
|
||||||
if [ -z $1 ]; then
|
|
||||||
try gnome-terminal; if [ $? = 0 ]; then gnome-terminal -e "tomb-open create"; exit 0; fi
|
|
||||||
try lxterm; if [ $? = 0 ]; then lxterm -bg black -fg white -e "tomb-open create"; exit 0; fi
|
# got an argument
|
||||||
try urxvt; if [ $? = 0 ]; then urxvt -bg black -fg white -e "tomb-open create"; exit 0; fi
|
if [ $1 ]; then
|
||||||
try uxterm; if [ $? = 0 ]; then uxterm -bg black -fg white -e "tomb-open create"; exit 0; fi
|
# is it a tomb?
|
||||||
try xterm; if [ $? = 0 ]; then xterm -bg black -fg white -e "tomb-open create"; exit 0; fi
|
arg="${1%%\.*}.tomb"
|
||||||
|
|
||||||
|
if [ -f $arg ]; then
|
||||||
|
file $arg | grep LUKS
|
||||||
|
|
||||||
|
if [ $? = 0 ]; then # tomb is a valid LUKS file
|
||||||
|
|
||||||
|
tomb mount $arg
|
||||||
|
|
||||||
|
if [ $? = 0 ]; then # mount was succesfull (with password and all)
|
||||||
|
# strip extension if there
|
||||||
|
tombname="${arg%%.*}"
|
||||||
|
tombmap=`mount -l | awk "/\[${tombname}\]$/"' { print $1 } '`
|
||||||
|
tombmount=`mount -l | awk "/\[${tombname}\]$/"' { print $3 } '`
|
||||||
|
tomb-status $tombmap $tombname $tombmount &!
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
tomb notify "Tomb cannot open." "Are you knocking the wrong door?"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# got a directory as argument
|
|
||||||
if [ -d $1 ]; then
|
|
||||||
# FIXME: somehow xdg-open loses mailcap mimes when executed by tomb-status
|
|
||||||
# try xdg-open; if [ $? = 0 ]; then xdg-open ${1}; exit 0; fi
|
|
||||||
try gnome-open; if [ $? = 0 ]; then gnome-open ${1}; exit 0; fi
|
|
||||||
try thunar; if [ $? = 0 ]; then thunar ${1}; exit 0; fi
|
|
||||||
try rox; if [ $? = 0 ]; then rox ${1}; exit 0; fi
|
|
||||||
try fsviewer; if [ $? = 0 ]; then fsviewer ${1}; exit 0; fi
|
|
||||||
try xnc; if [ $? = 0 ]; then xnc ${1}; exit 0; fi
|
|
||||||
tomb notify "File manager not found." "Tomb cannot guess which filemanager you are using"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# got a tomb as argument?
|
|
||||||
if [ -f $1 ]; then
|
|
||||||
file $1 | grep LUKS
|
|
||||||
if [ $? = 0 ]; then
|
|
||||||
tomb mount $1
|
|
||||||
exit $?
|
|
||||||
else
|
else
|
||||||
tomb notify "Not a real Tomb." "We found no real bones in there."
|
tomb notify "Not a real Tomb." "We found no real bones in there."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
elif [ -d $1 ]; then
|
||||||
|
# its a directory
|
||||||
|
|
||||||
|
# FIXME: somehow xdg-open loses mailcap mimes when executed by tomb-status
|
||||||
|
# try xdg-open; if [ $? = 0 ]; then xdg-open ${1}; exit 0; fi
|
||||||
|
try gnome-open; if [ $? = 0 ]; then gnome-open ${1}; exit 0; fi
|
||||||
|
try thunar; if [ $? = 0 ]; then thunar ${1}; exit 0; fi
|
||||||
|
try pcmanfm; if [ $? = 0 ]; then pcmanfm ${1}; exit 0; fi
|
||||||
|
try rox; if [ $? = 0 ]; then rox ${1}; exit 0; fi
|
||||||
|
try fsviewer; if [ $? = 0 ]; then fsviewer ${1}; exit 0; fi
|
||||||
|
# try xnc; if [ $? = 0 ]; then xnc ${1}; exit 0; fi
|
||||||
|
tomb notify "File manager not found." "Tomb cannot guess which filemanager you are using"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# no argument but on graphical display: creation dialog
|
# no argument but on graphical display: creation dialog
|
||||||
if [ -z $DISPLAY ]; then
|
if [ -z $DISPLAY ]; then
|
||||||
@ -72,11 +87,7 @@ if [ -z $DISPLAY ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" != "create" ]; then
|
# no arguments: start guided tomb creation
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# start guided tomb creation
|
|
||||||
tomb notify
|
tomb notify
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Create a new Tomb
|
Create a new Tomb
|
||||||
@ -134,15 +145,11 @@ tomb create ${filename}.tomb $size
|
|||||||
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "An error occurred creating tomb, operation aborted."
|
echo "An error occurred creating tomb, operation aborted."
|
||||||
tomb kill
|
|
||||||
echo "Press any key to close this terminal."
|
|
||||||
read -q
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if ! [ -r /usr/share/applications/tomb.desktop ]; then
|
# if ! [ -r /usr/share/applications/tomb.desktop ]; then
|
||||||
echo " Well done!"
|
# echo " Well done!"
|
||||||
echo " Now the last thing to do is to install Tomb on your desktop:"
|
# echo " Now the last thing to do is to install Tomb on your desktop:"
|
||||||
sudo tomb install
|
# sudo tomb install
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
@ -145,27 +145,39 @@ gboolean left_click(GtkWidget *w, GdkEvent *e) {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
gboolean cb_view(GtkWidget *w, GdkEvent *e) {
|
gboolean cb_view(GtkWidget *w, GdkEvent *e) {
|
||||||
// GtkWidget *dialog =
|
int pipefd[2];
|
||||||
// gtk_message_dialog_new (NULL,
|
pid_t cpid;
|
||||||
// GTK_DIALOG_DESTROY_WITH_PARENT,
|
char buf;
|
||||||
// GTK_MESSAGE_INFO,
|
int c, res;
|
||||||
// GTK_BUTTONS_CLOSE,
|
char map[256];
|
||||||
// "Tomb '%s' open on '%s'\n"
|
|
||||||
// "device mapper: %s", filename, mountpoint, mapper);
|
if (pipe(pipefd) <0) {
|
||||||
// gtk_dialog_run (GTK_DIALOG (dialog));
|
fprintf(stderr,"pipe creation error: %s\n", strerror(errno));
|
||||||
// gtk_widget_destroy (dialog);
|
return FALSE;
|
||||||
pid_t cpid = fork();
|
}
|
||||||
|
|
||||||
|
cpid = fork();
|
||||||
if (cpid == -1) {
|
if (cpid == -1) {
|
||||||
fprintf(stderr,"error: problem forking process\n");
|
fprintf(stderr,"fork error: %s\n", strerror(errno));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (cpid == 0) { // Child
|
if (cpid == 0) { // Child
|
||||||
execlp("tomb-open", "tomb-open", mountpoint ,(char*)NULL);
|
close(pipefd[1]); // close unused write end
|
||||||
exit(1);
|
for(c=0; read(pipefd[0], &buf, 1) > 0; c++)
|
||||||
|
map[c] = buf;
|
||||||
|
close(pipefd[0]);
|
||||||
|
map[c] = 0;
|
||||||
|
execlp("tomb-open", "tomb-open", map, (char*)NULL);
|
||||||
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
close(pipefd[0]); // close unused read end
|
||||||
|
write(pipefd[1], mountpoint, strlen(mountpoint));
|
||||||
|
close(pipefd[1]); // reader will see EOF
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gboolean cb_close(GtkWidget *w, GdkEvent *e) {
|
gboolean cb_close(GtkWidget *w, GdkEvent *e) {
|
||||||
int pipefd[2];
|
int pipefd[2];
|
||||||
pid_t cpid;
|
pid_t cpid;
|
||||||
@ -189,7 +201,7 @@ gboolean cb_close(GtkWidget *w, GdkEvent *e) {
|
|||||||
for(c=0; read(pipefd[0], &buf, 1) > 0; c++)
|
for(c=0; read(pipefd[0], &buf, 1) > 0; c++)
|
||||||
map[c] = buf;
|
map[c] = buf;
|
||||||
close(pipefd[0]);
|
close(pipefd[0]);
|
||||||
map[c] = '\n';
|
map[c] = 0;
|
||||||
execlp("tomb", "tomb", "close", map, (char*)NULL);
|
execlp("tomb", "tomb", "close", map, (char*)NULL);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
@ -257,3 +269,12 @@ gboolean cb_about(GtkWidget *w, GdkEvent *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// GtkWidget *dialog =
|
||||||
|
// gtk_message_dialog_new (NULL,
|
||||||
|
// GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
|
// GTK_MESSAGE_INFO,
|
||||||
|
// GTK_BUTTONS_CLOSE,
|
||||||
|
// "Tomb '%s' open on '%s'\n"
|
||||||
|
// "device mapper: %s", filename, mountpoint, mapper);
|
||||||
|
// gtk_dialog_run (GTK_DIALOG (dialog));
|
||||||
|
// gtk_widget_destroy (dialog);
|
||||||
|
Loading…
Reference in New Issue
Block a user