ssfs view ssfs-box @ rev 68

Some small improvment and typo
author Christophe Lincoln <pankso@slitaz.org>
date Mon Jun 13 19:58:32 2011 +0200 (2011-06-13)
parents 51160b20e291
children 3a2f682ce267
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
11 pixmap=/usr/share/pixmaps/ssfs.png
13 #
14 # Functions
15 #
17 info() {
18 size=$(du -sh $HOME/Sync | awk '{print $1}')
19 files=$(find $HOME/Sync | wc -l)
20 host=$(fgrep 'host' $config | cut -d '"' -f 2)
21 login=${host%@*}
22 host=${host#*@}
23 echo -e "Login\n$login
24 Host\n$host
25 Size\n$size
26 Files\n$files
27 RSA Key\n~/.ssh/id_rsa"
28 }
30 # Default tools GUI box function.
31 tools_main() {
32 if [ ! -s "$config" ]; then
33 $0 setup && exit 0
34 fi
35 [ "$opts" ] || opts="--width=460 --height=320"
36 text=$(gettext "<b>Welcome to the Ssfs Client user interface</b>")
37 info | yad $opts \
38 --list --title="Ssfs Box" \
39 --image-on-top --window-icon=$pixmap \
40 --text="$text" --image=$pixmap \
41 --column "Ssfs" --column "$(gettext "Value")" \
42 --button="$(gettext "Setup client"):4" \
43 --button="$(gettext "Edit config"):3" \
44 --button="$(gettext "Browse files"):2" \
45 --button="gtk-close:1"
46 }
48 # Default tools functions.
49 tools() {
50 # Store box results
51 main=$(tools_main)
52 # Deal with --button values
53 case $? in
54 1) exit 0 ;;
55 2) file-manager $HOME/Sync ;;
56 3) editor $config ;;
57 4) $0 setup ;;
58 *) continue ;;
59 esac
60 case $main in
61 RSA*)
62 yad --text-info --title="RSA Key" \
63 --width=560 --height=420 \
64 --filename=$HOME/.ssh/id_rsa ;;
65 *)
66 continue ;;
67 esac
68 }
70 # Setup GUI box function.
71 setup_main() {
72 text=$(gettext \
73 "<b>Welcome to the Ssfs Setup</b>\n
74 Any account on a server yet ? You can vist www.slitaz.org
75 services or setup your own server in a few minutes!\n")
76 yad --form --title="Ssfs GTK Setup" \
77 --window-icon=$pixmap \
78 --width=460 --height=200 --image-on-top \
79 --text="$text" --image=$pixmap \
80 --field="Login" --field="Server"
81 }
83 # Default tools functions.
84 setup() {
85 # Store box results and setup.
86 main=$(setup_main)
87 [ $? == 1 ] && exit 0
88 login=$(echo $main | cut -d '|' -f 1)
89 host=$(echo $main | cut -d '|' -f 2)
90 [ "$host" ] || exit 0
91 rm -f $config
92 terminal -hold -geometry 76x16 -T "Ssfs" \
93 -e "ssfs setup --login=$login --host=$host"
94 }
96 # Notification mode.
97 notify() {
98 export opts="--geometry=460x320-40+40 --timeout=6 --skip-taskbar"
99 yad --notification --image=$pixmap --command=$0 \
100 --text="$(gettext "Ssfs Live Sync storage")"
101 }
103 #
104 # Commands
105 #
107 case "$1" in
108 help)
109 echo "Usage: $app [command]" ;;
110 setup)
111 setup ;;
112 notify)
113 notify ;;
114 *)
115 tools ;;
116 esac
117 exit 0