ssfs view ssfs-box @ rev 49

ssfs-box: small improvment
author Christophe Lincoln <pankso@slitaz.org>
date Sun Jun 12 19:16:41 2011 +0200 (2011-06-12)
parents adba1713f615
children a8e077c089e8
line source
1 #!/bin/sh
2 #
3 # SliTaz Secure File Storage GTK user interface using Yad.
4 #
5 # Copyright (C) SliTaz GNU/Linux - BSD License
6 # Author: Christophe Lincoln <pankso@slitaz.org>
7 #
9 app=$(basename $0)
10 config=$HOME/.config/ssfs/client.lua
12 #
13 # Functions
14 #
16 info() {
17 size=$(du -sh $HOME/Sync | awk '{print $1}')
18 host=$(fgrep 'host' $config | cut -d '"' -f 2)
19 login=${host%@*}
20 host=${host#*@}
21 echo -e "Login\n$login
22 Host\n$host
23 Size\n$size
24 RSA Key\n~/.ssh/id_rsa"
25 }
27 # Default tools GUI box function.
28 tools_main() {
29 if [ ! -s "$config" ]; then
30 $0 setup && exit 0
31 fi
32 text=$(gettext "<b>Welcome to the Ssfs GTK user interface</b>")
33 info | yad \
34 --list --title="Ssfs GTK tools" \
35 --width=460 --height=280 --image-on-top \
36 --text="$text" --image="slitaz-menu" \
37 --column "Ssfs" --column "$(gettext "Value")" \
38 --button="$(gettext "Edit config"):3" \
39 --button="$(gettext "Browse files"):2" \
40 --button="gtk-close:1"
41 }
43 # Default tools functions.
44 tools() {
45 # Store box results
46 main=$(tools_main)
47 # Deal with --button values
48 case $? in
49 1) exit 0 ;;
50 2) file-manager $HOME/Sync ;;
51 3) editor $config ;;
52 *) continue ;;
53 esac
54 case $main in
55 RSA*)
56 yad --text-info --title="RSA Key" \
57 --width=560 --height=380 \
58 --filename=$HOME/.ssh/id_rsa ;;
59 *)
60 echo "TODO: $main" ;;
61 esac
62 }
64 # Setup GUI box function.
65 setup_main() {
66 text=$(gettext \
67 "<b>Welcome to the Ssfs Setup</b>\n
68 Any account on a server yet ? You can vist www.slitaz.org
69 services or setup your own server in a few minutes!\n")
70 yad --form --title="Ssfs GTK Setup" \
71 --width=460 --height=200 --image-on-top \
72 --text="$text" --image="slitaz-menu" \
73 --field="Login" --field="Server"
74 }
76 # Default tools functions.
77 setup() {
78 # Store box results and setup.
79 main=$(setup_main)
80 [ $? == 1 ] && exit 0
81 login=$(echo $main | cut -d '|' -f 1)
82 host=$(echo $main | cut -d '|' -f 2)
83 [ "$host" ] || exit 0
84 rm -f $config
85 terminal -hold -geometry 76x16 -T "Ssfs connection" \
86 -e "ssfs setup --login=$login --host=$host"
87 }
89 #
90 # Commands
91 #
93 case "$1" in
94 help)
95 echo "Usage: $app [command]" ;;
96 setup)
97 setup ;;
98 *)
99 tools ;;
100 esac
101 exit 0